Apologies. ---------- Forwarded message ---------- From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Mon, Jul 27, 2015 at 8:31 AM Subject: Re: [FFmpeg-devel] [PATCH 2/2] ffmpeg: silence unused return value warnings To: Nicolas George <geo...@nsup.org>
On Mon, Jul 27, 2015 at 4:42 AM, Nicolas George <geo...@nsup.org> wrote: > L'octidi 8 thermidor, an CCXXIII, Ganesh Ajjanagadde a écrit : >> GCC throws a -Wunused-result for not checking return value >> of write(); silence it >> >> Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> >> --- >> ffmpeg.c | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/ffmpeg.c b/ffmpeg.c >> index 8b5a705..6f18ab8 100644 >> --- a/ffmpeg.c >> +++ b/ffmpeg.c >> @@ -329,16 +329,16 @@ sigterm_handler(int sig) >> switch (sig) { >> /* 2 = STDERR_FILENO */ >> case SIGSEGV: >> - write(2, "Segmentation fault, hard exiting\n", >> - strlen("Segmentation fault, hard exiting\n")); >> + if(write(2, "Segmentation fault, hard exiting\n", >> + strlen("Segmentation fault, hard exiting\n"))){}; > > (void)write(...) should be enough, and IMHO more readable. Not with latest GCC, see e.g discussion http://stackoverflow.com/questions/7271939/declared-with-attribute-warn-unused-result and GCC bugzilla link therein https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 Attached updated patch to reflect changes made. > >> abort(); >> case SIGILL: >> - write(2, "Invalid instruction, hard exiting\n", >> - strlen("Invalid instruction, hard exiting\n")); >> + if(write(2, "Invalid instruction, hard exiting\n", >> + strlen("Invalid instruction, hard exiting\n"))){}; >> abort(); >> case SIGFPE: >> - write(2, "Arithmetic exception, hard exiting\n", >> - strlen("Arithmetic exception, hard exiting\n")); >> + if(write(2, "Arithmetic exception, hard exiting\n", >> + strlen("Arithmetic exception, hard exiting\n"))){}; >> abort(); >> break; >> default: >> @@ -346,8 +346,8 @@ sigterm_handler(int sig) >> } >> >> if(received_nb_signals > 3) { >> - write(2, "Received > 3 system signals, hard exiting\n", >> - strlen("Received > 3 system signals, hard exiting\n")); >> + if(write(2, "Received > 3 system signals, hard exiting\n", >> + strlen("Received > 3 system signals, hard exiting\n"))){}; >> exit(123); > > Regards, > > -- > Nicolas George
From b916305503072c61725f42fd408b6c066782b9c9 Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Mon, 27 Jul 2015 08:14:29 -0400 Subject: [PATCH 2/2] ffmpeg: silence unused return value warnings GCC throws a -Wunused-result for not checking return value of write(); silence it Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- ffmpeg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 333ec08..ee2e499 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -331,15 +331,15 @@ sigterm_handler(int sig) /* 2 = STDERR_FILENO */ case SIGSEGV: msg = "Segmentation fault, hard exiting\n"; - write(2, msg, strlen(msg)); + if(write(2, msg, strlen(msg))){}; abort(); case SIGILL: msg = "Invalid instruction, hard exiting\n"; - write(2, msg, strlen(msg)); + if(write(2, msg, strlen(msg))){}; abort(); case SIGFPE: msg = "Arithmetic exception, hard exiting\n"; - write(2, msg, strlen(msg)); + if(write(2, msg, strlen(msg))){}; abort(); default: break; @@ -347,7 +347,7 @@ sigterm_handler(int sig) if(received_nb_signals > 3) { msg = "Received > 3 system signals, hard exiting\n"; - write(2, msg, strlen(msg)); + if(write(2, msg, strlen(msg))){}; exit(123); } } -- 2.4.6
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel