RE: [PATCH net-next 5/6] devlink: Clear whole devlink_flash_notify struct

From: Keller, Jacob E
Date: Mon Aug 16 2021 - 17:29:50 EST




> -----Original Message-----
> From: Leon Romanovsky <leon@xxxxxxxxxx>
> Sent: Saturday, August 14, 2021 2:58 AM
> To: David S . Miller <davem@xxxxxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Leon Romanovsky <leonro@xxxxxxxxxx>; Guangbin Huang
> <huangguangbin2@xxxxxxxxxx>; Keller, Jacob E <jacob.e.keller@xxxxxxxxx>; Jiri
> Pirko <jiri@xxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx;
> Salil Mehta <salil.mehta@xxxxxxxxxx>; Shannon Nelson
> <snelson@xxxxxxxxxxx>; Yisen Zhuang <yisen.zhuang@xxxxxxxxxx>; Yufeng
> Mo <moyufeng@xxxxxxxxxx>
> Subject: [PATCH net-next 5/6] devlink: Clear whole devlink_flash_notify struct
>
> From: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> The { 0 } doesn't clear all fields in the struct, but tells to the
> compiler to set all fields to zero and doesn't touch any sub-fields
> if they exists.
>
> The {} is an empty initialiser that instructs to fully initialize whole
> struct including sub-fields, which is error-prone for future
> devlink_flash_notify extensions.
>
> Fixes: 6700acc5f1fe ("devlink: collect flash notify params into a struct")
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>

Yep, we should have used {} before. Are there any other misses where I used { 0 }.... Nope, I just double checked. Ok great!

Reviewed-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>

> ---
> net/core/devlink.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index d218f57ad8cf..a856ae401ea5 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -4169,7 +4169,7 @@ static void __devlink_flash_update_notify(struct
> devlink *devlink,
>
> static void devlink_flash_update_begin_notify(struct devlink *devlink)
> {
> - struct devlink_flash_notify params = { 0 };
> + struct devlink_flash_notify params = {};
>
> __devlink_flash_update_notify(devlink,
> DEVLINK_CMD_FLASH_UPDATE,
> @@ -4178,7 +4178,7 @@ static void devlink_flash_update_begin_notify(struct
> devlink *devlink)
>
> static void devlink_flash_update_end_notify(struct devlink *devlink)
> {
> - struct devlink_flash_notify params = { 0 };
> + struct devlink_flash_notify params = {};
>
> __devlink_flash_update_notify(devlink,
> DEVLINK_CMD_FLASH_UPDATE_END,
> --
> 2.31.1