Fixed gcc-4.3.2 warnings with the warn_unused_result flag in some APIs

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2408 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 882a11b..5414b08 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2750,7 +2750,8 @@
     char *p;
 
     printf("%s (empty to cancel): ", title); fflush(stdout);
-    fgets(buf, len, stdin);
+    if (fgets(buf, len, stdin) == NULL)
+	return PJ_FALSE;
 
     /* Remove trailing newlines. */
     for (p=buf; ; ++p) {
@@ -2794,7 +2795,8 @@
     printf("%s: ", title);
 
     fflush(stdout);
-    fgets(buf, len, stdin);
+    if (fgets(buf, len, stdin) == NULL)
+	return;
     len = strlen(buf);
 
     /* Left trim */
@@ -3023,7 +3025,8 @@
 	 "(e.g. \"speex/16000 200\"), empty to cancel:");
 
     printf("Codec name (\"*\" for all) and priority: ");
-    fgets(input, sizeof(input), stdin);
+    if (fgets(input, sizeof(input), stdin) == NULL)
+	return;
     if (input[0]=='\r' || input[0]=='\n') {
 	puts("Done");
 	return;
diff --git a/pjsip-apps/src/samples/confsample.c b/pjsip-apps/src/samples/confsample.c
index feb6aa1..676f4bb 100644
--- a/pjsip-apps/src/samples/confsample.c
+++ b/pjsip-apps/src/samples/confsample.c
@@ -105,7 +105,8 @@
     char *p;
 
     printf("%s (empty to cancel): ", title); fflush(stdout);
-    fgets(buf, len, stdin);
+    if (fgets(buf, len, stdin) == NULL)
+	return PJ_FALSE;
 
     /* Remove trailing newlines. */
     for (p=buf; ; ++p) {
@@ -268,7 +269,7 @@
 	char tmp1[10];
 	char tmp2[10];
 	char *err;
-	int src, dst, level;
+	int src, dst, level, dur;
 
 	puts("");
 	conf_list(conf, 0);
@@ -285,7 +286,8 @@
 	
 	printf("Enter selection: "); fflush(stdout);
 
-	fgets(tmp, sizeof(tmp), stdin);
+	if (fgets(tmp, sizeof(tmp), stdin) == NULL)
+	    break;
 
 	switch (tmp[0]) {
 	case 's':
@@ -415,13 +417,13 @@
 
 	    if (!input("Duration to monitor (in seconds)", tmp1, sizeof(tmp1)) )
 		continue;
-	    strtol(tmp1, &err, 10);
+	    dur = strtol(tmp1, &err, 10);
 	    if (*err) {
 		puts("Invalid duration number");
 		continue;
 	    }
 
-	    monitor_level(conf, src, tmp2[0], strtol(tmp1, &err, 10));
+	    monitor_level(conf, src, tmp2[0], dur);
 	    break;
 
 	case 'q':
diff --git a/pjsip-apps/src/samples/mix.c b/pjsip-apps/src/samples/mix.c
index 6cf93a0..f409af2 100644
--- a/pjsip-apps/src/samples/mix.c
+++ b/pjsip-apps/src/samples/mix.c
@@ -129,7 +129,8 @@
 
 	printf("File %s exists, overwrite? [Y/N] ", out_fname);
 	fflush(stdout);
-	fgets(in, sizeof(in), stdin);
+	if (fgets(in, sizeof(in), stdin) == NULL)
+	    return 1;
 	if (pj_tolower(in[0]) != 'y')
 	    return 1;
     }
diff --git a/pjsip-apps/src/samples/pjsip-perf.c b/pjsip-apps/src/samples/pjsip-perf.c
index e2a0018..ac8a552 100644
--- a/pjsip-apps/src/samples/pjsip-perf.c
+++ b/pjsip-apps/src/samples/pjsip-perf.c
@@ -1809,7 +1809,7 @@
 
     } else {
 	/* Server mode */
-	char s[10];
+	char s[10], *unused;
 	pj_status_t status;
 	unsigned i;
 
@@ -1844,7 +1844,8 @@
 
 	puts("\nPress <ENTER> to quit\n");
 	fflush(stdout);
-	fgets(s, sizeof(s), stdin);
+	unused = fgets(s, sizeof(s), stdin);
+	PJ_UNUSED_ARG(unused);
 
 	app.thread_quit = PJ_TRUE;
 	for (i=0; i<app.thread_count; ++i) {
diff --git a/pjsip-apps/src/samples/playfile.c b/pjsip-apps/src/samples/playfile.c
index a71ad41..8c51271 100644
--- a/pjsip-apps/src/samples/playfile.c
+++ b/pjsip-apps/src/samples/playfile.c
@@ -172,7 +172,9 @@
     puts("");
     puts("Press <ENTER> to stop playing and quit");
 
-    fgets(tmp, sizeof(tmp), stdin);
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
 
     
     /* Start deinitialization: */
diff --git a/pjsip-apps/src/samples/playsine.c b/pjsip-apps/src/samples/playsine.c
index ebfcde0..e03b0d5 100644
--- a/pjsip-apps/src/samples/playsine.c
+++ b/pjsip-apps/src/samples/playsine.c
@@ -277,7 +277,9 @@
     puts("");
     puts("Press <ENTER> to stop playing and quit");
 
-    fgets(tmp, sizeof(tmp), stdin);
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
 
     
     /* Start deinitialization: */
diff --git a/pjsip-apps/src/samples/recfile.c b/pjsip-apps/src/samples/recfile.c
index 9249173..e4187a6 100644
--- a/pjsip-apps/src/samples/recfile.c
+++ b/pjsip-apps/src/samples/recfile.c
@@ -167,7 +167,9 @@
     puts("");
     puts("Press <ENTER> to stop recording and quit");
 
-    fgets(tmp, sizeof(tmp), stdin);
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
 
     
     /* Start deinitialization: */
diff --git a/pjsip-apps/src/samples/resampleplay.c b/pjsip-apps/src/samples/resampleplay.c
index d883da9..7b5d1b1 100644
--- a/pjsip-apps/src/samples/resampleplay.c
+++ b/pjsip-apps/src/samples/resampleplay.c
@@ -190,8 +190,9 @@
     puts("");
     puts("Press <ENTER> to stop playing and quit");
 
-    fgets(tmp, sizeof(tmp), stdin);
-
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
     
     /* Start deinitialization: */
 
diff --git a/pjsip-apps/src/samples/simple_pjsua.c b/pjsip-apps/src/samples/simple_pjsua.c
index d606a86..ab2d017 100644
--- a/pjsip-apps/src/samples/simple_pjsua.c
+++ b/pjsip-apps/src/samples/simple_pjsua.c
@@ -182,7 +182,10 @@
 	char option[10];
 
 	puts("Press 'h' to hangup all calls, 'q' to quit");
-	fgets(option, sizeof(option), stdin);
+	if (fgets(option, sizeof(option), stdin) == NULL) {
+	    puts("EOF while reading stdin, will quit now..");
+	    break;
+	}
 
 	if (option[0] == 'q')
 	    break;
diff --git a/pjsip-apps/src/samples/siprtp.c b/pjsip-apps/src/samples/siprtp.c
index e98084b..b3e3d7d 100644
--- a/pjsip-apps/src/samples/siprtp.c
+++ b/pjsip-apps/src/samples/siprtp.c
@@ -1862,7 +1862,8 @@
     char *p;
 
     printf("%s (empty to cancel): ", title); fflush(stdout);
-    fgets(buf, len, stdin);
+    if (fgets(buf, len, stdin) == NULL)
+	return PJ_FALSE;
 
     /* Remove trailing newlines. */
     for (p=buf; ; ++p) {
@@ -1898,7 +1899,10 @@
 
     for (;;) {
 	printf(">>> "); fflush(stdout);
-	fgets(input1, sizeof(input1), stdin);
+	if (fgets(input1, sizeof(input1), stdin) == NULL) {
+	    puts("EOF while reading stdin, will quit now..");
+	    break;
+	}
 
 	switch (input1[0]) {
 
@@ -2020,7 +2024,8 @@
 	pj_log_write(level, buffer, len);
 
     if (log_file) {
-	fwrite(buffer, len, 1, log_file);
+	int count = fwrite(buffer, len, 1, log_file);
+	PJ_UNUSED_ARG(count);
 	fflush(log_file);
     }
 }
diff --git a/pjsip-apps/src/samples/sndinfo.c b/pjsip-apps/src/samples/sndinfo.c
index 0658d91..9f282d1 100644
--- a/pjsip-apps/src/samples/sndinfo.c
+++ b/pjsip-apps/src/samples/sndinfo.c
@@ -202,8 +202,9 @@
     /* Let playback/capture runs for a while */
     //pj_thread_sleep(1000);
     puts("Press <ENTER> to stop");
-    fgets(tmp, sizeof(tmp), stdin);
-
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
 
     pjmedia_snd_stream_close(strm);
 
diff --git a/pjsip-apps/src/samples/stateful_proxy.c b/pjsip-apps/src/samples/stateful_proxy.c
index b110a07..a3468ef 100644
--- a/pjsip-apps/src/samples/stateful_proxy.c
+++ b/pjsip-apps/src/samples/stateful_proxy.c
@@ -555,7 +555,11 @@
 	     "  dd   dump detailed status\n"
 	     "");
 
-	fgets(line, sizeof(line), stdin);
+	if (fgets(line, sizeof(line), stdin) == NULL) {
+	    puts("EOF while reading stdin, will quit now..");
+	    global.quit_flag = PJ_TRUE;
+	    break;
+	}
 
 	if (line[0] == 'q') {
 	    global.quit_flag = PJ_TRUE;
diff --git a/pjsip-apps/src/samples/stateless_proxy.c b/pjsip-apps/src/samples/stateless_proxy.c
index 30f571d..de3b533 100644
--- a/pjsip-apps/src/samples/stateless_proxy.c
+++ b/pjsip-apps/src/samples/stateless_proxy.c
@@ -221,7 +221,11 @@
 	     "  dd   dump detailed status\n"
 	     "");
 
-	fgets(line, sizeof(line), stdin);
+	if (fgets(line, sizeof(line), stdin) == NULL) {
+	    puts("EOF while reading stdin, will quit now..");
+	    global.quit_flag = PJ_TRUE;
+	    break;
+	}
 
 	if (line[0] == 'q') {
 	    global.quit_flag = PJ_TRUE;
diff --git a/pjsip-apps/src/samples/stereotest.c b/pjsip-apps/src/samples/stereotest.c
index f7e9e6b..504b2e0 100644
--- a/pjsip-apps/src/samples/stereotest.c
+++ b/pjsip-apps/src/samples/stereotest.c
@@ -295,8 +295,9 @@
     puts("");
     puts("Press <ENTER> to stop and quit");
 
-    fgets(tmp, sizeof(tmp), stdin);
-
+    if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	puts("EOF while reading stdin, will quit now..");
+    }
     
     /* Start deinitialization: */
 
diff --git a/pjsip-apps/src/samples/streamutil.c b/pjsip-apps/src/samples/streamutil.c
index ddb66cd..3680919 100644
--- a/pjsip-apps/src/samples/streamutil.c
+++ b/pjsip-apps/src/samples/streamutil.c
@@ -616,7 +616,10 @@
 
 	printf("Command: "); fflush(stdout);
 
-	fgets(tmp, sizeof(tmp), stdin);
+	if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+	    puts("EOF while reading stdin, will quit now..");
+	    break;
+	}
 
 	if (tmp[0] == 's')
 	    print_stream_stat(stream);
diff --git a/pjsip-apps/src/samples/tonegen.c b/pjsip-apps/src/samples/tonegen.c
index 4bd79e0..f0fc2f3 100644
--- a/pjsip-apps/src/samples/tonegen.c
+++ b/pjsip-apps/src/samples/tonegen.c
@@ -127,8 +127,11 @@
 	f = fopen("tonegen.pcm", "wb");
 
 	for (i=0; i<8000/SAMPLES_PER_FRAME; ++i) {
+	    int count;
 	    pjmedia_port_get_frame(port, &frm);
-	    fwrite(buf, SAMPLES_PER_FRAME, 2, f);
+	    count = fwrite(buf, SAMPLES_PER_FRAME, 2, f);
+	    if (count != 2)
+		break;
 	}
 
 	pj_assert(pjmedia_tonegen_is_busy(port) == 0);