Whamcloud - gitweb
LU-17504 build: fix gcc-13 [-Werror=stringop-overread] error 34/54834/6 master
authorShaun Tancheff <shaun.tancheff@hpe.com>
Thu, 25 Apr 2024 17:57:36 +0000 (00:57 +0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Apr 2024 06:58:41 +0000 (06:58 +0000)
This patch fixes the following [-Werror=stringop-overread] and
[-Werror=attribute-warning] errors detected by gcc 13:

lustre/mgc/mgc_request.c:190:21: error: 'strcmp' reading 1 or
more bytes from a region of size 0 [-Werror=stringop-overread]
  190 | if (strcmp(logname, cld->cld_logname) == 0) {
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In function 'fortify_memcpy_chk',
    inlined from 'class_handle_ioctl' at
/root/lustre-release/lustre/obdclass/class_obd.c:381:3:
include/linux/fortify-string.h:528:25: error:
call to '__write_overflow_field' declared with attribute warning:
detected write beyond size of field (1st parameter);
maybe use struct_group()? [-Werror=attribute-warning]
  528 |  __write_overflow_field(p_size_field, size);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jian Yu <yujian@whamcloud.com>
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I59f5a88b4cd64c9f4e67e568546baada371543b1
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54834
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
17 files changed:
libcfs/include/libcfs/libcfs_hash.h
libcfs/libcfs/hash.c
lnet/lnet/config.c
lnet/selftest/module.c
lustre/include/lustre_quota.h
lustre/include/lustre_sec.h
lustre/include/obd_class.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_ioctl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lfsck/lfsck_internal.h
lustre/mgc/mgc_request.c
lustre/obdclass/class_obd.c
lustre/obdclass/dt_object.c
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 7faa002..6fe31a6 100644 (file)
@@ -251,8 +251,8 @@ struct cfs_hash {
         /** workitem to output max depth */
        struct work_struct              hs_dep_work;
 #endif
-        /** name of htable */
-        char                        hs_name[0];
+       /** name of htable */
+       char                        hs_name[];
 };
 
 struct cfs_hash_lock_ops {
index 34da19d..b69f638 100644 (file)
@@ -1064,7 +1064,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
 
         len = (flags & CFS_HASH_BIGNAME) == 0 ?
               CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN;
-       LIBCFS_ALLOC(hs, offsetof(struct cfs_hash, hs_name[len]));
+       LIBCFS_ALLOC(hs, sizeof(struct cfs_hash) + len);
         if (hs == NULL)
                 RETURN(NULL);
 
index 01c61b7..fcdf3d6 100644 (file)
@@ -20,7 +20,7 @@
 struct lnet_text_buf {
        struct list_head        ltb_list;       /* stash on lists */
        int                     ltb_size;       /* allocated size */
-       char                    ltb_text[0];    /* text buffer */
+       char                    ltb_text[];     /* text buffer */
 };
 
 static int lnet_tbnob = 0;                     /* track text buf allocation */
index aafb427..56df179 100644 (file)
@@ -67,7 +67,7 @@ lnet_selftest_exit(void)
        }
 }
 
-void
+static void
 lnet_selftest_structure_assertion(void)
 {
        BUILD_BUG_ON(sizeof(struct srpc_msg) != 160);
index 798ecf9..dda0426 100644 (file)
@@ -78,7 +78,7 @@ struct lquota_iter {
        struct list_head li_link;
        __u32            li_md_size;
        __u32            li_dt_size;
-       char             li_buffer[0];
+       char             li_buffer[];
 };
 
 struct if_quotactl_iter {
index cdb2703..2cfbd02 100644 (file)
@@ -835,7 +835,7 @@ struct sptlrpc_sepol {
         * <mode>:<policy name>:<policy version>:<policy hash>
         */
        __u32           ssp_sepol_size;
-       char            ssp_sepol[0];
+       char            ssp_sepol[];
 };
 
 /**
index efe950d..9a25aa2 100644 (file)
@@ -308,7 +308,7 @@ struct config_llog_data {
                                                     * watching */
                                    cld_lostlock:1, /* lock not requeued */
                                    cld_processed:1;  /* successfully fetched */
-       char                        cld_logname[0];
+       char                        cld_logname[];
 };
 
 struct lustre_profile {
index 9bdba93..8be4759 100644 (file)
@@ -452,7 +452,7 @@ struct lu_dirent {
         *  their natural order. After the last attribute, padding bytes are
         *  added to make ->lde_reclen a multiple of 8.
         */
-       char          lde_name[0];
+       char          lde_name[];
 };
 
 /*
@@ -3363,7 +3363,7 @@ struct lu_idxpage {
         *
         * For the time being, we only support fixed-size key & record.
         */
-       char    lip_entries[0];
+       char    lip_entries[];
 };
 
 #define LIP_HDR_SIZE (offsetof(struct lu_idxpage, lip_entries))
@@ -3529,7 +3529,7 @@ struct object_update_param {
        __u16   oup_len;        /* length of this parameter */
        __u16   oup_padding;
        __u32   oup_padding2;
-       char    oup_buf[0];
+       char    oup_buf[];
 } __attribute__((packed));
 
 /* object update */
@@ -3541,7 +3541,7 @@ struct object_update {
        __u32           ou_padding1;            /* padding 1 */
        __u64           ou_batchid;             /* op transno on master */
        struct lu_fid   ou_fid;                 /* object to be updated */
-       struct object_update_param ou_params[0]; /* update params */
+       struct object_update_param ou_params[]; /* update params */
 };
 
 #define        UPDATE_REQUEST_MAGIC_V1 0xBDDE0001
@@ -3552,7 +3552,7 @@ struct object_update_request {
        __u32                   ourq_magic;
        __u16                   ourq_count;     /* number of ourq_updates[] */
        __u16                   ourq_padding;
-       struct object_update    ourq_updates[0];
+       struct object_update    ourq_updates[];
 };
 
 #define OUT_UPDATE_HEADER_MAGIC                0xBDDF0001
@@ -3563,7 +3563,7 @@ struct out_update_header {
        __u32           ouh_count;
        __u32           ouh_inline_length;
        __u32           ouh_reply_size;
-       __u32           ouh_inline_data[0];
+       __u32           ouh_inline_data[];
 };
 
 struct out_update_buffer {
@@ -3576,7 +3576,7 @@ struct object_update_result {
        __u32   our_rc;
        __u16   our_datalen;
        __u16   our_padding;
-       __u32   our_data[0];
+       __u32   our_data[];
 };
 
 #define UPDATE_REPLY_MAGIC_V1  0x00BD0001
@@ -3587,7 +3587,7 @@ struct object_update_reply {
        __u32   ourp_magic;
        __u16   ourp_count;
        __u16   ourp_padding;
-       __u16   ourp_lens[0];
+       __u16   ourp_lens[];
 };
 
 /* read update result */
@@ -3595,7 +3595,7 @@ struct out_read_reply {
        __u32   orr_size;
        __u32   orr_padding;
        __u64   orr_offset;
-       char    orr_data[0];
+       char    orr_data[];
 };
 
 #define BUT_REQUEST_MAGIC      0xBADE0001
index a5a43f6..146d5e3 100644 (file)
@@ -104,7 +104,7 @@ struct obd_ioctl_data {
        __u32           ioc_inllen4;
        char           *ioc_inlbuf4;
 
-       char            ioc_bulk[0];
+       char            ioc_bulk[];
 };
 
 struct obd_ioctl_hdr {
index 682a5bf..84fd56f 100644 (file)
@@ -1048,7 +1048,7 @@ struct lov_comp_md_v1 {
        __u8    lcm_padding3[1];
        __u16   lcm_padding1[2];
        __u64   lcm_padding2;
-       struct lov_comp_md_entry_v1 lcm_entries[0];
+       struct lov_comp_md_entry_v1 lcm_entries[];
 } __attribute__((packed));
 
 static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic)
@@ -2662,7 +2662,7 @@ struct hsm_action_list {
        __u64 hal_flags;
        __u32 hal_archive_id; /* which archive backend */
        __u32 padding1;
-       char  hal_fsname[0];   /* null-terminated */
+       char  hal_fsname[];   /* null-terminated */
        /* struct hsm_action_item[hal_count] follows, aligned on 8-byte
         * boundaries. See i_zero
         */
index 11f84f1..e037e47 100644 (file)
@@ -794,7 +794,7 @@ struct lfsck_namespace_req {
        __u32                            lnr_size;
        __u16                            lnr_type;
        __u16                            lnr_namelen;
-       char                             lnr_name[0];
+       char                             lnr_name[];
 };
 
 struct lfsck_layout_req {
index 7c2c27d..9b4b881 100644 (file)
@@ -206,23 +206,25 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd,
 {
        struct config_llog_data *cld;
        int rc;
+       int logname_size;
 
        ENTRY;
 
        CDEBUG(D_MGC, "do adding config log %s-%016lx\n", logname,
               cfg ? cfg->cfg_instance : 0);
 
-       OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1);
+       logname_size = strlen(logname) + 1;
+       OBD_ALLOC(cld, sizeof(*cld) + logname_size);
        if (!cld)
                RETURN(ERR_PTR(-ENOMEM));
 
        rc = mgc_logname2resid(logname, &cld->cld_resid, type);
        if (rc) {
-               OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1);
+               OBD_FREE(cld, sizeof(*cld) + logname_size);
                RETURN(ERR_PTR(rc));
        }
 
-       strcpy(cld->cld_logname, logname);
+       strscpy(cld->cld_logname, logname, logname_size);
        if (cfg)
                cld->cld_cfg = *cfg;
        else
index 8d598c2..aae8b56 100644 (file)
@@ -365,25 +365,27 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg)
        }
 
 #ifdef OBD_GET_VERSION
-       case_OBD_IOC_DEPRECATED(OBD_GET_VERSION, "obdclass", 2, 15)
+       case_OBD_IOC_DEPRECATED(OBD_GET_VERSION, "obdclass", 2, 15) {
+               size_t vstr_size = sizeof(LUSTRE_VERSION_STRING);
+
                if (!data->ioc_inlbuf1) {
                        rc = OBD_IOC_ERROR("obdclass", cmd, "no buffer passed",
                                           -EINVAL);
                        GOTO(out, rc);
                }
 
-               if (strlen(LUSTRE_VERSION_STRING) + 1 > data->ioc_inllen1) {
+               if (vstr_size > data->ioc_inllen1) {
                        rc = OBD_IOC_ERROR("obdclass", cmd, "buffer too small",
                                           -EINVAL);
                        GOTO(out, rc);
                }
 
-               memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING,
-                      strlen(LUSTRE_VERSION_STRING) + 1);
+               strscpy(data->ioc_bulk, LUSTRE_VERSION_STRING, vstr_size);
 
                if (copy_to_user(uarg, data, len))
                        rc = -EFAULT;
                GOTO(out, rc);
+       }
 #endif
        case OBD_IOC_NAME2DEV: {
                /* Resolve device name, does not change current selected dev */
index f14f9fb..981e0a6 100644 (file)
@@ -842,7 +842,7 @@ static int dt_index_page_build(const struct lu_env *env, struct dt_object *obj,
 {
        struct idx_info *ii = (struct idx_info *)arg;
        struct lu_idxpage *lip = &lp->lp_idx;
-       char *entry;
+       void *entry;
        __u64 hash;
        __u16 hashsize = 0;
        __u16 keysize = 0;
index 774c1e0..b80ce18 100644 (file)
@@ -5212,8 +5212,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct hsm_action_list *)0)->padding1));
        LASSERTF((int)offsetof(struct hsm_action_list, hal_fsname) == 32, "found %lld\n",
                 (long long)(int)offsetof(struct hsm_action_list, hal_fsname));
-       LASSERTF((int)sizeof(((struct hsm_action_list *)0)->hal_fsname) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct hsm_action_list *)0)->hal_fsname));
+       BUILD_BUG_ON(offsetof(struct hsm_action_list, hal_fsname) != sizeof(struct hsm_action_list));
 
        /* Checks for struct hsm_progress */
        LASSERTF((int)sizeof(struct hsm_progress) == 48, "found %lld\n",
@@ -5683,8 +5682,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding2));
        LASSERTF((int)offsetof(struct object_update_param, oup_buf) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_param, oup_buf));
