Patrick Colp
2010-Jun-04 20:04 UTC
[Xen-devel] [PATCH] Fix "error: ignoring return value of ‘freopen’" compile errors in xenwatchdogd
Hi, While trying to compile the latest pull of xen-unstable, I ran into these errors: cc1: warnings being treated as errors xenwatchdogd.c: In function ‘daemonize’: xenwatchdogd.c:31: error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result xenwatchdogd.c:32: error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result xenwatchdogd.c:33: error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result make: *** [xenwatchdogd.o] Error 1 This patch fixes xenwatchdogd to not ignore the return values. Signed-off-by: Patrick Colp <pjcolp@cs.ubc.ca> --- diff -r e9b5568232a8 tools/misc/xenwatchdogd.c --- a/tools/misc/xenwatchdogd.c Fri Jun 04 10:46:14 2010 -0700 +++ b/tools/misc/xenwatchdogd.c Fri Jun 04 10:52:46 2010 -0700 @@ -28,9 +28,12 @@ err(1, "setsid"); if (chdir("/") < 0) err(1, "chdir /"); - freopen("/dev/null", "r", stdin); - freopen("/dev/null", "w", stdout); - freopen("/dev/null", "w", stderr); + if (freopen("/dev/null", "r", stdin) == NULL) + err(1, "reopen stdin"); + if(freopen("/dev/null", "w", stdout) == NULL) + err(1, "reopen stdout"); + if(freopen("/dev/null", "w", stderr) == NULL) + err(1, "reopen stderr"); } void catch_exit(int sig) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel