Whamcloud - gitweb
LU-9934 build: address issues raised by gcc7
[fs/lustre-release.git] / libcfs / libcfs / util / parser.c
index 3aa97a1..ec19dd1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2001 Cluster File Systems, Inc.
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014, 2017, Intel Corporation.
  *
  *   This file is part of Lustre, http://www.sf.net/projects/lustre/
  *
@@ -36,7 +36,7 @@
 #include <unistd.h>
 
 #include <libcfs/util/parser.h>
-#include <lustre_ver.h>
+#include <linux/lustre/lustre_ver.h>
 
 static command_t * top_level;           /* Top level of commands, initialized by
                                     * InitParser                              */
@@ -195,7 +195,7 @@ got_it:
        if ((*result)->pc_func != NULL) {
                return CMD_COMPLETE;
        } else {
-               if (*next == '\0') {
+               if (**next == '\0') {
                        return CMD_INCOMPLETE;
                } else {
                        return process(*next, next, (*result)->pc_sub_cmd,
@@ -549,7 +549,6 @@ int Parser_list_commands(const command_t *cmdlist, char *buffer,
        int col = col_start;
        int char_max;
        int len;
-       char fmt[6];
        int count = 0;
        int rc;
 
@@ -572,9 +571,9 @@ int Parser_list_commands(const command_t *cmdlist, char *buffer,
 
                /* Add trailing spaces to pad the entry to the column size */
                if (len < char_max) {
-                       snprintf(fmt, 6, "%%-%2ds", char_max - len);
                        snprintf(&buffer[col * char_max] + len,
-                                char_max - len + 1, fmt, " ");
+                                char_max - len + 1, "%*s", char_max - len,
+                                " ");
                } else {
                        buffer[(col + 1) * char_max - 1] = ' ';
                }