-       LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_buf) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_param *)0)->oup_buf));
+       BUILD_BUG_ON(offsetof(struct object_update_param, oup_buf) != sizeof(struct object_update_param));
 
        /* Checks for struct object_update */
        LASSERTF((int)sizeof(struct object_update) == 40, "found %lld\n",
@@ -5719,8 +5717,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update *)0)->ou_fid));
        LASSERTF((int)offsetof(struct object_update, ou_params) == 40, "found %lld\n",
                 (long long)(int)offsetof(struct object_update, ou_params));
-       LASSERTF((int)sizeof(((struct object_update *)0)->ou_params) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update *)0)->ou_params));
+       BUILD_BUG_ON(offsetof(struct object_update, ou_params) != sizeof(struct object_update));
        BUILD_BUG_ON(UPDATE_FL_OST != 0x00000001);
        BUILD_BUG_ON(UPDATE_FL_SYNC != 0x00000002);
        BUILD_BUG_ON(UPDATE_FL_COMMITTED != 0x00000004);
@@ -5743,8 +5740,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_request *)0)->ourq_padding));
        LASSERTF((int)offsetof(struct object_update_request, ourq_updates) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_request, ourq_updates));
-       LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_updates) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_request *)0)->ourq_updates));
+       BUILD_BUG_ON(offsetof(struct object_update_request, ourq_updates) != sizeof(struct object_update_request));
        BUILD_BUG_ON(UPDATE_REQUEST_MAGIC != 0xBDDE0002);
 
        /* Checks for struct object_update_result */
