Преглед на файлове

[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 преди 9 години
родител
ревизия
fae7a5310a
променени са 1 файла, в които са добавени 8 реда и са изтрити 4 реда
  1. 8
    4
      src/crypto/aes.c

+ 8
- 4
src/crypto/aes.c Целия файл

@@ -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…
Отказ
Запис