Skip to contentSkip to conversation

Avoid pointers for address of packed members

PATCH New Khem Raj 1 participant 1 message Mar 22, 2017 KVM

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 Avoid pointers for address of packed members

Fixes Clang warning due to -Waddress-of-packed-member

virtio/blk.c:161:37: error: taking address of packed member 'geometry' of class or structure 'virtio_blk_config' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]

        struct virtio_blk_geometry *geo = &conf->geometry;
---
 virtio/blk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
virtio/blk.c +1 -2
index c485e4f..1f7365d 100644
@@ -158,7 +158,6 @@ static void set_guest_features(struct kvm *kvm, void *dev, u32 features)
 {
 	struct blk_dev *bdev = dev;
 	struct virtio_blk_config *conf = &bdev->blk_config;
-	struct virtio_blk_geometry *geo = &conf->geometry;
 
 	bdev->features = features;
 
@@ -167,7 +166,7 @@ static void set_guest_features(struct kvm *kvm, void *dev, u32 features)
 	conf->seg_max = virtio_host_to_guest_u32(&bdev->vdev, conf->seg_max);
 
 	/* Geometry */
-	geo->cylinders = virtio_host_to_guest_u16(&bdev->vdev, geo->cylinders);
+	conf->geometry.cylinders = virtio_host_to_guest_u16(&bdev->vdev, conf->geometry.cylinders);
 
 	conf->blk_size = virtio_host_to_guest_u32(&bdev->vdev, conf->blk_size);
 	conf->min_io_size = virtio_host_to_guest_u16(&bdev->vdev, conf->min_io_size);
Signature · 1 line
2.12.0