Replace eclectic mix of errx(4, "out of memory"), err(4, NULL)
authorkrw <krw@openbsd.org>
Mon, 19 Jun 2023 13:45:19 +0000 (13:45 +0000)
committerkrw <krw@openbsd.org>
Mon, 19 Jun 2023 13:45:19 +0000 (13:45 +0000)
and err(1, NULL) with consistent err(1, NULL) when responding to
out of memory conditions.

sbin/disklabel/disklabel.c
sbin/disklabel/editor.c

index de1f280..031e919 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: disklabel.c,v 1.249 2023/05/13 18:13:42 krw Exp $     */
+/*     $OpenBSD: disklabel.c,v 1.250 2023/06/19 13:45:19 krw Exp $     */
 
 /*
  * Copyright (c) 1987, 1993
@@ -367,13 +367,13 @@ parsefstab(void)
 
        i = asprintf(&partname, "/dev/%s%c", dkname, 'a');
        if (i == -1)
-               err(4, NULL);
+               err(1, NULL);
        i = asprintf(&partduid,
            "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx.a",
            lab.d_uid[0], lab.d_uid[1], lab.d_uid[2], lab.d_uid[3],
            lab.d_uid[4], lab.d_uid[5], lab.d_uid[6], lab.d_uid[7]);
        if (i == -1)
-               err(4, NULL);
+               err(1, NULL);
        setfsent();
        for (i = 0; i < MAXPARTITIONS; i++) {
                partname[strlen(dkname) + 5] = 'a' + i;
@@ -812,7 +812,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
        lp->d_version = 1;
 
        if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))))
-               errx(4, "out of memory");
+               err(1, NULL);
 
        mpcopy(omountpoints, mountpoints);
        for (part = 0; part < MAXPARTITIONS; part++) {
index 54985b2..183f7e6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: editor.c,v 1.409 2023/06/18 20:41:52 krw Exp $        */
+/*     $OpenBSD: editor.c,v 1.410 2023/06/19 13:45:19 krw Exp $        */
 
 /*
  * Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org>
@@ -198,7 +198,7 @@ editor(int f)
        if (!(omountpoints = calloc(MAXPARTITIONS, sizeof(char *))) ||
            !(origmountpoints = calloc(MAXPARTITIONS, sizeof(char *))) ||
            !(tmpmountpoints = calloc(MAXPARTITIONS, sizeof(char *))))
-               errx(4, "out of memory");
+               err(1, NULL);
 
        /* How big is the OpenBSD portion of the disk?  */
        find_bounds(&newlab);
@@ -567,7 +567,7 @@ again:
                goto again;
        alloc = reallocarray(NULL, lastalloc, sizeof(struct space_allocation));
        if (alloc == NULL)
-               errx(4, "out of memory");
+               err(1, NULL);
        memcpy(alloc, alloc_table[index].table,
            lastalloc * sizeof(struct space_allocation));
 
@@ -675,7 +675,7 @@ again:
                        }
                        free(*partmp);
                        if ((*partmp = strdup(ap->mp)) == NULL)
-                               errx(4, "out of memory");
+                               err(1, NULL);
                }
        }
 
@@ -1455,7 +1455,7 @@ mpcopy(char **to, char **from)
                if (from[i] != NULL) {
                        to[i] = strdup(from[i]);
                        if (to[i] == NULL)
-                               errx(4, "out of memory");
+                               err(1, NULL);
                }
        }
 }
@@ -1753,7 +1753,7 @@ get_mp(const struct disklabel *lp, int partno)
                        /* XXX - might as well realloc */
                        free(mountpoints[partno]);
                        if ((mountpoints[partno] = strdup(p)) == NULL)
-                               errx(4, "out of memory");
+                               err(1, NULL);
                        break;
                }
                fputs("Mount points must start with '/'\n", stderr);