[ovs-dev] [PATCH] ofp-util: Remove unneeded default case from ofputil_decode_group_mod().

Simon Horman simon.horman at netronome.com
Wed Dec 2 05:11:16 UTC 2015


On Tue, Dec 01, 2015 at 07:50:43PM -0800, Ben Pfaff wrote:
> On Wed, Dec 02, 2015 at 10:27:53AM +0900, Simon Horman wrote:
> > On Tue, Dec 01, 2015 at 10:39:04AM -0800, Ben Pfaff wrote:
> > > Code earlier in this function validated that gm->type is valid, so there's
> > > no need for a default case at the end of the function.  Keeping the default
> > > case as an abort could potentially introduce a bug later, if the code
> > > happened to be blindly cut-and-pasted somewhere else.
> > > 
> > > CC: Flavio Leitner <fbl at sysclose.org>
> > > Signed-off-by: Ben Pfaff <blp at ovn.org>
> > > ---
> > >  lib/ofp-util.c | 2 --
> > >  1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> > > index 2141144..5a0d31d 100644
> > > --- a/lib/ofp-util.c
> > > +++ b/lib/ofp-util.c
> > > @@ -8879,8 +8879,6 @@ ofputil_decode_group_mod(const struct ofp_header *oh,
> > >                  return OFPERR_OFPGMFC_INVALID_GROUP;
> > >              }
> > >              break;
> > > -        default:
> > > -            OVS_NOT_REACHED();
> > >          }
> > >      }
> > 
> > My concern is that if it is cut-and pasted without the earlier code
> > that verifies gm->type then there may be an case which isn't handled.
> > Could we add a comment? In that case I would be comfortable
> > with deleting the code though personally I lean towards leaving it.
> > 
> 
> I think I'm just going to drop this.  One can't defend against all
> coding errors.

I don't feel as strongly about this as my previous email may have implied
so feel free to drop it if you think that is reasonable.



More information about the dev mailing list