[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sysvinit-devel] [PATCH 0/5] init.c: add return tests for fprintf()
From: |
Petter Reinholdtsen |
Subject: |
Re: [sysvinit-devel] [PATCH 0/5] init.c: add return tests for fprintf() |
Date: |
Mon, 10 Feb 2014 21:37:01 +0100 |
User-agent: |
Mutt/1.5.20 (2009-12-10) |
[Michał Kulling]
> Hi all,
Hi. :)
> I'll present all my patches for init.c, which patching several bugs
> from Coverity - you can dismiss my yesterday message. All patches
> was created on previous, patched file.
Thank you very much. :)
> --- init.c-orig 2014-02-10 20:41:50.922024360 +0100
> +++ init.c 2014-02-10 20:40:09.786021955 +0100
> @@ -372,34 +372,74 @@
> case C_REC:
> break;
> case D_RUNLEVEL:
> - fscanf(f, "%c\n", &runlevel);
> - break;
> + if(fscanf(f, "%c\n", &runlevel) < 0){
> + fprintf(stderr, "Read state pipe:
> %s\n", strerror(errno));
> + oops_error = -1;
> + return NULL;
> + }
> + break;
Perhaps the if(fscanf)...} part should be made into a function or
macro, to avoid duplicate code? It is repeated quite a lot of times.
--
Happy hacking
Petter Reinholdtsen