public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
To: "Pekka Enberg" <penberg@cs.helsinki.fi>
Cc: tzanussi@gmail.com, akpm@linux-foundation.org,
	torvalds@linux-foundation.org, compudj@krystal.dyndns.org,
	vegard.nossum@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] relay: Add buffer-only channels; useful for early logging.
Date: Sun, 22 Jun 2008 23:51:22 +0300	[thread overview]
Message-ID: <20080622235122.0dc0f724@linux360.ro> (raw)
In-Reply-To: <84144f020806221229r683b07d9i3297c396a29e69f1@mail.gmail.com>

On Sun, 22 Jun 2008 22:29:53 +0300
"Pekka Enberg" <penberg@cs.helsinki.fi> wrote:

> On Sat, Jun 21, 2008 at 5:11 PM, Eduard - Gabriel Munteanu
> <eduard.munteanu@linux360.ro> wrote:
> > +       tmpname = kzalloc(NAME_MAX + 1, GFP_KERNEL);
> > +       if (!tmpname)
> > +               goto failed;
> 
> Why don't you return -ENOMEM here?

The original function from which I ripped this thing off
(relay_open_buf()) returned 1 on error, so I assumed I wasn't supposed
to change this behavior.

I should probably do this in a separate patch.

> The separate goto seems pointless. Why don't you use negative return
> values for error handling?

Yes, it's better to use 'return' directly.

> >  /**
> > + *     relay_late_setup_files - triggers file creation
> > + *     @chan: channel to operate on
> > + *     @base_filename: base name of files to create
> > + *     @parent: dentry of parent directory, %NULL for root
> > directory
> > + *
> > + *     Returns 0 if successful, non-zero otherwise.
> > + *
> > + *     Use to setup files for a previously buffer-only channel.
> > + *     Useful to do early tracing in kernel, before VFS is up, for
> > example.
> > + */
> > +int relay_late_setup_files(struct rchan *chan,
> > +                          const char *base_filename,
> > +                          struct dentry *parent)
> > +{
> > +       unsigned int i;
> > +       int err;
> > +       struct rchan_buf *buf;
> > +
> > +       if (!chan || !base_filename)
> > +               return 1;
> 
> -EINVAL?

Will do and resubmit. Being new code (called directly by other kernel
users), it allows me to be a bit inconsistent about return values.

> > +               err = relay_setup_buf_file(chan, buf, i);
> > +               if (unlikely(err))
> > +                       goto out;
> > +       }
> > +       mutex_unlock(&relay_channels_mutex);
> > +
> > +       return 0;
> > +
> > +out:
> > +       mutex_unlock(&relay_channels_mutex);
> > +       return 1;
> 
> You don't need two return statements (and coincidentally two unlocks)
> if you keep the return value in a local variable 'err'.

Thanks, I missed this possibility. Sounds better.
 

	Eduard

  reply	other threads:[~2008-06-22 20:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-21 14:11 [PATCH 3/3] relay: Add buffer-only channels; useful for early logging Eduard - Gabriel Munteanu
2008-06-22 19:24 ` Pekka Enberg
2008-06-22 19:29 ` Pekka Enberg
2008-06-22 20:51   ` Eduard - Gabriel Munteanu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-23 12:31 Eduard - Gabriel Munteanu
2008-07-03  6:06 ` Andrew Morton
2008-07-05  4:14   ` Eduard - Gabriel Munteanu
2008-07-05  6:32     ` Andrew Morton
2008-08-06 17:32 ` Mathieu Desnoyers
2008-06-15 15:05 Eduard - Gabriel Munteanu
2008-06-17 14:35 ` Mathieu Desnoyers
2008-06-13  1:10 Eduard - Gabriel Munteanu
2008-06-13  7:04 ` Pekka Enberg
2008-06-13 15:54   ` Eduard - Gabriel Munteanu
2008-06-16 12:30     ` Mathieu Desnoyers
2008-06-16 13:37       ` Eduard - Gabriel Munteanu
2008-06-17 13:53         ` Mathieu Desnoyers
2008-06-14 16:10   ` Eduard - Gabriel Munteanu
2008-06-16 12:35 ` Mathieu Desnoyers
2008-06-16 13:30   ` Eduard - Gabriel Munteanu
2008-06-12 20:26 Eduard - Gabriel Munteanu

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=20080622235122.0dc0f724@linux360.ro \
    --to=eduard.munteanu@linux360.ro \
    --cc=akpm@linux-foundation.org \
    --cc=compudj@krystal.dyndns.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@linux-foundation.org \
    --cc=tzanussi@gmail.com \
    --cc=vegard.nossum@gmail.com \
    /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