Skip to contentSkip to conversation

bonding: bond_get_size() returns wrong size

PATCH Applied Dan Carpenter 7 participants 7 messages Nov 1, 2013 – Nov 2, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: bond_get_size() returns wrong size

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')
drivers/net/bonding/bond_netlink.c +2 -2
index 7661261..40e7b1c 100644
@@ -82,8 +82,8 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
 
 static size_t bond_get_size(const struct net_device *bond_dev)
 {
-	return nla_total_size(sizeof(u8));	/* IFLA_BOND_MODE */
-		+ nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
+	return nla_total_size(sizeof(u8)) +	/* IFLA_BOND_MODE */
+		nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
 }
 
 static int bond_fill_info(struct sk_buff *skb,
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')

Hrm, how does it even build. Good catch, thanks.

Quoted 16 lines
drivers/net/bonding/bond_netlink.c +2 -2
index 7661261..40e7b1c 100644
@@ -82,8 +82,8 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
 
 static size_t bond_get_size(const struct net_device *bond_dev)
 {
-	return nla_total_size(sizeof(u8));	/* IFLA_BOND_MODE */
-		+ nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
+	return nla_total_size(sizeof(u8)) +	/* IFLA_BOND_MODE */
+		nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
 }
 
 static int bond_fill_info(struct sk_buff *skb,
#2 lore raw
Quoted 10 lines · Veaceslav Falico
Quoted 5 lines · Dan Carpenter

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')

Hrm, how does it even build. Good catch, thanks.

Yep, an alternative is to use following format :

static inline size_t br_port_info_size(void)
{

        return nla_total_size(1)        /* IFLA_BRPORT_STATE  */
                + nla_total_size(2)     /* IFLA_BRPORT_PRIORITY */
                + nla_total_size(4)     /* IFLA_BRPORT_COST */
                + nla_total_size(1)     /* IFLA_BRPORT_MODE */
                + nla_total_size(1)     /* IFLA_BRPORT_GUARD */
                + nla_total_size(1)     /* IFLA_BRPORT_PROTECT */
                + nla_total_size(1)     /* IFLA_BRPORT_FAST_LEAVE */
                + nla_total_size(1)     /* IFLA_BRPORT_LEARNING */
                + nla_total_size(1)     /* IFLA_BRPORT_UNICAST_FLOOD */

+ 0;
}

So that a patch adding a new attribute doesn't have to change the 'last line'

Reviewed-by
#3 lore raw
In reply to Veaceslav Falico
Quoted 8 lines · Fri, Nov 01, 2013 at 11:41:00AM CET, [email protected] wrote:
Quoted 5 lines · Dan Carpenter

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')

Hrm, how does it even build. Good catch, thanks.

I wonder about the same thing.

Quoted 19 lines
Quoted 16 lines
drivers/net/bonding/bond_netlink.c +2 -2
index 7661261..40e7b1c 100644
@@ -82,8 +82,8 @@ static int bond_newlink(struct net *src_net, struct net_device *bond_dev,
 
 static size_t bond_get_size(const struct net_device *bond_dev)
 {
-	return nla_total_size(sizeof(u8));	/* IFLA_BOND_MODE */
-		+ nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
+	return nla_total_size(sizeof(u8)) +	/* IFLA_BOND_MODE */
+		nla_total_size(sizeof(u32));	/* IFLA_BOND_ACTIVE_SLAVE */
 }
 
 static int bond_fill_info(struct sk_buff *skb,
#4 lore raw
Quoted 5 lines · Jiri Pirko
Quoted 4 lines · Fri, Nov 01, 2013 at 11:41:00AM CET, [email protected] wrote:
Quoted 3 lines · Dan Carpenter

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')

Hrm, how does it even build. Good catch, thanks.

I wonder about the same thing.

+ and - can be unary operators so it's a valid expression :-) Nice catch

Nik

#5 lore raw

Am 01.11.2013 13:25, schrieb Nikolay Aleksandrov:

Quoted 9 lines · Jiri Pirko
Quoted 8 lines
Quoted 7 lines · Fri, Nov 01, 2013 at 11:41:00AM CET, [email protected] wrote:
Quoted 5 lines · Dan Carpenter

There is an extra semi-colon so bond_get_size() doesn't return the correct value.

Fixes ec76aa49855f ('bonding: add Netlink support active_slave option')
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Hrm, how does it even build. Good catch, thanks.

I wonder about the same thing.

+ and - can be unary operators so it's a valid expression :-) Nice catch

NTL my gcc warns (-Wall)
warning: statement with no effect

this should come up.

re,
wh

Quoted 7 lines

Nik

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html