summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-01-01 22:08:21 +0000
committerBenny Prijono <bennylp@teluu.com>2009-01-01 22:08:21 +0000
commite8292035968488eb3a9b61a431afc8c9a39f51d3 (patch)
tree37b6e83a23282b53ed0ab8a602498798bb56c57d
parent423bd3b19d5611412da90b87f6989dc89339defa (diff)
Fixed gcc-4.3.2 warnings with the warn_unused_result flag in some APIs
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2408 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib-util/src/pjlib-util-test/main.c3
-rw-r--r--pjlib/src/pjlib-test/main.c3
-rw-r--r--pjmedia/src/test/main.c3
-rw-r--r--pjmedia/src/test/rtp_test.c5
-rw-r--r--pjnath/src/pjnath-test/main.c3
-rw-r--r--pjnath/src/pjturn-client/client_main.c3
-rw-r--r--pjnath/src/pjturn-srv/main.c3
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c9
-rw-r--r--pjsip-apps/src/samples/confsample.c12
-rw-r--r--pjsip-apps/src/samples/mix.c3
-rw-r--r--pjsip-apps/src/samples/pjsip-perf.c5
-rw-r--r--pjsip-apps/src/samples/playfile.c4
-rw-r--r--pjsip-apps/src/samples/playsine.c4
-rw-r--r--pjsip-apps/src/samples/recfile.c4
-rw-r--r--pjsip-apps/src/samples/resampleplay.c5
-rw-r--r--pjsip-apps/src/samples/simple_pjsua.c5
-rw-r--r--pjsip-apps/src/samples/siprtp.c11
-rw-r--r--pjsip-apps/src/samples/sndinfo.c5
-rw-r--r--pjsip-apps/src/samples/stateful_proxy.c6
-rw-r--r--pjsip-apps/src/samples/stateless_proxy.c6
-rw-r--r--pjsip-apps/src/samples/stereotest.c5
-rw-r--r--pjsip-apps/src/samples/streamutil.c5
-rw-r--r--pjsip-apps/src/samples/tonegen.c5
-rw-r--r--pjsip/src/test-pjsip/main.c3
24 files changed, 84 insertions, 36 deletions
diff --git a/pjlib-util/src/pjlib-util-test/main.c b/pjlib-util/src/pjlib-util-test/main.c
index ee025496..51a349b8 100644
--- a/pjlib-util/src/pjlib-util-test/main.c
+++ b/pjlib-util/src/pjlib-util-test/main.c
@@ -54,7 +54,8 @@ int main(int argc, char *argv[])
char s[10];
puts("Press ENTER to quit");
- fgets(s, sizeof(s), stdin);
+ if (fgets(s, sizeof(s), stdin) == NULL)
+ return rc;
}
return rc;
diff --git a/pjlib/src/pjlib-test/main.c b/pjlib/src/pjlib-test/main.c
index 85dc04a3..acae5445 100644
--- a/pjlib/src/pjlib-test/main.c
+++ b/pjlib/src/pjlib-test/main.c
@@ -98,7 +98,8 @@ int main(int argc, char *argv[])
char s[10];
puts("");
puts("Press <ENTER> to exit");
- fgets(s, sizeof(s), stdin);
+ if (!fgets(s, sizeof(s), stdin))
+ return rc;
}
return rc;
diff --git a/pjmedia/src/test/main.c b/pjmedia/src/test/main.c
index b041bca9..4b223566 100644
--- a/pjmedia/src/test/main.c
+++ b/pjmedia/src/test/main.c
@@ -39,7 +39,8 @@ int main(int argc, char *argv[])
if (argc == 2 && argv[1][0]=='-' && argv[1][1]=='i') {
puts("\nPress <ENTER> to quit");
- fgets(s, sizeof(s), stdin);
+ if (fgets(s, sizeof(s), stdin) == NULL)
+ return rc;
}
return rc;
diff --git a/pjmedia/src/test/rtp_test.c b/pjmedia/src/test/rtp_test.c
index c4a4e924..2a62520c 100644
--- a/pjmedia/src/test/rtp_test.c
+++ b/pjmedia/src/test/rtp_test.c
@@ -32,7 +32,10 @@ int rtp_test()
pjmedia_rtp_session_init (&rtp, 4, 0x12345678);
pjmedia_rtp_encode_rtp (&rtp, 4, 0, 0, 160, &rtphdr, &hdrlen);
- fwrite (rtphdr, hdrlen, 1, fhnd);
+ if (fwrite (rtphdr, hdrlen, 1, fhnd) != 1) {
+ fclose(fhnd);
+ return -1;
+ }
fclose(fhnd);
return 0;
}
diff --git a/pjnath/src/pjnath-test/main.c b/pjnath/src/pjnath-test/main.c
index 217a3b68..90709f6e 100644
--- a/pjnath/src/pjnath-test/main.c
+++ b/pjnath/src/pjnath-test/main.c
@@ -53,7 +53,8 @@ int main(int argc, char *argv[])
char buf[10];
puts("Press <ENTER> to exit");
- fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
+ return rc;
}
return rc;
diff --git a/pjnath/src/pjturn-client/client_main.c b/pjnath/src/pjturn-client/client_main.c
index 8567a1b1..36de03f5 100644
--- a/pjnath/src/pjturn-client/client_main.c
+++ b/pjnath/src/pjturn-client/client_main.c
@@ -445,7 +445,8 @@ static void console_main(void)
menu();
- fgets(input, sizeof(input), stdin);
+ if (fgets(input, sizeof(input), stdin) == NULL)
+ break;
switch (input[0]) {
case 'a':
diff --git a/pjnath/src/pjturn-srv/main.c b/pjnath/src/pjturn-srv/main.c
index fa5f7147..212ec458 100644
--- a/pjnath/src/pjturn-srv/main.c
+++ b/pjnath/src/pjturn-srv/main.c
@@ -108,7 +108,8 @@ static void console_main(pj_turn_srv *srv)
menu();
- fgets(line, sizeof(line), stdin);
+ if (fgets(line, sizeof(line), stdin) == NULL)
+ break;
switch (line[0]) {
case 'd':
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 882a11bc..5414b087 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2750,7 +2750,8 @@ static pj_bool_t simple_input(const char *title, char *buf, pj_size_t len)
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 @@ static void ui_input_url(const char *title, char *buf, int len,
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 @@ static void manage_codec_prio(void)
"(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 feb6aa11..676f4bb8 100644
--- a/pjsip-apps/src/samples/confsample.c
+++ b/pjsip-apps/src/samples/confsample.c
@@ -105,7 +105,8 @@ static pj_bool_t input(const char *title, char *buf, pj_size_t len)
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 6cf93a0f..f409af2b 100644
--- a/pjsip-apps/src/samples/mix.c
+++ b/pjsip-apps/src/samples/mix.c
@@ -129,7 +129,8 @@ int main(int argc, char *argv[])
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 e2a00183..ac8a5521 100644
--- a/pjsip-apps/src/samples/pjsip-perf.c
+++ b/pjsip-apps/src/samples/pjsip-perf.c
@@ -1809,7 +1809,7 @@ int main(int argc, char *argv[])
} else {
/* Server mode */
- char s[10];
+ char s[10], *unused;
pj_status_t status;
unsigned i;
@@ -1844,7 +1844,8 @@ int main(int argc, char *argv[])
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 a71ad41a..8c51271f 100644
--- a/pjsip-apps/src/samples/playfile.c
+++ b/pjsip-apps/src/samples/playfile.c
@@ -172,7 +172,9 @@ int main(int argc, char *argv[])
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 ebfcde01..e03b0d5d 100644
--- a/pjsip-apps/src/samples/playsine.c
+++ b/pjsip-apps/src/samples/playsine.c
@@ -277,7 +277,9 @@ int main(int argc, char *argv[])
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 92491731..e4187a65 100644
--- a/pjsip-apps/src/samples/recfile.c
+++ b/pjsip-apps/src/samples/recfile.c
@@ -167,7 +167,9 @@ int main(int argc, char *argv[])
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 d883da9a..7b5d1b14 100644
--- a/pjsip-apps/src/samples/resampleplay.c
+++ b/pjsip-apps/src/samples/resampleplay.c
@@ -190,8 +190,9 @@ int main(int argc, char *argv[])
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 d606a861..ab2d0174 100644
--- a/pjsip-apps/src/samples/simple_pjsua.c
+++ b/pjsip-apps/src/samples/simple_pjsua.c
@@ -182,7 +182,10 @@ int main(int argc, char *argv[])
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 e98084bc..b3e3d7d4 100644
--- a/pjsip-apps/src/samples/siprtp.c
+++ b/pjsip-apps/src/samples/siprtp.c
@@ -1862,7 +1862,8 @@ static pj_bool_t simple_input(const char *title, char *buf, pj_size_t len)
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 @@ static void console_main()
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 @@ static void app_log_writer(int level, const char *buffer, int len)
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 0658d91c..9f282d1a 100644
--- a/pjsip-apps/src/samples/sndinfo.c
+++ b/pjsip-apps/src/samples/sndinfo.c
@@ -202,8 +202,9 @@ static int open_device(int dev_id, pjmedia_dir dir,
/* 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 b110a071..a3468ef4 100644
--- a/pjsip-apps/src/samples/stateful_proxy.c
+++ b/pjsip-apps/src/samples/stateful_proxy.c
@@ -555,7 +555,11 @@ int main(int argc, char *argv[])
" 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 30f571d8..de3b5339 100644
--- a/pjsip-apps/src/samples/stateless_proxy.c
+++ b/pjsip-apps/src/samples/stateless_proxy.c
@@ -221,7 +221,11 @@ int main(int argc, char *argv[])
" 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 f7e9e6b7..504b2e07 100644
--- a/pjsip-apps/src/samples/stereotest.c
+++ b/pjsip-apps/src/samples/stereotest.c
@@ -295,8 +295,9 @@ int main(int argc, char *argv[])
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 ddb66cdf..36809190 100644
--- a/pjsip-apps/src/samples/streamutil.c
+++ b/pjsip-apps/src/samples/streamutil.c
@@ -616,7 +616,10 @@ int main(int argc, char *argv[])
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 4bd79e07..f0fc2f3f 100644
--- a/pjsip-apps/src/samples/tonegen.c
+++ b/pjsip-apps/src/samples/tonegen.c
@@ -127,8 +127,11 @@ int main()
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);
diff --git a/pjsip/src/test-pjsip/main.c b/pjsip/src/test-pjsip/main.c
index cba6ef05..044cd51a 100644
--- a/pjsip/src/test-pjsip/main.c
+++ b/pjsip/src/test-pjsip/main.c
@@ -82,7 +82,8 @@ int main(int argc, char *argv[])
if (interractive) {
char s[10];
printf("<Press ENTER to quit>\n"); fflush(stdout);
- fgets(s, sizeof(s), stdin);
+ if (fgets(s, sizeof(s), stdin) == NULL)
+ return retval;
}
return retval;