Re: [PATCH 2/2] cyclictest: simplify rstat_setup
John Kacur <[email protected]>
| Newsgroups | org.kernel.vger.linux-rt-users |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 10 Mar 2026, Crystal Wood wrote:
> On Mon, 2026-03-09 at 18:55 -0400, John Kacur wrote:
> >
> > On Sun, 1 Mar 2026, Lukas Beckmann wrote:
> > > +static void rstat_setup(void)
> > > +{
> > > + int fd;
> > > + pid_t pid;
> > >
> > > - if (mptr == (void*)-1)
> > > - fprintf(stderr, "ERROR: mmap, %s\n", strerror(errno));
> > > + pid = getpid();
> > >
> > > - return mptr;
> > > -}
> > > + snprintf(shm_name, SHM_BUF_SIZE, "%s%d", "/cyclictest", pid);
> > >
> > > -static int rstat_mlock(void *mptr)
> > > -{
> > > - int err;
> >
> > errno = 0 before the call to shm_unlink for good defensive programming
> > other than that the patch looks good, I will do a little more testing
>
> Defensive against the library returning -1 without setting errno? Seems
> a bit paranoid and cluttery... all for the payoff of an "ERROR:
> shm_unlink Success" message if it ever does happen *and* the old errno
> happened to be ENOENT.
>
> And the current code uses it even in places that print the message
> regardless.
>
> -Crystal
>
>
Isn't that what defensive programming is? Guarding against something that
is unlikely? It's one line of code that I requested in a patch that gets
rid of many lines of code, is that really worth arguing over?
John Kacur