]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Fixing Alignment Error In intel smart-log-add
authorBen Reese <5884008+benreese0@users.noreply.github.com>
Tue, 3 Mar 2020 21:41:41 +0000 (13:41 -0800)
committerKeith Busch <kbusch@kernel.org>
Wed, 4 Mar 2020 01:02:18 +0000 (18:02 -0700)
Fixing alignment in nvme_additional_smart_log_item introduced by switch
from '#pragma pack' semantics to '__attribute__((pack))'.

Per https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html each
union or struct requires it's own '__attribute__((pack))'.

Signed-off-by: Ben Reese <5884008+benreese0@users.noreply.github.com>
plugins/intel/intel-nvme.c

index 64801e9e21b0805a1279d1d56be337c7773facf3..807f2d2a7b837fe5349e480d05d68b487ad61d4f 100644 (file)
 #define CREATE_CMD
 #include "intel-nvme.h"
 
-struct nvme_additional_smart_log_item {
+struct  __attribute__((packed)) nvme_additional_smart_log_item {
        __u8                    key;
        __u8                    _kp[2];
        __u8                    norm;
        __u8                    _np;
-       union {
+       union __attribute__((packed)) {
                __u8            raw[6];
-               struct wear_level {
+               struct __attribute__((packed))  wear_level {
                        __le16  min;
                        __le16  max;
                        __le16  avg;
                } wear_level;
-               struct thermal_throttle {
+               struct __attribute__((packed)) thermal_throttle {
                        __u8    pct;
                        __u32   count;
                } thermal_throttle;
-       };
+       } ;
        __u8                    _rp;
-} __attribute__((packed));
+} ;
 
 struct nvme_additional_smart_log {
        struct nvme_additional_smart_log_item   program_fail_cnt;