lkml.org 
[lkml]   [2013]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: silicom: fix 'return is not a function, parentheses are not required' in bpctl_mod.c
On Thu, Dec 05, 2013 at 03:09:15PM -0800, Joe Perches wrote:
> On Fri, 2013-12-06 at 01:50 +0300, Dan Carpenter wrote:
> > On Thu, Dec 05, 2013 at 10:23:53PM +0100, Will Tange wrote:
> > > Fixes warnings regarding redundant parantheses thrown by the checkpatch tool in bpctl_mod.c
> []
> > if (ret < 0)
> > return BP_NOT_CAP;
> > if (ret == 0)
> > return 1;
> > return 0;
> >
> > More lines, but simpler to understand than the original.
> >
> > Think of checkpatch.pl as a pointer to bad code and not that we just
> > have to silence checkpatch and move on.
>
> So true.
>
> If 0 is the expected ret value and 1 is the
> expected function return for not-errored use,
> I suggest changing the last bit to:
>
> if (ret < 0)
> return BP_NOT_CAP;
> else if (ret > 0)
> return 0;
>
> return 1;
>
> so that the error conditions are done first
> and the normal return is at the bottom of
> the function.

In this function, -1 means fail, 1 means "on" and 0 means "off". I
sorted them from lowest to highest: negative, zero and greater than
zero.

regards,
dan carpenter


\
 
 \ /
  Last update: 2013-12-06 00:41    [W:0.065 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site