summaryrefslogtreecommitdiffhomepage
path: root/device/alignment_test.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 15:30:32 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 15:37:04 +0100
commitd7bc7508e57d6227646f6aa81e5393a41a904518 (patch)
tree6854e627bb98d6d468c4fefe47d34d2004bb4f2e /device/alignment_test.go
parentd6e76fdbd6bae64a08662eb19d3634adb4881155 (diff)
device: fix alignment on 32-bit machines and test for it
The test previously checked the offset within a substruct, not the offset within the allocated struct, so this adds the two together. It then fixes an alignment crash on 32-bit machines. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/alignment_test.go')
-rw-r--r--device/alignment_test.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/device/alignment_test.go b/device/alignment_test.go
index 46baeb1..a918112 100644
--- a/device/alignment_test.go
+++ b/device/alignment_test.go
@@ -61,6 +61,5 @@ func TestDeviceAlignment(t *testing.T) {
field.Type.Align(),
)
}
-
- checkAlignment(t, "Device.rate.underLoadUntil", unsafe.Offsetof(d.rate.underLoadUntil))
+ checkAlignment(t, "Device.rate.underLoadUntil", unsafe.Offsetof(d.rate)+unsafe.Offsetof(d.rate.underLoadUntil))
}