> > Upon failure, write a warning message and continue > > Found-by: covscan > > Signed-off-by: Uri Lublin <uril@xxxxxxxxxx> > --- > > v1->v2: added a check for fopen too. > > --- > src/vdagentd/vdagentd.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c > index 72a3e13..ba1b0c7 100644 > --- a/src/vdagentd/vdagentd.c > +++ b/src/vdagentd/vdagentd.c > @@ -996,8 +996,13 @@ static void daemonize(void) > } > pidfile = fopen(pidfilename, "w"); > if (pidfile) { > - fprintf(pidfile, "%d\n", (int)getpid()); > + int r = fprintf(pidfile, "%d\n", (int)getpid()); > + if (r < 0) { > + syslog(LOG_WARNING, "Error writing to %s: %m", pidfilename); This won't never be executed, the condition should be if (fclose(pidfile) || r < 0) { the file is just opened, the string is small and the file is not a terminal (so full buffering, no line one, no flush) so fprintf will return r > 0. > + } > fclose(pidfile); removing this. > + } else { > + syslog(LOG_WARNING, "Failed to create pidfile %s: %m", > pidfilename); > } > break; > case -1: Frediano _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel