From b7cc13de4cfd975f6c3051a910314cafd03d8ecd Mon Sep 17 00:00:00 2001 From: krw Date: Mon, 19 Jun 2023 13:45:19 +0000 Subject: [PATCH] Replace eclectic mix of errx(4, "out of memory"), err(4, NULL) and err(1, NULL) with consistent err(1, NULL) when responding to out of memory conditions. --- sbin/disklabel/disklabel.c | 8 ++++---- sbin/disklabel/editor.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index de1f28030f4..031e9197593 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -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++) { diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index 54985b2ad31..183f7e6de1a 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -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 @@ -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); -- 2.20.1