Whamcloud - gitweb
LU-16518 utils: fix clang build errors
authorTimothy Day <timday@amazon.com>
Wed, 8 Nov 2023 20:22:54 +0000 (12:22 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 9 Nov 2023 08:36:09 +0000 (08:36 +0000)
This patch fixes a number of small clang build
errors in Lustre utils. Many errors are related
to nuances in typing or statements which appear
to be tautologies. These are resolved.

Some unneeded paranthesis are removed. A variable
is initialized which could potentially be left
uninitialized. And a comparison was added that
seemed to be left out.

Lustre-change: https://review.whamcloud.com/50161
Lustre-commit: 632dc6729abcaf83aeaef8167a73ce18b9a41a67

Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Id3f40b033e640f8d2ae6386f66a88de06fc89666
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53042
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/utils/gss/sk_utils.c
lustre/utils/lfs.c
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_layout.c

index 6b4b00a..3122a60 100644 (file)
@@ -2692,16 +2692,16 @@ struct llapi_ladvise_hdr {
 
 /* Shared key */
 enum sk_crypt_alg {
-       SK_CRYPT_INVALID        = -1,
        SK_CRYPT_EMPTY          = 0,
        SK_CRYPT_AES256_CTR     = 1,
+       SK_CRYPT_INVALID        = __UINT16_MAX__
 };
 
 enum sk_hmac_alg {
-       SK_HMAC_INVALID = -1,
        SK_HMAC_EMPTY   = 0,
        SK_HMAC_SHA256  = 1,
        SK_HMAC_SHA512  = 2,
+       SK_HMAC_INVALID = __UINT16_MAX__
 };
 
 struct sk_crypt_type {
index e627199..efcef1e 100755 (executable)
@@ -248,7 +248,7 @@ int sk_load_keyfile(char *path)
        }
        if (config->skc_type & SK_TYPE_SERVER) {
                /* Server keys need to have the file system name in the key */
-               if (!config->skc_fsname) {
+               if (config->skc_fsname[0] == '\0') {
                        printerr(0, "Key configuration has no file system "
                                 "attribute.  Can't load as server type\n");
                        goto out;
@@ -262,7 +262,7 @@ int sk_load_keyfile(char *path)
        }
        if (config->skc_type & SK_TYPE_CLIENT) {
                /* Load client file system key */
-               if (config->skc_fsname) {
+               if (config->skc_fsname[0] != '\0') {
                        rc = snprintf(description, SK_DESCRIPTION_SIZE,
                                      "lustre:%s", config->skc_fsname);
                        if (rc >= SK_DESCRIPTION_SIZE)
index 8d6b399..9feec18 100644 (file)
@@ -4867,8 +4867,8 @@ static int lfs_poollist(int argc, char **argv)
 }
 
 #define FP_DEFAULT_TIME_MARGIN (24 * 60 * 60)
-static time_t set_time(struct find_param *param, time_t *time, time_t *set,
-                      char *str)
+static int set_time(struct find_param *param, time_t *time, time_t *set,
+                   char *str)
 {
        long long t = 0;
        int sign = 0;
@@ -4915,7 +4915,7 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set,
                        fprintf(stderr,
                                "%s find: bad time string '%s': %s\n",
                                progname, timebuf, strerror(EINVAL));
-                       return LONG_MAX;
+                       return INT_MAX;
                }
 
                if (param->fp_time_margin == 0 ||
@@ -4929,7 +4929,7 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set,
                        str--;
                fprintf(stderr, "%s find: bad time '%s': too large\n",
                        progname, str);
-               return LONG_MAX;
+               return INT_MAX;
        }
 
        *set = *time - t;
@@ -5325,7 +5325,7 @@ static int lfs_find(int argc, char **argv)
                                param.fp_exclude_mtime = !!neg_opt;
                        }
                        rc = set_time(&param, &t, xtime, optarg);
-                       if (rc == LONG_MAX) {
+                       if (rc == INT_MAX) {
                                ret = -1;
                                goto err;
                        }
@@ -8699,7 +8699,8 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                else
                        printf(" %7s %7s %7s %7s", "-", "-", "-", "-");
                printf("\n");
-       } else if (qctl->qc_cmd == LUSTRE_Q_GETINFO || LUSTRE_Q_GETINFOPOOL ||
+       } else if (qctl->qc_cmd == LUSTRE_Q_GETINFO ||
+                  qctl->qc_cmd == LUSTRE_Q_GETINFOPOOL ||
                   qctl->qc_cmd == Q_GETOINFO) {
                char bgtimebuf[40];
                char igtimebuf[40];
index 12c9ff1..e459509 100644 (file)
@@ -2639,7 +2639,7 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                                             (__s16)lum->lmm_stripe_count);
                        }
                } else {
-                       llapi_printf(LLAPI_MSG_NORMAL, "%hd",
+                       llapi_printf(LLAPI_MSG_NORMAL, "%i",
                                     extension ? 0 :
                                     (__s16)lum->lmm_stripe_count);
                }
index 77f066d..1974782 100644 (file)
@@ -3192,7 +3192,7 @@ int llapi_layout_mirror_inherit(struct llapi_layout *f_layout,
  *                             belonging to these mirror will be collected.
  * \param[in] ids_nr           number of mirror ids array.
  *
- * \retval             number of component info collected on sucess or
+ * \retval             number of component info collected on success or
  *                     an error code on failure.
  */
 int llapi_mirror_find_stale(struct llapi_layout *layout,