All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@gnu.org>
To: "Voelker, Bernhard" <bernhard.voelker@siemens-enterprise.com>
Cc: Karel Zak <kzak@redhat.com>, util-linux <util-linux@vger.kernel.org>
Subject: RE: [PATCH v3 3/4] lslocks: new command
Date: Mon, 27 Feb 2012 18:19:55 +0100	[thread overview]
Message-ID: <1330363195.2540.6.camel@offbook> (raw)
In-Reply-To: <7856072A9D04C24B82DFE2B1112FE38A0F0AFAD64D@MCHP058A.global-ad.net>

On Mon, 2012-02-27 at 18:16 +0100, Voelker, Bernhard wrote:
> Davidlohr Bueso wrote:
> 
> 
> > +static char *get_cmdname(pid_t pid)
> > +{
> > +	FILE *fp;
> > +	char path[PATH_MAX];
> > +
> > +	sprintf(path, "/proc/%d/comm", pid);
> > +	if (!(fp = fopen(path, "r")))
> > +		return NULL;
> > +
> > +	/* just need the first line */
> > +	if (!fgets(path, sizeof(path), fp))
> > +		goto out;
> > +out:
> 
> this looks strange to me:
> if fgets fails, then we want to ...
> 
> > +	fclose(fp);
> 
> ... but certainly not this:

yep, that's bogus. Will send a v4.

Thanks.

> 
> > +	path[strlen(path) - 1] = '\0';
> > +	return xstrdup(path);
> > +}
> 
> Have a nice day,
> Berny
> 



  reply	other threads:[~2012-02-27 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 15:41 [PATCH v3 3/4] lslocks: new command Davidlohr Bueso
2012-02-27 17:16 ` Voelker, Bernhard
2012-02-27 17:19   ` Davidlohr Bueso [this message]
2012-02-27 17:29   ` Davidlohr Bueso
2012-02-29 13:36     ` Karel Zak

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=1330363195.2540.6.camel@offbook \
    --to=dave@gnu.org \
    --cc=bernhard.voelker@siemens-enterprise.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.