/** 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 {
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);
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 */
}
}
-void
+static void
lnet_selftest_structure_assertion(void)
{
BUILD_BUG_ON(sizeof(struct srpc_msg) != 160);
struct list_head li_link;
__u32 li_md_size;
__u32 li_dt_size;
- char li_buffer[0];
+ char li_buffer[];
};
struct if_quotactl_iter {
* <mode>:<policy name>:<policy version>:<policy hash>
*/
__u32 ssp_sepol_size;
- char ssp_sepol[0];
+ char ssp_sepol[];
};
/**
* watching */
cld_lostlock:1, /* lock not requeued */
cld_processed:1; /* successfully fetched */
- char cld_logname[0];
+ char cld_logname[];
};
struct lustre_profile {
* 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[];
};
/*
*
* 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))
__u16 oup_len; /* length of this parameter */
__u16 oup_padding;
__u32 oup_padding2;
- char oup_buf[0];
+ char oup_buf[];
} __attribute__((packed));
/* 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
__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
__u32 ouh_count;
__u32 ouh_inline_length;
__u32 ouh_reply_size;
- __u32 ouh_inline_data[0];
+ __u32 ouh_inline_data[];
};
struct out_update_buffer {
__u32 our_rc;
__u16 our_datalen;
__u16 our_padding;
- __u32 our_data[0];
+ __u32 our_data[];
};
#define UPDATE_REPLY_MAGIC_V1 0x00BD0001
__u32 ourp_magic;
__u16 ourp_count;
__u16 ourp_padding;
- __u16 ourp_lens[0];
+ __u16 ourp_lens[];
};
/* read update result */
__u32 orr_size;
__u32 orr_padding;
__u64 orr_offset;
- char orr_data[0];
+ char orr_data[];
};
#define BUT_REQUEST_MAGIC 0xBADE0001
__u32 ioc_inllen4;
char *ioc_inlbuf4;
- char ioc_bulk[0];
+ char ioc_bulk[];
};
struct obd_ioctl_hdr {
__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)
__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
*/
__u32 lnr_size;
__u16 lnr_type;
__u16 lnr_namelen;
- char lnr_name[0];
+ char lnr_name[];
};
struct lfsck_layout_req {
{
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
}
#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 */
{
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;
(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",
(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",
(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);
(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 */
(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",
(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 */
(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);
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
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)
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);
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);
}
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)
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);
}
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);
(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);
(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",
(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",
(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);
(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 */
(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",
(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 */
(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);