2022-03-21 07:57:13

by John Crispin

[permalink] [raw]
Subject: Re: [PATCH] ath9k: initialize arrays at compile time



On 20.03.22 16:20, [email protected] wrote:
> array[size] = { 0 };

should this not be array[size] = { }; ?!

If I recall correctly { 0 } will only set the first element of the
struct/array to 0 and leave random data in all others elements

John


2022-03-21 12:48:12

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH] ath9k: initialize arrays at compile time

On Mär 20 2022, John Crispin wrote:

> If I recall correctly { 0 } will only set the first element of the
> struct/array to 0 and leave random data in all others elements

An initializer always initializes the _whole_ object.

The subject is also wrong, all initializers are executed at run time
(automatic variables cannot be initialized at compile time).

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."