Browse Source

[build] Fix strict-aliasing warning on older gcc versions

Reported-by: James A. Peltier <jpeltier@sfu.ca>
Reported-by: Matthew Helton <mwhelton@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
fae7a5310a
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      src/crypto/aes.c

+ 8
- 4
src/crypto/aes.c View File

@@ -156,13 +156,17 @@ static struct aes_table aes_invmixcolumns;
156 156
  */
157 157
 static inline __attribute__ (( always_inline )) uint32_t
158 158
 aes_entry_column ( const union aes_table_entry *entry, unsigned int column ) {
159
-	const uint8_t *first __attribute__ (( may_alias ));
159
+	const union {
160
+		uint8_t byte;
161
+		uint32_t column;
162
+	} __attribute__ (( may_alias )) *product;
160 163
 
161
-	/* Locate start of relevant four-byte subset */
162
-	first = &entry->byte[ 4 - column ];
164
+	/* Locate relevant four-byte subset */
165
+	product = container_of ( &entry->byte[ 4 - column ],
166
+				 typeof ( *product ), byte );
163 167
 
164 168
 	/* Extract this four-byte subset */
165
-	return ( *( ( uint32_t * ) first ) );
169
+	return product->column;
166 170
 }
167 171
 
168 172
 /**

Loading…
Cancel
Save