2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Use EXIT_SUCCESS and EXIT_FAILURE

Instead of randomly using -1 or 1 as a failure status, properly utilize
the EXIT_FAILURE define that's platform specific (as it should be).
This commit is contained in:
Ondřej Surý
2024-02-07 14:50:38 +01:00
parent e140743e6a
commit 76997983fd
41 changed files with 153 additions and 150 deletions

View File

@@ -218,7 +218,7 @@ next_file(isc_dir_t *dir) {
fprintf(stderr,
"Error: reading directory: %s\n",
strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
}
}
@@ -366,14 +366,14 @@ insert_into_typenames(int type, const char *typebuf, const char *attr) {
fprintf(stderr,
"Error: type %d has two names: %s, %s\n", type,
typenames[i].typebuf, typebuf);
exit(1);
exit(EXIT_FAILURE);
}
ttn = &typenames[i];
}
/* Subtract one to leave an empty sentinel entry at the end */
if (i >= TYPENAMES - 1) {
fprintf(stderr, "Error: typenames array too small\n");
exit(1);
exit(EXIT_FAILURE);
} else if (ttn == NULL) {
ttn = &typenames[i];
ttnam_count = i + 1;
@@ -382,7 +382,7 @@ insert_into_typenames(int type, const char *typebuf, const char *attr) {
/* XXXMUKS: This is redundant due to the INSIST above. */
if (strlen(typebuf) > sizeof(ttn->typebuf) - 1) {
fprintf(stderr, "Error: type name %s is too long\n", typebuf);
exit(1);
exit(EXIT_FAILURE);
}
strncpy(ttn->typebuf, typebuf, sizeof(ttn->typebuf));
@@ -412,13 +412,13 @@ insert_into_typenames(int type, const char *typebuf, const char *attr) {
"Error: type %d has different attributes: "
"%s, %s\n",
type, ttn->attr, attr);
exit(1);
exit(EXIT_FAILURE);
}
if (strlen(attr) > sizeof(ttn->attr) - 1) {
fprintf(stderr, "Error: attr (%s) [name %s] is too long\n",
attr, typebuf);
exit(1);
exit(EXIT_FAILURE);
}
strncpy(ttn->attr, attr, sizeof(ttn->attr));
@@ -444,7 +444,7 @@ add(unsigned int rdclass, const char *classbuf, int type, const char *typebuf,
if (newtt == NULL) {
fprintf(stderr, "malloc() failed\n");
exit(1);
exit(EXIT_FAILURE);
}
newtt->next = NULL;
@@ -496,7 +496,7 @@ add(unsigned int rdclass, const char *classbuf, int type, const char *typebuf,
newcc = (struct cc *)malloc(sizeof(*newcc));
if (newcc == NULL) {
fprintf(stderr, "malloc() failed\n");
exit(1);
exit(EXIT_FAILURE);
}
newcc->rdclass = rdclass;
strncpy(newcc->classbuf, classbuf, sizeof(newcc->classbuf));
@@ -554,7 +554,7 @@ sd(unsigned int rdclass, const char *classbuf, const char *dirbuf,
if (type > 65535) {
fprintf(stderr, "Error: type value > 65535 (%s)\n",
dir.filename);
exit(1);
exit(EXIT_FAILURE);
}
add(rdclass, classbuf, type, typebuf, dirbuf);
}
@@ -638,7 +638,7 @@ main(int argc, char **argv) {
sizeof("/rdata/_65535_65535"))
{
fprintf(stderr, "\"%s\" too long\n", optarg);
exit(1);
exit(EXIT_FAILURE);
}
n = snprintf(srcdir, sizeof(srcdir), "%s/", optarg);
INSIST(n > 0 && (unsigned int)n < sizeof(srcdir));
@@ -653,7 +653,7 @@ main(int argc, char **argv) {
suffix = optarg;
break;
case '?':
exit(1);
exit(EXIT_FAILURE);
}
}
@@ -682,7 +682,7 @@ main(int argc, char **argv) {
if (rdclass > 65535) {
fprintf(stderr, "Error: class value > 65535 (%s)\n",
dir.filename);
exit(1);
exit(EXIT_FAILURE);
}
sd(rdclass, classbuf, buf, filetype);
}
@@ -1023,7 +1023,7 @@ main(int argc, char **argv) {
}
if (ferror(stdout) != 0) {
exit(1);
exit(EXIT_FAILURE);
}
return (0);