On Thu, May 03, 2018 at 09:37:50AM +0200, Otto Moerbeek wrote:
> On Thu, May 03, 2018 at 02:49:03PM +0800, Nan Xiao wrote:
>
> > Hi tech@,
> >
> > A patch for usr.bin/systat/vmstat.c, apologize if I'm wrong.
> >
> > Index: vmstat.c
> > ===================================================================
> > RCS file: /cvs/src/usr.bin/systat/vmstat.c,v
> > retrieving revision 1.82
> > diff -u -p -r1.82 vmstat.c
> > --- vmstat.c 18 Dec 2016 23:36:32 -0000 1.82
> > +++ vmstat.c 3 May 2018 06:19:35 -0000
> > @@ -180,6 +180,8 @@ initvmstat(void)
> >
> > intrloc = calloc(nintr, sizeof(long));
> > intrname = calloc(nintr, sizeof(char *));
> > + if (intrloc == NULL || intrname == NULL)
> > + errx(2, "out of memory");
>
> errno is set, so use err(1, NULL).
Like this also fix another occurance and use 2 as exit code.
-Otto
Index: vmstat.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.82
diff -u -p -r1.82 vmstat.c
--- vmstat.c 18 Dec 2016 23:36:32 -0000 1.82
+++ vmstat.c 3 May 2018 07:39:52 -0000
@@ -180,6 +180,8 @@ initvmstat(void)
intrloc = calloc(nintr, sizeof(long));
intrname = calloc(nintr, sizeof(char *));
+ if (intrloc == NULL || intrname == NULL)
+ err(2, NULL);
for (i = 0; i < nintr; i++) {
char name[128];
@@ -634,7 +636,7 @@ allocinfo(struct Info *si)
memset(si, 0, sizeof(*si));
si->intrcnt = calloc(nintr, sizeof(*si->intrcnt));
if (si->intrcnt == NULL)
- errx(2, "out of memory");
+ err(2, NULL);
}
static void