[FFmpeg-devel] [PATCH 2/2] ffmpeg: silence unused return value warnings
wm4
nfxjfg at googlemail.com
Mon Jul 27 13:33:30 CEST 2015
On Sun, 26 Jul 2015 23:53:23 -0400
Ganesh Ajjanagadde <gajjanagadde at gmail.com> wrote:
> GCC throws a -Wunused-result for not checking return value
> of write(); silence it
>
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at 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"))){};
> 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);
> }
> }
At this point, you should probably create a macro like
WRITE_SIGNAL_SAFE(), which does all this. (Also I agree
with Nicolas George that (void) is preferable.)
More information about the ffmpeg-devel
mailing list