@@ -5764,8 +5760,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_result *)0)->our_padding));
        LASSERTF((int)offsetof(struct object_update_result, our_data) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_result, our_data));
-       LASSERTF((int)sizeof(((struct object_update_result *)0)->our_data) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_result *)0)->our_data));
+       BUILD_BUG_ON(offsetof(struct object_update_result, our_data) != sizeof(struct object_update_result));
 
        /* Checks for struct object_update_reply */
        LASSERTF((int)sizeof(struct object_update_reply) == 8, "found %lld\n",
@@ -5784,8 +5779,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_padding));
        LASSERTF((int)offsetof(struct object_update_reply, ourp_lens) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_reply, ourp_lens));
-       LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_lens) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_lens));
+       BUILD_BUG_ON(offsetof(struct object_update_reply, ourp_lens) != sizeof(struct object_update_reply));
        BUILD_BUG_ON(UPDATE_REPLY_MAGIC != 0x00BD0002);
 
        /* Checks for struct out_update_header */
@@ -5809,8 +5803,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct out_update_header *)0)->ouh_reply_size));
        LASSERTF((int)offsetof(struct out_update_header, ouh_inline_data) == 16, "found %lld\n",
                 (long long)(int)offsetof(struct out_update_header, ouh_inline_data));
-       LASSERTF((int)sizeof(((struct out_update_header *)0)->ouh_inline_data) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct out_update_header *)0)->ouh_inline_data));
+       BUILD_BUG_ON(offsetof(struct out_update_header, ouh_inline_data) != sizeof(struct out_update_header));
        BUILD_BUG_ON(OUT_UPDATE_HEADER_MAGIC != 0xBDDF0001);
        BUILD_BUG_ON(OUT_UPDATE_MAX_INLINE_SIZE != 4096);
 
