[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] procfs: another fix for the process file name in stat/status
From: |
Pino Toscano |
Subject: |
Re: [PATCH] procfs: another fix for the process file name in stat/status |
Date: |
Mon, 10 Sep 2012 18:16:44 +0200 |
User-agent: |
KMail/1.13.7 (Linux/3.2.0-3-amd64; KDE/4.8.4; x86_64; ; ) |
Alle lunedì 10 settembre 2012, Samuel Thibault ha scritto:
> Pino Toscano, le Mon 10 Sep 2012 17:31:32 +0200, a écrit :
> > Alle domenica 9 settembre 2012, Samuel Thibault ha scritto:
> > > Pino Toscano, le Fri 07 Sep 2012 20:02:56 +0200, a écrit :
> > > > +static int args_filename_length (const char *name)
> > > > +{
> > > > + const char *p = name;
> > > > + while (*p != '\0' && *p != ' ')
> > > > + ++p;
> > >
> > > Why not using index(name, ' ') here?
> >
> > If I would use strchr, the code would be something like:
> > const char *p = strchr (name, ' ');
> > return p != NULL ? p - name : strlen (name);
> >
> > which, for the common case, would mean scanning the string twice.
>
> Ah, right. You can use strchrnul instead.
Indeed -- I didn't know it, thanks for the hint.
Updated patch attached.
--
Pino Toscano
0001-PID-stat-status-show-only-the-first-word.patch
Description: Text Data
signature.asc
Description: This is a digitally signed message part.