ethtool: Use explicit designated initializers for .cmd
Subsystems (2)
PATCH 1/1 ethtool: Use explicit designated initializers for .cmd
Initialize the .cmd member of various ethtool using a designated struct initializer rather. This makes things a teeny bit more robust, although the chance of a struct layout changing is extremely remote, and also makes the code a little easier to read.
---
Just something I noticed while browsing the code. Doesn't change generated code, and at least for me makes things slightly cleaner.
net/core/ethtool.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
net/core/ethtool.c +5 -5
@@ -146,7 +146,7 @@ int ethtool_op_set_flags(struct net_device *dev, u32 data)static int ethtool_get_settings (struct net_device *dev,void __user *useraddr) { -struct ethtool_cmd cmd = {ETHTOOL_GSET }; +struct ethtool_cmd cmd = { .cmd =ETHTOOL_GSET };int err;if (!dev->ethtool_ops->get_settings)
@@ -324,7 +324,7 @@ static int ethtool_reset(struct net_device *dev, char __user *useraddr)static int ethtool_get_wol (struct net_device *dev,char __user *useraddr) { -struct ethtool_wolinfo wol = {ETHTOOL_GWOL }; +struct ethtool_wolinfo wol = { .cmd =ETHTOOL_GWOL };if (!dev->ethtool_ops->get_wol)return -EOPNOTSUPP ;
@@ -458,7 +458,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)static int ethtool_get_coalesce (struct net_device *dev,void __user *useraddr) { -struct ethtool_coalesce coalesce = {ETHTOOL_GCOALESCE }; +struct ethtool_coalesce coalesce = { .cmd =ETHTOOL_GCOALESCE };if (!dev->ethtool_ops->get_coalesce)return -EOPNOTSUPP ;
@@ -485,7 +485,7 @@ static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)static int ethtool_get_ringparam (struct net_device *dev,void __user *useraddr) { -struct ethtool_ringparam ringparam = {ETHTOOL_GRINGPARAM }; +struct ethtool_ringparam ringparam = { .cmd =ETHTOOL_GRINGPARAM };if (!dev->ethtool_ops->get_ringparam)return -EOPNOTSUPP ;
@@ -839,7 +839,7 @@ static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)static int ethtool_get_value (struct net_device *dev,char __user *useraddr,u32 cmd,u32 (*actor)(struct net_device *)) { -struct ethtool_value edata = { cmd }; +struct ethtool_value edata = { .cmd = cmd };if (!actor)return -EOPNOTSUPP ;
Signature · 3 lines
Roland Dreier <[email protected]> For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/index.html
From: Roland Dreier <[email protected]>
Date: Thu, 11 Feb 2010 12:12:06 -0800
Quoted 6 lines
Initialize the .cmd member of various ethtool using a designated struct initializer rather. This makes things a teeny bit more robust, although the chance of a struct layout changing is extremely remote, and also makes the code a little easier to read.
Signed-off-by Roland Dreier <[email protected]>
Applied to net-next-2.6, thanks Roland.