From f6478958a4d4ffad128d97863aea9f8ad626b4bf Mon Sep 17 00:00:00 2001 From: "andrew@webrtc.org" Date: Tue, 6 Sep 2011 16:46:25 +0000 Subject: [PATCH] Fix "ignoring return value" in ViE tests. Review URL: http://webrtc-codereview.appspot.com/133016 git-svn-id: http://webrtc.googlecode.com/svn/trunk@538 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../test/AutoTest/source/vie_autotest_loopback.cc | 12 ++++++++++-- .../main/test/AutoTest/source/vie_autotest_main.cc | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc b/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc index 78b87b12d4..1d02ca0b53 100644 --- a/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc +++ b/src/video_engine/main/test/AutoTest/source/vie_autotest_loopback.cc @@ -153,7 +153,11 @@ int VideoEngineSampleCode(void* window1, void* window2) captureIdx = 0; printf("0\n"); #else - scanf("%d", &captureIdx); + if (scanf("%d", &captureIdx) != 1) + { + printf("Error in scanf()\n"); + return -1; + } getchar(); captureIdx = captureIdx - 1; // Compensate for idx start at 1. #endif @@ -311,7 +315,11 @@ int VideoEngineSampleCode(void* window1, void* window2) codecIdx = 0; printf("0\n"); #else - scanf("%d", &codecIdx); + if (scanf("%d", &codecIdx) != 1) + { + printf("Error in scanf()\n"); + return -1; + } getchar(); codecIdx = codecIdx - 1; // Compensate for idx start at 1. #endif diff --git a/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc b/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc index 6d320bd045..47360d5450 100644 --- a/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc +++ b/src/video_engine/main/test/AutoTest/source/vie_autotest_main.cc @@ -331,17 +331,18 @@ int ViEAutoTestMain::GetClassTestSelection() ViETest::Log("\t 11. Go back to previous menu"); ViETest::Log("Select type of test: "); + int items_read = 0; if (_useAnswerFile) { //GetNextAnswer(answer); } else { - scanf("%d", &testType); + items_read = scanf("%d", &testType); getchar(); } ViETest::Log("\n"); - if (testType >= 1 && testType <= 13) + if (items_read == 1 && testType >= 1 && testType <= 13) { return testType; }