From 155ea3e5ec44790385cd44953b48d2a892699afe Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 25 Apr 2024 15:36:44 -0700 Subject: [PATCH] LU-17504 build: fix gcc-13 [-Werror=stringop-overread] error 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Lustre-change: https://review.whamcloud.com/54834 Lustre-commit: TBD (from 787b45323742a00e262334ba6dfa8c7aff80bdac) Signed-off-by: Jian Yu Signed-off-by: Shaun Tancheff Change-Id: I59f5a88b4cd64c9f4e67e568546baada371543b1 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54874 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- libcfs/include/libcfs/libcfs_hash.h | 4 ++-- libcfs/libcfs/hash.c | 2 +- lnet/lnet/config.c | 2 +- lustre/include/obd_class.h | 2 +- lustre/include/uapi/linux/lustre/lustre_idl.h | 18 +++++++++--------- lustre/include/uapi/linux/lustre/lustre_ioctl.h | 2 +- lustre/include/uapi/linux/lustre/lustre_user.h | 4 ++-- lustre/lfsck/lfsck_internal.h | 2 +- lustre/mgc/mgc_request.c | 8 +++++--- lustre/obdclass/class_obd.c | 6 +++--- lustre/obdclass/dt_object.c | 2 +- lustre/ptlrpc/wiretest.c | 21 +++++++-------------- lustre/utils/wirecheck.c | 14 +++++++------- lustre/utils/wiretest.c | 24 ++++++++---------------- 14 files changed, 49 insertions(+), 62 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_hash.h b/libcfs/include/libcfs/libcfs_hash.h index d0e452c..78c7f37 100644 --- a/libcfs/include/libcfs/libcfs_hash.h +++ b/libcfs/include/libcfs/libcfs_hash.h @@ -266,8 +266,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 { diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index 291fd98..f72bad3 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -1065,7 +1065,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); diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index e107527..3b890da 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -43,7 +43,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 */ diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 1870177..e328b36 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -279,7 +279,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 { diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index ae26ed7..9118125 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -465,7 +465,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[]; }; /* @@ -3353,7 +3353,7 @@ struct lu_idxpage { * - the record size (II_FL_VARREC is set) * * 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)) @@ -3520,7 +3520,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[]; }; /* object update */ @@ -3532,7 +3532,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 @@ -3543,7 +3543,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 @@ -3554,7 +3554,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 { @@ -3567,7 +3567,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 @@ -3578,7 +3578,7 @@ struct object_update_reply { __u32 ourp_magic; __u16 ourp_count; __u16 ourp_padding; - __u16 ourp_lens[0]; + __u16 ourp_lens[]; }; /* read update result */ @@ -3586,7 +3586,7 @@ struct out_read_reply { __u32 orr_size; __u32 orr_padding; __u64 orr_offset; - char orr_data[0]; + char orr_data[]; }; /** layout swap request structure diff --git a/lustre/include/uapi/linux/lustre/lustre_ioctl.h b/lustre/include/uapi/linux/lustre/lustre_ioctl.h index 43dbf5a..6b4434a 100644 --- a/lustre/include/uapi/linux/lustre/lustre_ioctl.h +++ b/lustre/include/uapi/linux/lustre/lustre_ioctl.h @@ -103,7 +103,7 @@ struct obd_ioctl_data { __u32 ioc_inllen4; char *ioc_inlbuf4; - char ioc_bulk[0]; + char ioc_bulk[]; }; struct obd_ioctl_hdr { diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 1bedab6..65827f7 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -1028,7 +1028,7 @@ struct lov_comp_md_v1 { __u16 lcm_mirror_count; __u16 lcm_padding1[3]; __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) @@ -2596,7 +2596,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 hai_zero */ } __attribute__((packed)); diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index b7c599f..7a0462a 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -788,7 +788,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 { diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index c190486..020df62 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -209,23 +209,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 diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 42d8a3a..27759ee 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -318,13 +318,14 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0) case OBD_GET_VERSION: { static bool warned; + size_t vstr_size = sizeof(LUSTRE_VERSION_STRING); if (!data->ioc_inlbuf1) { CERROR("No buffer passed in ioctl\n"); GOTO(out, err = -EINVAL); } - if (strlen(LUSTRE_VERSION_STRING) + 1 > data->ioc_inllen1) { + if (vstr_size > data->ioc_inllen1) { CERROR("ioctl buffer too small to hold version\n"); GOTO(out, err = -EINVAL); } @@ -335,8 +336,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) "use llapi_get_version_string() and/or relink\n", current->comm); } - 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((void __user *)arg, data, len)) err = -EFAULT; diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index f063018..d4760f6 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -843,7 +843,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; diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index f56f0bc..b1513b6 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -5187,8 +5187,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", @@ -5658,8 +5657,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", @@ -5694,8 +5692,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); @@ -5718,8 +5715,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 */ @@ -5739,8 +5735,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", @@ -5759,8 +5754,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 */ @@ -5784,8 +5778,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); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 642b0cc..3c3fb79 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -2414,7 +2414,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 @@ -2633,7 +2633,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) @@ -2647,7 +2647,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); @@ -2662,7 +2662,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); } @@ -2674,7 +2674,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) @@ -2684,7 +2684,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); } @@ -2697,7 +2697,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); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 06bfee2..8be26b17 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -2082,8 +2082,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); @@ -5222,8 +5221,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", @@ -5693,8 +5691,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", @@ -5729,8 +5726,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); @@ -5753,8 +5749,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 */ @@ -5774,8 +5769,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", @@ -5794,8 +5788,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 */ @@ -5819,8 +5812,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); -- 1.8.3.1