From a3053cbc0ea15eab65072398eb48a5a8d20092f5 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Sat, 31 Aug 2019 19:52:18 -0500 Subject: [PATCH] streaming: Avoid -Wshadow warnings Renaming variables is easy enough here. While at it, use a static buffer rather than wasting time on memset(). Signed-off-by: Eric Blake --- plugins/streaming/streaming.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/streaming/streaming.c b/plugins/streaming/streaming.c index 4ab73b8b..b2359540 100644 --- a/plugins/streaming/streaming.c +++ b/plugins/streaming/streaming.c @@ -185,21 +185,19 @@ streaming_pwrite (void *handle, const void *buf, /* Need to write some zeroes. */ if (offset > highestwrite) { - int64_t size = offset - highestwrite; - char buf[4096]; + int64_t remaining = offset - highestwrite; + static char zerobuf[4096]; - memset (buf, 0, sizeof buf); - - while (size > 0) { - n = size > sizeof buf ? sizeof buf : size; - r = write (fd, buf, n); + while (remaining > 0) { + n = remaining > sizeof zerobuf ? sizeof zerobuf : remaining; + r = write (fd, zerobuf, n); if (r == -1) { nbdkit_error ("write: %m"); errorstate = 1; return -1; } highestwrite += r; - size -= r; + remaining -= r; } } -- 2.11.4.GIT