Re: [BlueZ PATCH] lib: fix variable-length array declarations in hci structures

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

 



Hi Marcel,

On Tue, Aug 31, 2021 at 2:54 PM Peter A. Bigot <pab@xxxxxxxxxxx> wrote:
>
> On 8/31/21 2:23 PM, Marcel Holtmann wrote:
> > Hi Peter,
> >
> >> Use of zero as the size for arrays as the last element of a structure
> >> is a GNU C extension, which as of GCC 10 produces diagnostics when
> >> values in the extended array are referenced.  Switch to the C99
> >> standard idiom for flexible array members, already in use in a few
> >> other headers.
> >>
> >> Signed-off-by: Peter A. Bigot <pab@xxxxxxxxxxx>
> >> ---
> >>
> >> No changes from previous submission except the BlueZ subject prefix
> >> that I hope will get this into bluez.
> >>
> >> lib/hci.h | 16 ++++++++--------
> >> 1 file changed, 8 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/lib/hci.h b/lib/hci.h
> >> index 3382b87bf..a61568bce 100644
> >> --- a/lib/hci.h
> >> +++ b/lib/hci.h
> >> @@ -729,7 +729,7 @@ typedef struct {
> >> typedef struct {
> >>      uint8_t         flt_type;
> >>      uint8_t         cond_type;
> >> -    uint8_t         condition[0];
> >> +    uint8_t         condition[];
> >> } __attribute__ ((packed)) set_event_flt_cp;
> >> #define SET_EVENT_FLT_CP_SIZE 2
> > does this break any API assumptions? Since as long as libbluetooth exists these headers are API.
>
> The size of the structure remains the same; there should be no API
> changes.  I've done this sort of change multiple times over the years
> and nobody's reported any problems.
>
> Peter

Looks like we also use [] in the kernel so I think it should be safe
to do this change on userspace as well.

-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux