Because the unsigne long exists, the structure members are 8-byte aligned. If the int type is placed in the head and tail, 8 bytes are added. If the structure alignment is not considered, unpredictable memory exceptions, such as segment errors and malloc failures, may occur.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- include/wd.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/wd.h b/include/wd.h index 9b33dfc..5384afe 100644 --- a/include/wd.h +++ b/include/wd.h @@ -109,22 +109,23 @@ struct wd_dtb { __u32 bsize; };
+/* Members should be exactly 8-byte aligned */ struct uacce_dev { /* sysfs node content */ /* flag: SVA */ int flags; + int numa_id; /* HW context type */ char api[WD_NAME_SIZE]; /* dev supported algorithms */ char algs[MAX_ATTR_STR_SIZE]; - unsigned long qfrs_offs[UACCE_QFRT_MAX]; /* sysfs path with dev name */ char dev_root[PATH_STR_SIZE];
/* dev path in devfs */ char char_dev_path[MAX_DEV_NAME_LEN];
- int numa_id; + unsigned long qfrs_offs[UACCE_QFRT_MAX]; };
struct uacce_dev_list {