Patchwork ethtool: Use explicit designated initializers for .cmd

login
register
mail settings
Submitter Roland Dreier
Date Feb. 11, 2010, 8:12 p.m.
Message ID <adatytn7crt.fsf@roland-alpha.cisco.com>
Download mbox | patch
Permalink /patch/45153/
State Accepted
Delegated to: David Miller
Headers show

Comments

Roland Dreier - Feb. 11, 2010, 8:12 p.m.
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 <rolandd@cisco.com>
---
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(-)
David Miller - Feb. 11, 2010, 8:14 p.m.
From: Roland Dreier <rdreier@cisco.com>
Date: Thu, 11 Feb 2010 12:12:06 -0800

> 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 <rolandd@cisco.com>

Applied to net-next-2.6, thanks Roland.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d8aee58..f1d5c6d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -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;