From: Danny Al-Gaaf Date: Mon, 10 Mar 2014 19:01:22 +0000 (+0100) Subject: scratchtoolpp.cc: check return value of getchar() X-Git-Tag: v0.79~150^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2daabc1ecd292f1f4bc6c46f56ee4ddb425997e8;p=ceph.git 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 --- 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)