From: Timothy Day Date: Tue, 28 Feb 2023 18:48:04 +0000 (+0000) Subject: LU-16518 lnet: fix clang build errors X-Git-Tag: 2.15.56~190 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b0297a1056a4b0ee65f4405edd407a519db594e9;p=fs%2Flustre-release.git LU-16518 lnet: fix clang build errors LNET_PID_ANY and LNET_NID_ANY were defined outside the range of an u64. They were moved from -1 to the maximum value for u64. LNET_NID_ANY was used in an instance where LNET_NET_ANY should have been used. Initialize a variable which could potentially be left uninitialized. Fixed a minor style issue. Signed-off-by: Timothy Day Change-Id: I61c8b33d98fdaa4b7a4846d0061a483664e4f652 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50318 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Chris Horn Reviewed-by: Frank Sehr Reviewed-by: jsimmons Reviewed-by: Oleg Drokin --- diff --git a/lnet/include/uapi/linux/lnet/lnet-types.h b/lnet/include/uapi/linux/lnet/lnet-types.h index f515173..780b9b0 100644 --- a/lnet/include/uapi/linux/lnet/lnet-types.h +++ b/lnet/include/uapi/linux/lnet/lnet-types.h @@ -55,9 +55,9 @@ #define LNET_RESERVED_PORTAL 0 /** wildcard NID that matches any end-point address */ -#define LNET_NID_ANY ((lnet_nid_t) -1) +#define LNET_NID_ANY (~(lnet_nid_t) 0) /** wildcard PID that matches any lnet_pid_t */ -#define LNET_PID_ANY ((lnet_pid_t) -1) +#define LNET_PID_ANY (~(lnet_pid_t) 0) static inline int LNET_NID_IS_ANY(const struct lnet_nid *nid) { diff --git a/lnet/utils/lnetconfig/cyaml.c b/lnet/utils/lnetconfig/cyaml.c index 7c82645..032bb5a 100644 --- a/lnet/utils/lnetconfig/cyaml.c +++ b/lnet/utils/lnetconfig/cyaml.c @@ -1257,7 +1257,7 @@ void cYAML_build_error(int rc, int seq_no, char *cmd, char *entity, char *err_str, struct cYAML **root) { - struct cYAML *r = NULL, *err, *s, *itm, *cmd_obj; + struct cYAML *r = NULL, *err, *s, *itm = NULL, *cmd_obj; if (root == NULL) return; @@ -1277,8 +1277,9 @@ void cYAML_build_error(int rc, int seq_no, char *cmd, else if (cmd_obj == NULL) { s = cYAML_create_seq(r, cmd); itm = cYAML_create_seq_item(s); - } else if (cmd_obj != NULL && cmd_obj->cy_type != CYAML_TYPE_ARRAY) + } else if (cmd_obj != NULL && cmd_obj->cy_type != CYAML_TYPE_ARRAY) { goto failed; + } err = cYAML_create_object(itm, entity); if (err == NULL) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 967af40..ec326ef 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -4644,7 +4644,7 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree, /* assign the network id */ ip2nets.ip2nets_net.nw_id = libcfs_str2net(net->cy_valuestring); - if (ip2nets.ip2nets_net.nw_id == LNET_NID_ANY) + if (ip2nets.ip2nets_net.nw_id == LNET_NET_ANY) return LUSTRE_CFG_RC_BAD_PARAM; seq_no = cYAML_get_object_item(tree, "seq_no");