index da7bac0..a2e4175 100644 (file)
@@ -2463,7 +2463,7 @@ check_hsm_action_list(void)
        CHECK_MEMBER(hsm_action_list, hal_flags);
        CHECK_MEMBER(hsm_action_list, hal_archive_id);
        CHECK_MEMBER(hsm_action_list, padding1);
-       CHECK_MEMBER(hsm_action_list, hal_fsname);
+       CHECK_MEMBER_IS_FLEXIBLE(hsm_action_list, hal_fsname);
 }
 
 static void
@@ -2683,7 +2683,7 @@ static void check_object_update_param(void)
        CHECK_MEMBER(object_update_param, oup_len);
        CHECK_MEMBER(object_update_param, oup_padding);
        CHECK_MEMBER(object_update_param, oup_padding2);
-       CHECK_MEMBER(object_update_param, oup_buf);
+       CHECK_MEMBER_IS_FLEXIBLE(object_update_param, oup_buf);
 }
 
 static void check_object_update(void)
@@ -2697,7 +2697,7 @@ static void check_object_update(void)
        CHECK_MEMBER(object_update, ou_padding1);
        CHECK_MEMBER(object_update, ou_batchid);
        CHECK_MEMBER(object_update, ou_fid);
-       CHECK_MEMBER(object_update, ou_params);
+       CHECK_MEMBER_IS_FLEXIBLE(object_update, ou_params);
 
        CHECK_CVALUE_X(UPDATE_FL_OST);
        CHECK_CVALUE_X(UPDATE_FL_SYNC);
