linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for vm-scalability] usemem: Fix the build warning
@ 2019-12-25  8:34 Hui Zhu
  2019-12-25  8:45 ` Fengguang Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Zhu @ 2019-12-25  8:34 UTC (permalink / raw)
  To: fengguang.wu, linux-kernel; +Cc: Hui Zhu, Hui Zhu

Got:
gcc -O -c -Wall -g  usemem.c -o usemem.o
usemem.c: In function ‘output_statistics’:
usemem.c:638:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
  write(1, buf, len);

This commit fixes this warning.

Signed-off-by: Hui Zhu <teawaterz@linux.alibaba.com>
---
 usemem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/usemem.c b/usemem.c
index 85dbdc5..9158304 100644
--- a/usemem.c
+++ b/usemem.c
@@ -635,7 +635,8 @@ static void output_statistics(unsigned long unit_bytes, const char *intro)
 			"%s%lu bytes / %lu usecs = %lu KB/s\n",
 			intro, unit_bytes, delta_us, throughput);
 	fflush(stdout);
-	write(1, buf, len);
+	if (write(1, buf, len) != len)
+		printf("Output buf \"%s\" fail\n", buf);
 }
 
 static void timing_free(void *ptrs[], unsigned int nptr,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for vm-scalability] usemem: Fix the build warning
  2019-12-25  8:34 [PATCH for vm-scalability] usemem: Fix the build warning Hui Zhu
@ 2019-12-25  8:45 ` Fengguang Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Fengguang Wu @ 2019-12-25  8:45 UTC (permalink / raw)
  To: Hui Zhu; +Cc: linux-kernel, Hui Zhu

Thanks teawater!

>-	write(1, buf, len);
>+	if (write(1, buf, len) != len)
>+		printf("Output buf \"%s\" fail\n", buf);

Changed it to

                fprintf(stderr, "WARNING: statistics output may be incomplete.\n");

Thanks,
Fengguang

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-25  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-25  8:34 [PATCH for vm-scalability] usemem: Fix the build warning Hui Zhu
2019-12-25  8:45 ` Fengguang Wu

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).