aboutsummaryrefslogtreecommitdiffstats
path: root/disk-utils/sfdisk.c
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2019-05-18 21:46:08 +0100
committerSami Kerola <kerolasa@iki.fi>2019-05-18 22:07:20 +0100
commit84f46d1f6725980697e5a442b06ececd9ceb6576 (patch)
treec6913c65d71c27702250d1d8af57390dd2f1642b /disk-utils/sfdisk.c
parent4ac2ab97d18fc53b169d492168cc455d55887038 (diff)
downloadutil-linux-84f46d1f6725980697e5a442b06ececd9ceb6576.tar.gz
sfdisk: remove unnecessary size check [cppcheck]
Following warning is false positive. Size of the buffer is defined using BUFSIZ, and so the strncpy() will never overwrite the last byte that is initialized to zero in get_user_reply(). [disk-utils/sfdisk.c:137] -> [disk-utils/sfdisk.c:136]: (warning) Either the condition 'bufsz!=0' is redundant or strncpy() argument nr 3 can have invalid value. The value is -1 but the valid values are '0:'. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/sfdisk.c')
-rw-r--r--disk-utils/sfdisk.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 4a9640d0e3..83f3cf8f7a 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -134,8 +134,6 @@ static int get_user_reply(const char *prompt, char *buf, size_t bufsz)
if (!p)
return 1;
strncpy(buf, p, bufsz - 1);
- if (bufsz != 0)
- buf[bufsz - 1] = '\0';
free(p);
} else
#endif