@@ -2712,7 +2712,7 @@ static void check_object_update_request(void)
        CHECK_MEMBER(object_update_request, ourq_magic);
        CHECK_MEMBER(object_update_request, ourq_count);
        CHECK_MEMBER(object_update_request, ourq_padding);
-       CHECK_MEMBER(object_update_request, ourq_updates);
+       CHECK_MEMBER_IS_FLEXIBLE(object_update_request, ourq_updates);
 
        CHECK_CDEFINE(UPDATE_REQUEST_MAGIC);
 }
@@ -2724,7 +2724,7 @@ static void check_object_update_result(void)
        CHECK_MEMBER(object_update_result, our_rc);
        CHECK_MEMBER(object_update_result, our_datalen);
        CHECK_MEMBER(object_update_result, our_padding);
-       CHECK_MEMBER(object_update_result, our_data);
+       CHECK_MEMBER_IS_FLEXIBLE(object_update_result, our_data);
 }
 
 static void check_object_update_reply(void)
@@ -2734,7 +2734,7 @@ static void check_object_update_reply(void)
        CHECK_MEMBER(object_update_reply, ourp_magic);
        CHECK_MEMBER(object_update_reply, ourp_count);
        CHECK_MEMBER(object_update_reply, ourp_padding);
-       CHECK_MEMBER(object_update_reply, ourp_lens);
+       CHECK_MEMBER_IS_FLEXIBLE(object_update_reply, ourp_lens);
 
        CHECK_CDEFINE(UPDATE_REPLY_MAGIC);
 }
@@ -2747,7 +2747,7 @@ static void check_out_update_header(void)
        CHECK_MEMBER(out_update_header, ouh_count);
        CHECK_MEMBER(out_update_header, ouh_inline_length);
        CHECK_MEMBER(out_update_header, ouh_reply_size);
-       CHECK_MEMBER(out_update_header, ouh_inline_data);
+       CHECK_MEMBER_IS_FLEXIBLE(out_update_header, ouh_inline_data);
 
        CHECK_CDEFINE(OUT_UPDATE_HEADER_MAGIC);
        CHECK_CDEFINE(OUT_UPDATE_MAX_INLINE_SIZE);
index 75543bc..7bc2eb7 100644 (file)
@@ -2046,8 +2046,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct lov_comp_md_v1 *)0)->lcm_padding2));
        LASSERTF((int)offsetof(struct lov_comp_md_v1, lcm_entries[0]) == 32, "found %lld\n",
                 (long long)(int)offsetof(struct lov_comp_md_v1, lcm_entries[0]));
-       LASSERTF((int)sizeof(((struct lov_comp_md_v1 *)0)->lcm_entries[0]) == 48, "found %lld\n",
-                (long long)(int)sizeof(((struct lov_comp_md_v1 *)0)->lcm_entries[0]));
+       BUILD_BUG_ON(offsetof(struct lov_comp_md_v1, lcm_entries) != sizeof(struct lov_comp_md_v1));
        BUILD_BUG_ON(LOV_MAGIC_COMP_V1 != (0x0BD60000 | 0x0BD0));
        LASSERTF(LCM_FL_NONE == 0, "found %lld\n",
                 (long long)LCM_FL_NONE);
@@ -5237,8 +5236,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct hsm_action_list *)0)->padding1));
        LASSERTF((int)offsetof(struct hsm_action_list, hal_fsname) == 32, "found %lld\n",
                 (long long)(int)offsetof(struct hsm_action_list, hal_fsname));
