On Thu, Aug 21, 2025 at 09:49:29PM +0100, Mark Brown wrote:
> On Thu, Aug 21, 2025 at 11:01:32PM +0300, Nikola Z. Ivanov wrote:
> > Remove 0/NULL global variable assignment in mixer-test.c and pcm-test.c
>
> Why?
>
> > --- a/tools/testing/selftests/alsa/mixer-test.c
> > +++ b/tools/testing/selftests/alsa/mixer-test.c
> > @@ -53,10 +53,10 @@ struct ctl_data {
> >     struct ctl_data *next;
> >  };
> >
> > -int num_cards = 0;
> > -int num_controls = 0;
> > -struct card_data *card_list = NULL;
> > -struct ctl_data *ctl_list = NULL;
> > +int num_cards;
> > +int num_controls;
> > +struct card_data *card_list;
> > +struct ctl_data *ctl_list;
>
> Nothing now sets initial values for these variables so they all have
> undefined values which is buggy.  The code is relying on the default
> values.

Checkpatch reports it as an error, it looks to be part of the C
standard that all compilers must initialize globals to 0.
Though I suppose it helps with readability to see
the num_ counters assigned 0.

Reply via email to