From 2daabc1ecd292f1f4bc6c46f56ee4ddb425997e8 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Mon, 10 Mar 2014 20:01:22 +0100 Subject: [PATCH] scratchtoolpp.cc: check return value of getchar() CID 716865 (#1 of 1): Unchecked return value from library (CHECKED_RETURN) 1. check_return: Calling function "getchar()" without checking return value. This library function may fail and return an error code. 2. unchecked_value: No check of the return value of "getchar()" Check really for 'enter' as the user asked for. Signed-off-by: Danny Al-Gaaf --- src/tools/scratchtoolpp.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/scratchtoolpp.cc b/src/tools/scratchtoolpp.cc index 62096920300..87074a6c2f9 100644 --- a/src/tools/scratchtoolpp.cc +++ b/src/tools/scratchtoolpp.cc @@ -41,8 +41,12 @@ public: void testradospp_milestone(void) { + int c; cout << "*** press enter to continue ***" << std::endl; - getchar(); + while ((c = getchar()) != EOF) { + if (c == '\n') + break; + } } int main(int argc, const char **argv) -- 2.47.3