[dm-devel] [PATCH 13/16] kpartx: fix strict aliasing warning
Benjamin Marzinski
bmarzins at redhat.com
Wed Dec 11 06:43:07 UTC 2013
Compiling with strict aliasing throws warnings about aliasing
volume_label_t to an array of unsigned ints. Adding __may_alias__
lets it know that we meant to do this.
Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>
---
kpartx/dasd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index dcdf678..1fcf778 100644
--- a/kpartx/dasd.c
+++ b/kpartx/dasd.c
@@ -46,6 +46,8 @@ unsigned long long sectors512(unsigned long long sectors, int blocksize)
return sectors * (blocksize >> 9);
}
+typedef unsigned int __attribute__((__may_alias__)) label_ints_t;
+
/*
*/
int
@@ -169,7 +171,7 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)
/*
* VM style CMS1 labeled disk
*/
- unsigned int *label = (unsigned int *) &vlabel;
+ label_ints_t *label = (label_ints_t *) &vlabel;
blocksize = label[4];
if (label[14] != 0) {
--
1.8.4.2
More information about the dm-devel
mailing list