diff mbox series

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

Message ID d66bfd66eb8744663b7a299db0df7203bc6640cd.1628933864.git.leonro@nvidia.com
State New
Headers show
Series Devlink cleanup for delay event series | expand

Commit Message

Leon Romanovsky Aug. 14, 2021, 9:57 a.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

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@nvidia.com>
---
 net/core/devlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Keller, Jacob E Aug. 16, 2021, 9:29 p.m. UTC | #1
> -----Original Message-----

> From: Leon Romanovsky <leon@kernel.org>

> Sent: Saturday, August 14, 2021 2:58 AM

> To: David S . Miller <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>

> Cc: Leon Romanovsky <leonro@nvidia.com>; Guangbin Huang

> <huangguangbin2@huawei.com>; Keller, Jacob E <jacob.e.keller@intel.com>; Jiri

> Pirko <jiri@nvidia.com>; linux-kernel@vger.kernel.org; netdev@vger.kernel.org;

> Salil Mehta <salil.mehta@huawei.com>; Shannon Nelson

> <snelson@pensando.io>; Yisen Zhuang <yisen.zhuang@huawei.com>; Yufeng

> Mo <moyufeng@huawei.com>

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

> 

> From: Leon Romanovsky <leonro@nvidia.com>

> 

> 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@nvidia.com>


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@intel.com>


> ---

>  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
diff mbox series

Patch

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,