From 632dc6729abcaf83aeaef8167a73ce18b9a41a67 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Tue, 28 Feb 2023 18:47:06 +0000 Subject: [PATCH] LU-16518 utils: fix clang build errors 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. Signed-off-by: Timothy Day Change-Id: Id3f40b033e640f8d2ae6386f66a88de06fc89666 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50161 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/include/uapi/linux/lustre/lustre_user.h | 4 ++-- lustre/utils/gss/sk_utils.c | 4 ++-- lustre/utils/lfs.c | 13 +++++++------ lustre/utils/liblustreapi.c | 2 +- lustre/utils/liblustreapi_layout.c | 4 ++-- lustre/utils/mkfs_lustre.c | 2 +- lustre/utils/obd.c | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index b78ea2b..920c9de 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2628,16 +2628,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 { diff --git a/lustre/utils/gss/sk_utils.c b/lustre/utils/gss/sk_utils.c index e627199..efcef1e 100755 --- a/lustre/utils/gss/sk_utils.c +++ b/lustre/utils/gss/sk_utils.c @@ -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) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 96cff47..aabcce8 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -4637,8 +4637,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; @@ -4685,7 +4685,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 || @@ -4699,7 +4699,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; @@ -5248,7 +5248,7 @@ static int lfs_find(int argc, char **argv) param.fp_exclude_mtime = !!neg_opt; } rc = set_time(¶m, &t, xtime, optarg); - if (rc == LONG_MAX) { + if (rc == INT_MAX) { ret = -1; goto err; } @@ -8623,7 +8623,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]; diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 80c062b..f239eca 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2787,7 +2787,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); } diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index 2adb66b..10f82be 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -2785,7 +2785,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, @@ -2942,7 +2942,7 @@ int llapi_mirror_resync_many(int fd, struct llapi_layout *layout, return -rc; while (pos < end) { - uint64_t mirror_end; + uint64_t mirror_end = LUSTRE_EOF; ssize_t bytes_read; size_t to_read; size_t to_write; diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 94d35ce..68fd09e 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -861,7 +861,7 @@ int chk_args(int argc, char *const argv[]) /* This check validates if the last argument is really a device name * and does not start with char '-'. */ - if ((argv[argc - 1][0] == '-')) + if (argv[argc - 1][0] == '-') return 1; else return 0; diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index d07da81..5d5ae5c 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -3497,7 +3497,7 @@ static int llog_search_pool_cb(const char *record, void *data) */ if (strstr(record, add_pool)) lpd->lpd_ost_num++; - } else if (lpd->lpd_ostname && lpd->lpd_ostname[0]) { + } else if (lpd->lpd_ostname[0] != '\0') { if (strstr(record, lpd->lpd_ostname)) { lpd->lpd_pool_exists = true; if (strstr(record, add_pool)) { -- 1.8.3.1