bonding: cleanup bond_opts array
authorJonathan Toppins <jtoppins@cumulusnetworks.com>
Fri, 9 Jan 2015 18:31:08 +0000 (13:31 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Jan 2015 21:39:31 +0000 (16:39 -0500)
commit7bfa014500ceffa8b787ffc3a6e00252443631d0
tree2a2efbd3890f8b9a1bc96ccc5ee67bb8db5b4ba1
parentd9fbfb94d07ff8feb1741c31a1dd80d4850b44cb
bonding: cleanup bond_opts array

Remove the empty array element initializer and size the array with
BOND_OPT_LAST so the compiler will complain if more elements are in
there than should be.

An interesting unwanted side effect of this initializer is that if one
inserts new options into the middle of the array then this initializer
will zero out the option that equals BOND_OPT_TLB_DYNAMIC_LB+1.

Example:
Extend the OPTS enum:
enum {
   ...
   BOND_OPT_TLB_DYNAMIC_LB,
   BOND_OPT_LACP_NEW1,
   BOND_OPT_LAST
};

Now insert into bond_opts array:
static const struct bond_option bond_opts[] = {
      ...
      [BOND_OPT_LACP_RATE] = { .... unchanged stuff .... },
      [BOND_OPT_LACP_NEW1] = { ... new stuff ... },
      ...
      [BOND_OPT_TLB_DYNAMIC_LB] = { .... unchanged stuff ....},
      { } // MARK A
};

Since BOND_OPT_LACP_NEW1 = BOND_OPT_TLB_DYNAMIC_LB+1, the last
initializer (MARK A) will overwrite the contents of BOND_OPT_LACP_NEW1
and can be easily viewed with the crash utility.

Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
Cc: Andy Gospodarek <gospo@cumulusnetworks.com>
Cc: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com>
Acked-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_options.c