From b5365d5e00aaea55d6b14d1ffc0d801c89d9f79d Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Tue, 28 Feb 2023 18:48:36 +0000 Subject: [PATCH] LU-16518 libcfs: fix clang build errors Adjust a strncat and the preceding if statement to account for the null terminator in the string. Use (void) to designate two variables as unused in a function to avoid doing a self-assign. Also, use an explicit format to fix the format security warning around alloc_workqueue. Signed-off-by: Timothy Day Change-Id: I14a19ba83c063cd81c16723c31d0488c2b4f607e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50162 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_cpu.h | 2 +- libcfs/libcfs/util/parser.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_cpu.h b/libcfs/include/libcfs/libcfs_cpu.h index cb2539e..20cd8c6 100644 --- a/libcfs/include/libcfs/libcfs_cpu.h +++ b/libcfs/include/libcfs/libcfs_cpu.h @@ -305,7 +305,7 @@ struct workqueue_struct *cfs_cpt_bind_workqueue(const char *wq_name, struct workqueue_attrs attrs = { }; struct workqueue_struct *wq; - wq = alloc_workqueue(wq_name, WQ_UNBOUND | flags, nthrs); + wq = alloc_workqueue("%s", WQ_UNBOUND | flags, nthrs, wq_name); if (!wq) return ERR_PTR(-ENOMEM); diff --git a/libcfs/libcfs/util/parser.c b/libcfs/libcfs/util/parser.c index 504cead..44887e9 100644 --- a/libcfs/libcfs/util/parser.c +++ b/libcfs/libcfs/util/parser.c @@ -504,14 +504,14 @@ int Parser_help(int argc, char **argv) */ line[0] = '\0'; for (i = 1; i < argc; i++) { - if (strlen(argv[i]) >= sizeof(line) - strlen(line)) + if (strlen(argv[i]) >= sizeof(line) - strlen(line) - 1) return -E2BIG; /* * The function strlcat() cannot be used here because of * this function is used in LNet utils that is not linked * with libcfs.a. */ - strncat(line, argv[i], sizeof(line) - strlen(line)); + strncat(line, argv[i], sizeof(line) - strlen(line) - 1); } switch (process(line, &next, top_level, &result, &prev)) { @@ -828,8 +828,8 @@ int Parser_bool(int *b, char *str) int Parser_quit(int argc, char **argv) { - argc = argc; - argv = argv; + (void) argc; + (void) argv; done = 1; return 0; } -- 1.8.3.1