Page MenuHomeFreeBSD

achiem: quiet gcc -Warray-bounds
ClosedPublic

Authored by rlibby on Fri, Oct 17, 7:00 AM.
Tags
None
Referenced Files
F132679703: D53152.id164463.diff
Sun, Oct 19, 12:05 AM
F132670442: D53152.id164463.diff
Sat, Oct 18, 10:27 PM
Unknown Object (File)
Fri, Oct 17, 4:39 PM
Unknown Object (File)
Fri, Oct 17, 9:59 AM
Unknown Object (File)
Fri, Oct 17, 9:57 AM
Unknown Object (File)
Fri, Oct 17, 9:37 AM
Subscribers

Details

Summary

gcc complains about accessing the byte as ads->common.bytes[3] as that
field is declared as being one byte.

Test Plan

env CROSS_TOOLCHAIN=amd64-gcc14 make buildkernel

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rlibby added a reviewer: mav.

I think there should be 1, not 2.

In D53152#1214504, @mav wrote:

I think there should be 1, not 2.

Sorry, not sure I follow. Are you referring to the index in ads->bytes?

% ctfdump -t /boot/kernel/kernel | grep -A 3 ses_status_array_dev_slot
  <4752> STRUCT ses_status_array_dev_slot (4 bytes)
	common type=3929 off=0
	bytes type=521 off=8

% kgdb -q /boot/kernel/kernel                                         
Reading symbols from /boot/kernel/kernel...
Reading symbols from /usr/lib/debug//boot/kernel/kernel.debug...
(kgdb) ptype /o struct ses_status_array_dev_slot
/* offset      |    size */  type = struct ses_status_array_dev_slot {
/*      0      |       1 */    struct ses_status_common {
/*      0      |       1 */        uint8_t bytes[1];

                                   /* total size (bytes):    1 */
                               } common;
/*      1      |       3 */    uint8_t bytes[3];

                               /* total size (bytes):    4 */
                             }
(kgdb) set $ads = (struct ses_status_array_dev_slot *)0
(kgdb) p (uintptr_t)&$ads->common.bytes[3]
$1 = 3
(kgdb) p (uintptr_t)&$ads->bytes[2]
$2 = 3

I'm sorry, you are right. I've mixed ses_status_array_dev_slot with ses_status_dev_slot.

This revision is now accepted and ready to land.Fri, Oct 17, 4:24 PM
This revision was automatically updated to reflect the committed changes.