Whamcloud - gitweb
LU-17657 build: gcc 13 stricter enum checking 68/54468/6
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 26 Apr 2024 15:25:19 +0000 (22:25 +0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 May 2024 18:24:02 +0000 (18:24 +0000)
gcc 13 does not allow mixing of enum and integer
types between function declaration and implementation.

Cleanup a couple of instances where an enum is treated
as an uint32_t / __u32 and treat it as an enum type.

lustre/lov/lov_ea.c: In function 'lsme_unpack_comp':
lustre/lov/lov_ea.c:531:21: error: array subscript
   'struct lov_stripe_md_entry[0]' is partly outside array bounds
    of 'struct lov_stripe_md_entry[0]' [-Werror=array-bounds=]
  531 |                 lsme->lsme_magic = magic;

Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I8e2ef989ecbdebe5e13bcea0fbb210c4a14eb45e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54468
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/include/lustre/lustreapi.h
lustre/include/lustre_net.h
lustre/lov/lov_ea.c

index f5e921e..876dce6 100644 (file)
@@ -1249,6 +1249,9 @@ enum llapi_layout_comp_use {
        LLAPI_LAYOUT_COMP_USE_LAST = 2,
        LLAPI_LAYOUT_COMP_USE_NEXT = 3,
        LLAPI_LAYOUT_COMP_USE_PREV = 4,
+
+       /* ensure -fshort-enums keeps u32 size for interop */
+       _LLAPI_LAYOUT_COMP_TYPE_SIZE = (__u32)-1,
 };
 
 /**
@@ -1258,7 +1261,8 @@ int llapi_layout_comp_use_id(struct llapi_layout *layout, uint32_t id);
 /**
  * Select the currently active component at the specified position.
  */
-int llapi_layout_comp_use(struct llapi_layout *layout, uint32_t pos);
+int llapi_layout_comp_use(struct llapi_layout *layout,
+                         enum llapi_layout_comp_use pos);
 /**
  * Add layout components to an existing file.
  */
index 7cdd4c6..762556e 100644 (file)
@@ -2291,7 +2291,8 @@ int ptlrpc_reconnect_import(struct obd_import *imp);
 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len);
 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len);
 
-int lustre_msg_check_version(struct lustre_msg *msg, __u32 version);
+int lustre_msg_check_version(struct lustre_msg *msg,
+                            enum lustre_msg_version version);
 void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
                        char **bufs);
 int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count,
@@ -2319,7 +2320,7 @@ __u32 lustre_msg_buflen(struct lustre_msg *m, __u32 n);
 void lustre_msg_set_buflen(struct lustre_msg *m, __u32 n, __u32 len);
 __u32 lustre_msg_bufcount(struct lustre_msg *m);
 char *lustre_msg_string(struct lustre_msg *m, __u32 n, __u32 max_len);
-__u32 lustre_msghdr_get_flags(struct lustre_msg *msg);
+enum lustre_msghdr lustre_msghdr_get_flags(struct lustre_msg *msg);
 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags);
 __u32 lustre_msg_get_flags(struct lustre_msg *msg);
 void lustre_msg_add_flags(struct lustre_msg *msg, __u32 flags);
index 45a1a65..d572e47 100644 (file)
@@ -525,11 +525,18 @@ lsme_unpack_comp(struct lov_obd *lov, struct lov_mds_md *lmm,
        magic = le32_to_cpu(lmm->lmm_magic);
        if (!lov_supported_comp_magic(magic)) {
                struct lov_stripe_md_entry *lsme;
+               size_t lsme_sz = offsetof(typeof(*lsme), lsme_oinfo[0]);
+               struct lov_stripe_md_entry lsme_init = {
+                       .lsme_pattern = le32_to_cpu(lmm->lmm_pattern),
+                       .lsme_magic = magic,
+               };
 
                /* allocate a lsme holder for invalid magic lmm */
-               OBD_ALLOC_LARGE(lsme, offsetof(typeof(*lsme), lsme_oinfo[0]));
-               lsme->lsme_magic = magic;
-               lsme->lsme_pattern = le32_to_cpu(lmm->lmm_pattern);
+               OBD_ALLOC_LARGE(lsme, lsme_sz);
+               if (!lsme)
+                       return ERR_PTR(-ENOMEM);
+
+               memcpy(lsme, &lsme_init, lsme_sz);
 
                return lsme;
        }