-       LASSERTF((int)sizeof(((struct hsm_action_list *)0)->hal_fsname) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct hsm_action_list *)0)->hal_fsname));
+       BUILD_BUG_ON(offsetof(struct hsm_action_list, hal_fsname) != sizeof(struct hsm_action_list));
 
        /* Checks for struct hsm_progress */
        LASSERTF((int)sizeof(struct hsm_progress) == 48, "found %lld\n",
@@ -5708,8 +5706,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding2));
        LASSERTF((int)offsetof(struct object_update_param, oup_buf) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_param, oup_buf));
-       LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_buf) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_param *)0)->oup_buf));
+       BUILD_BUG_ON(offsetof(struct object_update_param, oup_buf) != sizeof(struct object_update_param));
 
        /* Checks for struct object_update */
        LASSERTF((int)sizeof(struct object_update) == 40, "found %lld\n",
@@ -5744,8 +5741,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update *)0)->ou_fid));
        LASSERTF((int)offsetof(struct object_update, ou_params) == 40, "found %lld\n",
                 (long long)(int)offsetof(struct object_update, ou_params));
-       LASSERTF((int)sizeof(((struct object_update *)0)->ou_params) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update *)0)->ou_params));
+       BUILD_BUG_ON(offsetof(struct object_update, ou_params) != sizeof(struct object_update));
        BUILD_BUG_ON(UPDATE_FL_OST != 0x00000001);
        BUILD_BUG_ON(UPDATE_FL_SYNC != 0x00000002);
        BUILD_BUG_ON(UPDATE_FL_COMMITTED != 0x00000004);
@@ -5768,8 +5764,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_request *)0)->ourq_padding));
        LASSERTF((int)offsetof(struct object_update_request, ourq_updates) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_request, ourq_updates));
-       LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_updates) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_request *)0)->ourq_updates));
+       BUILD_BUG_ON(offsetof(struct object_update_request, ourq_updates) != sizeof(struct object_update_request));
        BUILD_BUG_ON(UPDATE_REQUEST_MAGIC != 0xBDDE0002);
 
        /* Checks for struct object_update_result */
@@ -5789,8 +5784,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_result *)0)->our_padding));
        LASSERTF((int)offsetof(struct object_update_result, our_data) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_result, our_data));
-       LASSERTF((int)sizeof(((struct object_update_result *)0)->our_data) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_result *)0)->our_data));
+       BUILD_BUG_ON(offsetof(struct object_update_result, our_data) != sizeof(struct object_update_result));
 
        /* Checks for struct object_update_reply */
        LASSERTF((int)sizeof(struct object_update_reply) == 8, "found %lld\n",
@@ -5809,8 +5803,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_padding));
        LASSERTF((int)offsetof(struct object_update_reply, ourp_lens) == 8, "found %lld\n",
                 (long long)(int)offsetof(struct object_update_reply, ourp_lens));
-       LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_lens) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_lens));
+       BUILD_BUG_ON(offsetof(struct object_update_reply, ourp_lens) != sizeof(struct object_update_reply));
        BUILD_BUG_ON(UPDATE_REPLY_MAGIC != 0x00BD0002);
 
        /* Checks for struct out_update_header */
@@ -5834,8 +5827,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)sizeof(((struct out_update_header *)0)->ouh_reply_size));
        LASSERTF((int)offsetof(struct out_update_header, ouh_inline_data) == 16, "found %lld\n",
                 (long long)(int)offsetof(struct out_update_header, ouh_inline_data));
-       LASSERTF((int)sizeof(((struct out_update_header *)0)->ouh_inline_data) == 0, "found %lld\n",
-                (long long)(int)sizeof(((struct out_update_header *)0)->ouh_inline_data));
+       BUILD_BUG_ON(offsetof(struct out_update_header, ouh_inline_data) != sizeof(struct out_update_header));
        BUILD_BUG_ON(OUT_UPDATE_HEADER_MAGIC != 0xBDDF0001);
        BUILD_BUG_ON(OUT_UPDATE_MAX_INLINE_SIZE != 4096);