aboutsummaryrefslogtreecommitdiff
path: root/include/f2fs_fs.h
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2019-03-18 15:39:55 +0900
committerJaegeuk Kim <jaegeuk@kernel.org>2019-03-23 18:59:24 +0900
commit8f80581f0d62df4ce103517a40298b7948480915 (patch)
tree35fb6e2ded32a383bd1ef6793c40435bb3cd6f79 /include/f2fs_fs.h
parent50e22bd9473c0741f119ecd9308154bdab6bcd71 (diff)
downloadf2fs-tools-8f80581f0d62df4ce103517a40298b7948480915.tar.gz
f2fs-tools: Fix various compilation warnings
Avoid various compilation warnings due to strncpy: libf2fs.c:590:33: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(rootdev, ret, "/dev/%s", buf); ../include/f2fs_fs.h:1384:2: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(buf, features, strlen(features) + 1); f2fstat.c:243:3: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] strncpy(ptr_buf, name[i], strlen(name[i])); This patch does not change any functionality. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'include/f2fs_fs.h')
-rw-r--r--include/f2fs_fs.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 8d1490c..02b500e 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1381,9 +1381,9 @@ static inline int parse_feature(struct feature *table, const char *features)
{
char *buf, *sub, *next;
- buf = calloc(strlen(features) + 1, sizeof(char));
- ASSERT(buf);
- strncpy(buf, features, strlen(features) + 1);
+ buf = strdup(features);
+ if (!buf)
+ return -1;
for (sub = buf; sub && *sub; sub = next ? next + 1 : NULL) {
/* Skip the beginning blanks */