From: "Alan D. Brunelle" <Alan.Brunelle@hp.com>
To: linux-btrace@vger.kernel.org
Subject: [PATCH] Fix compiler warning - check return value from ftruncate
Date: Wed, 12 Nov 2008 12:09:29 +0000 [thread overview]
Message-ID: <491AC779.8070301@hp.com> (raw)
[-- 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
reply other threads:[~2008-11-12 12:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=491AC779.8070301@hp.com \
--to=alan.brunelle@hp.com \
--cc=linux-btrace@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.