From: Jeremy Katz Subject: [PATCH] Check some returns of common functions Date: Tue, 25 Apr 2006 22:18:04 -0400 Message-ID: <1146017884.3007.13.camel@aglarond.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-M3BPGKh77zCsEfTi1nkA" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-M3BPGKh77zCsEfTi1nkA Content-Type: text/plain Content-Transfer-Encoding: 7bit When building with FORTIFY_SOURCE to ensure that return codes of common functions are checked to avoid some bugs, a few warnings pop up and become errors due to -Werror. Attached checks the return codes Signed-off-by: Jeremy Katz --=-M3BPGKh77zCsEfTi1nkA Content-Disposition: attachment; filename=xen-check-returns.patch Content-Type: text/x-patch; name=xen-check-returns.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit --- xen-unstable.hg/tools/xenstore/xenstored_core.c.unused 2006-04-25 22:06:11.000000000 -0400 +++ xen-unstable.hg/tools/xenstore/xenstored_core.c 2006-04-25 22:11:22.000000000 -0400 @@ -173,7 +173,7 @@ va_list arglist; char *str; char sbuf[1024]; - int ret; + int ret, dummy; if (tracefd < 0) return; @@ -184,7 +184,7 @@ va_end(arglist); if (ret <= 1024) { - write(tracefd, sbuf, ret); + dummy = write(tracefd, sbuf, ret); return; } @@ -192,7 +192,7 @@ va_start(arglist, fmt); str = talloc_vasprintf(NULL, fmt, arglist); va_end(arglist); - write(tracefd, str, strlen(str)); + dummy = write(tracefd, str, strlen(str)); talloc_free(str); } @@ -238,7 +238,8 @@ static void trigger_reopen_log(int signal __attribute__((unused))) { char c = 'A'; - write(reopen_log_pipe[1], &c, 1); + int dummy; + dummy = write(reopen_log_pipe[1], &c, 1); } @@ -1678,7 +1679,8 @@ exit(0); len = sprintf(buf, "%d\n", getpid()); - write(fd, buf, len); + if (write(fd, buf, len) != len) + barf_perror("Writing pid file %s", pidfile); } /* Stevens. */ @@ -1703,7 +1705,8 @@ #ifndef TESTING /* Relative paths for socket names */ /* Move off any mount points we might be in. */ - chdir("/"); + if (chdir("/") == -1) + barf_perror("Failed to chdir"); #endif /* Discard our parent's old-fashioned umask prejudices. */ umask(0); @@ -1900,7 +1903,8 @@ if (FD_ISSET(reopen_log_pipe[0], &inset)) { char c; - read(reopen_log_pipe[0], &c, 1); + if (read(reopen_log_pipe[0], &c, 1) != 1) + barf_perror("read failed"); reopen_log(); } --=-M3BPGKh77zCsEfTi1nkA Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-M3BPGKh77zCsEfTi1nkA--