Whamcloud - gitweb
LU-16518 libcfs: fix clang build errors 62/50162/4
authorTimothy Day <timday@amazon.com>
Tue, 28 Feb 2023 18:48:36 +0000 (18:48 +0000)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 Mar 2023 23:15:42 +0000 (23:15 +0000)
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 <timday@amazon.com>
Change-Id: I14a19ba83c063cd81c16723c31d0488c2b4f607e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50162
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/libcfs_cpu.h
libcfs/libcfs/util/parser.c

index cb2539e..20cd8c6 100644 (file)
@@ -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);
 
index 504cead..44887e9 100644 (file)
@@ -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;
 }