]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
scratchtoolpp.cc: check return value of getchar()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 10 Mar 2014 19:01:22 +0000 (20:01 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 10 Mar 2014 19:01:22 +0000 (20:01 +0100)
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 <danny.al-gaaf@bisect.de>
src/tools/scratchtoolpp.cc

index 62096920300bcaa727d16a8a3a33e137ee2d78f6..87074a6c2f9b4536e3273ef673c1d8636e56f4f6 100644 (file)
@@ -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)