public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: scameron@beardog.cce.hp.com
To: Dan Merillat <dan.merillat@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>, Andy Whitcroft <apw@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Roel Kluin <roel.kluin@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	rostedt@goodmis.org, Mike Miller <mike.miller@hp.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	iss_storagedev@hp.com
Subject: Re: [PATCH] ftrace: return error instead of 12 bytes read
Date: Wed, 18 Nov 2009 11:15:38 -0600	[thread overview]
Message-ID: <20091118171538.GK3273@beardog.cce.hp.com> (raw)
In-Reply-To: <c0c067900911180218h466bec13m5f8ec8713617b11a@mail.gmail.com>

On Wed, Nov 18, 2009 at 05:18:53AM -0500, Dan Merillat wrote:
> On Thu, Nov 12, 2009 at 8:45 AM, Ingo Molnar <mingo@elte.hu> wrote:
> 
> > Even in filesystems, ~80% of the cases use proper negative values:
> >
> >  $ git grep 'return -E' fs/ | wc -l
> >  4540
> >  $ git grep 'return E' fs/ | wc -l
> >  895
> 
> Except....
> fs/9p/fid.c:                            return ERR_PTR(-EPERM);
> 
> try this:
> 
> $ git grep "return E[A-Z]*;" | grep -v EOF | grep -v ERROR | wc -l
> 138
> $ git grep "return -E[A-Z]*;"| wc -l
> 57285
> 
> 2 of those are in Documentation/ and 2 are comments from a quick
> glance.   134 uses of positive error returns, _74_ of which are in
> fs/xfs, 24 in bluetooth, and the rest scattered randomly around the
> kernel.
> 
> 134 positive error returns  vs 57881 negative?  The style is so
> strongly ingrained in the kernel (And I'd bet an audit of those
> remaning 134 would find at least one bug) that it'd be a good janitor
> task to go through and switch them.
> 
> 
> This is one example - a function that returns either ENXIO or 0, and
> the lone caller explicitly tests and flips the sign.
> 
> (Not signing off on this!!!!  but CCing the relevant people for this driver)
> 
> diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
> index 6399e50..79867d6 100644
> --- a/drivers/block/cciss.c
> +++ b/drivers/block/cciss.c
> @@ -428,7 +428,7 @@ cciss_proc_write(struct file *file, const char __user *buf,
> 
>                 rc = cciss_engage_scsi(h->ctlr);
>                 if (rc != 0)
> -                       err = -rc;
> +                       err = rc;
>                 else
>                         err = length;
>         } else
> diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
> index 3315268..4af3085 100644
> --- a/drivers/block/cciss_scsi.c
> +++ b/drivers/block/cciss_scsi.c
> @@ -1547,7 +1547,7 @@ cciss_engage_scsi(int ctlr)
>         if (sa->registered) {
>                 printk("cciss%d: SCSI subsystem already engaged.\n", ctlr);
>                 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
> -               return ENXIO;
> +               return -ENXIO;
>         }
>         sa->registered = 1;
>         spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);

I sent a patch to fix this already.

http://groups.google.com/group/linux.kernel/browse_thread/thread/40b43d35dff0f30a/0a073fc8014547e0?hl=en&lnk=gst&q=cciss+weird#0a073fc8014547e0

-- steve

  reply	other threads:[~2009-11-18 17:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 21:26 [PATCH] ftrace: return error instead of 12 bytes read Roel Kluin
2009-11-11 21:47 ` Andrew Morton
2009-11-11 21:58   ` Steven Rostedt
     [not found]   ` <20091112081043.GA25345@elte.hu>
2009-11-12  9:47     ` [patch] Fix: 'return -ENOMEM' instead of 'return ENOMEM' Alexey Dobriyan
2009-11-12 13:31   ` [PATCH] ftrace: return error instead of 12 bytes read Andy Whitcroft
2009-11-12 13:45     ` Ingo Molnar
2009-11-12 14:10       ` Andy Whitcroft
2009-11-18 10:18       ` Dan Merillat
2009-11-18 17:15         ` scameron [this message]
2009-11-11 21:57 ` Steven Rostedt
2009-11-12  2:33 ` [PATCH][GIT PULL][v2.6.32] tracing: Fix return value of tracing_stats_read() Steven Rostedt
2009-11-12  7:50   ` Ingo Molnar
2009-11-12  8:21 ` [tip:tracing/urgent] " tip-bot for Roel Kluin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091118171538.GK3273@beardog.cce.hp.com \
    --to=scameron@beardog.cce.hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=dan.merillat@gmail.com \
    --cc=iss_storagedev@hp.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.miller@hp.com \
    --cc=mingo@elte.hu \
    --cc=roel.kluin@gmail.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox