Skip to content

Commit 85ae2a4

Browse files
committed
Formatting, and proper initialization of bitfield storage.
1 parent 7ec5ffa commit 85ae2a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/mips/common/util/bitfield.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ struct BitField {
176176
return reinterpret_cast<const U*>(storage)[helper::firstByteOffset / sizeof(U)] >> helper::shift &
177177
helper::mask;
178178
} else {
179-
return (loadUnaligned<U, helper::bytesCount>(storage + helper::firstByteOffset) >> helper::shift) & helper::mask;
179+
return (loadUnaligned<U, helper::bytesCount>(storage + helper::firstByteOffset) >> helper::shift) &
180+
helper::mask;
180181
}
181182
return 0;
182183
}
@@ -198,8 +199,7 @@ struct BitField {
198199
storage[helper::firstByteOffset + 2] = static_cast<uint8_t>(v >> 16);
199200
} else {
200201
storage[helper::firstByteOffset] = static_cast<uint8_t>(v);
201-
*reinterpret_cast<uint16_t*>(storage + helper::firstByteOffset + 1) =
202-
static_cast<uint16_t>(v >> 8);
202+
*reinterpret_cast<uint16_t*>(storage + helper::firstByteOffset + 1) = static_cast<uint16_t>(v >> 8);
203203
}
204204
} else if constexpr (helper::bytesCount == 4) {
205205
if constexpr (helper::isAlignedAndSafe) {
@@ -219,7 +219,7 @@ struct BitField {
219219
storeUnaligned<U, helper::bytesCount>(storage + helper::firstByteOffset, span);
220220
}
221221
}
222-
uint8_t storage[BitFieldInternal::ComputeStorage<T...>::size()];
222+
uint8_t storage[BitFieldInternal::ComputeStorage<T...>::size()] = {0};
223223
};
224224

225225
} // namespace Utilities

0 commit comments

Comments
 (0)