Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1548486
| From | Linus Walleij <linus.walleij@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mmc: use empty initializer list to zero-clear structures |
| Date | 2016-12-30 09:10 +0100 |
| Message-ID | <sU0qd-1M6-3@gated-at.bofh.it> (permalink) |
| References | <sQ4LM-7gg-29@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Dec 19, 2016 at 12:51 PM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> In the MMC subsystem, we see such initializers that only clears the
> first member explicitly.
>
> For example,
>
> struct mmc_request mrq = {NULL};
>
> sets the first member (.sbc) to NULL explicitly. However, this is
> an unstable form because we may insert a non-pointer member at the
> top of the struct mmc_request in the future. (if we do so, the
> compiler will spit warnings.)
>
> So, using a designated initializer is preferred coding style. The
> expression above is equivalent to:
>
> struct mmc_request mrq = { .sbc = NULL };
>
> Of course, this does not express our intention. We want to fill
> all struct members with zeros. Please note struct members are
> implicitly zero-cleared unless otherwise specified in the initializer.
>
> After all, the most reasonable (and stable) form is:
>
> struct mmc_request mrq = {};
>
> Do likewise for mmc_command, mmc_data as well.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] mmc: use empty initializer list to zero-clear structures Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-12-19 13:00 +0100 Re: [PATCH] mmc: use empty initializer list to zero-clear structures Linus Walleij <linus.walleij@linaro.org> - 2016-12-30 09:10 +0100
csiph-web