linux-btrace.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix compiler warning - check return value from ftruncate
@ 2008-11-12 12:09 Alan D. Brunelle
  0 siblings, 0 replies; only message in thread
From: Alan D. Brunelle @ 2008-11-12 12:09 UTC (permalink / raw)
  To: linux-btrace

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-compiler-warning-check-return-value-from-ftrun.patch --]
[-- Type: text/x-diff; name="0001-Fix-compiler-warning-check-return-value-from-ftrun.patch", Size: 1258 bytes --]


gcc 4.3.2 has started to warn about:

gcc -o blktrace.o -c -Wall -O2 -g -W -D_GNU_SOURCE -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 blktrace.c
blktrace.c: In function ���������tip_ftrunc_final���������:
blktrace.c:662: warning: ignoring return value of ���������ftruncate���������, declared
with attribute warn_unused_result

This simple patch overcomes that - no exit is performed as this is not
fatal, and the thread will be exitting soon enough.

Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com>
---
 blktrace.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/blktrace.c b/blktrace.c
index 7e27f14..ad54db5 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -654,12 +654,18 @@ static void tip_ftrunc_final(struct thread_information *tip)
 	 * truncate to right size and cleanup mmap
 	 */
 	if (tip->ofile_mmap && tip->ofile) {
+		int ret;
 		int ofd = fileno(tip->ofile);
 
 		if (tip->fs_buf)
 			munmap(tip->fs_buf, tip->fs_buf_len);
 
-		ftruncate(ofd, tip->fs_size);
+		ret = ftruncate(ofd, tip->fs_size);
+		if (ret < 0) {
+			perror(tip->fn);
+			fprintf(stderr, "Warning: thread %d ftrunc failed\n",
+				tip->cpu);
+		}
 	}
 }
 
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-12 12:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12 12:09 [PATCH] Fix compiler warning - check return value from ftruncate Alan D. Brunelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).