kpartx: dasd: fix -Waddress-of-packed-member warning from gcc9
authorMartin Wilck <mwilck@suse.com>
Mon, 24 Jun 2019 09:27:26 +0000 (11:27 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 3 Jul 2019 06:30:27 +0000 (08:30 +0200)
Fixes the following warning:

dasd.c: In function ‘read_dasd_pt’:
dasd.c:206:3: warning: converting a packed ‘volume_label_t’ {aka ‘struct
volume_label’} pointer (alignment 1) to a ‘label_ints_t’ {aka ‘unsigned int’}
pointer (alignment 4) may result in an unaligned pointer value
[-Waddress-of-packed-member]
  206 |   label_ints_t *label = (label_ints_t *) &vlabel;
      |   ^~~~~~~~~~~~

As volume_label_t is only used in read_dasd_pt(), and filled with memcpy(),
increasing its alignment should be safe.

Signed-off-by: Martin Wilck <mwilck@suse.com>
kpartx/dasd.h

index 749af49..8ad5d62 100644 (file)
@@ -68,7 +68,7 @@ typedef struct volume_label
        char res3[28];          /* reserved                                  */
        uint8_t ldl_version;    /* version number, valid for ldl format      */
        uint64_t formatted_blocks; /* valid when ldl_version >= f2           */
-} __attribute__ ((packed)) volume_label_t;
+} __attribute__ ((packed, aligned(__alignof__(int)))) volume_label_t;
 
 
 typedef struct extent