Re: [BlueZ 9/9] avdtp: Fix manipulating struct as an array

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

 



Hi Bastien,

On Fri, May 31, 2024 at 11:51 AM Bastien Nocera <hadess@xxxxxxxxxx> wrote:
>
> On Thu, 2024-05-30 at 19:57 +0300, Pauli Virtanen wrote:
> > Hi,
> >
> > to, 2024-05-30 kello 16:58 +0200, Bastien Nocera kirjoitti:
> > > Don't manipulate the "req" structs as if they were flat arrays,
> > > static
> > > analysis and humans are both equally confused by this kind of
> > > usage.
> >
> > struct start_req {
> >       union {
> >               struct seid required[1];
> >               struct seid seids[0];
> >       };
> > } __attribute__ ((packed));
> >
> > and access only via req->seids?
>
> That's a good idea, I'll give it a try.
>
> > <snip>
> > > +#define
> > > REQ_GET_NTH_SEID(x)                                         \
> > > +   static struct seid
> > > *                                           \
> > > +   x##_req_get_nth_seid(struct x##_req *req, int count, int
> > > i)  \
> > > +   {
> > >     \
> > > +           if (count == 0 || i >=
> > > count)                              \
> > > +                   return
> > > NULL;                                       \
> > > +           if (i ==
> > > 1)                                          \
> > > +                   return &req-
> > > >first_seid;                        \
> > > +           return &req-
> > > >other_seids[i];                            \
> >
> > (i == 0) and [i - 1]?
>
> *facepalm*
>
> Yes, this will need a v2, thanks for spotting that.

Ive applied the set except for this one, please resend once you are
done with the suggested changes.

-- 
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