mirror of
https://github.com/seL4/seL4.git
synced 2026-04-04 14:31:12 +00:00
bf gen: Removed some undefined bit shifts.
The bitfield generator constructs tags as enums. The compiler is free to back these by any type big enough to cover the enum. The generator emits code that uses these tag values in mask and shift operations where the target type is typically a uint32_t. As a result, it can produce code involving undefined shifts like: (seL4_CapData_Badge & 0x1) << 31 This commit casts the tag value to the unsigned target type before masking to ensure everything is done on an appropriate sized unsigned type. JIRA: SELFOUR-193
This commit is contained in:
@@ -1711,7 +1711,7 @@ class TaggedUnion:
|
||||
offset, size, high = ref.field_map[field]
|
||||
|
||||
if field == self.tagname:
|
||||
f_value = "%s_%s" % (self.name, name)
|
||||
f_value = "(uint%d_t)%s_%s" % (self.base, self.name, name)
|
||||
else:
|
||||
f_value = field
|
||||
|
||||
|
||||
Reference in New Issue
Block a user