array of flexible structures oddity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm working on some code and noticed that sparse v0.6.4 now complains
about a seemingly innocuous use of "tty_port" from the Linux kernel:

struct my_struct {
    struct tty_port[5];
}

This occurs because the tty_port structure contains a tty_bufhead which
itself contains a "sentinel" member which is an intentionally zero-sized
flexible member.

In this case, the member is known to be zero sized and data is not
directly accessed.

This results in the array of tty_port being considered "flexible" and
thus we report this warning.

This seems like a wrong approach, or at least we ought to have a method
of marking such intentional uses.

There's no other warning, (i.e. we don't get a warning about embedding a
flexible structure into another structure despite this likely being a
bug in normal flows).

For now I can work around it by disabling the warning... but I think the
behavior here ought to be improved.

I think the following behavior is what i would consider ideal:

a) count the structure as flexible only if the last member is flexible
b) produce a warning on embedding a flexible structure or element
anywhere that is not the last position, unless
c) some attribute or other marker which lets us indicate that its known
behavior and is safely handled.

Thanks,
Jake




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux