portability: Solaris 10 does not have err.h

Use error(3) function, that has gnulib portability fixes, instead of err(3)
and warn(3) family.

Reported-by: Anton Tkachev <antont@bk.ru>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2015-10-26 22:12:37 +00:00
parent fae20302cf
commit 535dfc4fc2
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
10 changed files with 84 additions and 72 deletions

1
THANKS
View file

@ -35,3 +35,4 @@ Wolfgang Steudel
Aaron Paetznick Aaron Paetznick
Tim Cantin Tim Cantin
Martijn van Brummelen Martijn van Brummelen
Anton Tkachev

View file

@ -20,6 +20,7 @@
gnulib_modules=" gnulib_modules="
close-stream close-stream
closeout closeout
error
fclose fclose
fcntl-h fcntl-h
fdopen fdopen

View file

@ -1,3 +1,4 @@
/ar-lib
/compile /compile
/config.guess /config.guess
/config.sub /config.sub

1
lib/.gitignore vendored
View file

@ -7,6 +7,7 @@
/Makefile.am /Makefile.am
/Makefile.in /Makefile.in
/_Exit.c /_Exit.c
/alloca.h
/alloca.in.h /alloca.in.h
/arg-nonnull.h /arg-nonnull.h
/arpa/ /arpa/

View file

@ -38,10 +38,9 @@
*/ */
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <err.h>
#include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
@ -49,11 +48,13 @@
#include "close-stream.h" #include "close-stream.h"
#include "closeout.h" #include "closeout.h"
#include "defaults.h" #include "error.h"
#include "dhcpd-pools.h"
#include "progname.h" #include "progname.h"
#include "xalloc.h" #include "xalloc.h"
#include "dhcpd-pools.h"
#include "defaults.h"
/* Global variables */ /* Global variables */
int prefix_length[2][NUM_OF_PREFIX]; int prefix_length[2][NUM_OF_PREFIX];
struct configuration_t config; struct configuration_t config;
@ -165,7 +166,7 @@ int main(int argc, char **argv)
/* Output sorting option */ /* Output sorting option */
sorts = strlen(optarg); sorts = strlen(optarg);
if (5 < sorts) { if (5 < sorts) {
warnx("main: only first 5 sort orders will be used"); error(0, 0, "main: only first 5 sort orders will be used");
strncpy(config.sort, optarg, (size_t)5); strncpy(config.sort, optarg, (size_t)5);
sorts = 5; sorts = 5;
} else } else
@ -188,8 +189,8 @@ int main(int argc, char **argv)
config.output_limit[i] = optarg[i] - '0'; config.output_limit[i] = optarg[i] - '0';
else { else {
clean_up(); clean_up();
errx(EXIT_FAILURE, error(EXIT_FAILURE, 0,
"main: output mask `%s' is illegal", optarg); "main: output mask `%s' is illegal", optarg);
} }
} }
break; break;
@ -211,7 +212,8 @@ int main(int argc, char **argv)
/* Print help */ /* Print help */
usage(EXIT_SUCCESS); usage(EXIT_SUCCESS);
default: default:
errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); error(EXIT_FAILURE, 0, "Try `%s --help' for more information.",
program_name);
} }
} }
/* Output function selection */ /* Output function selection */
@ -246,7 +248,7 @@ int main(int argc, char **argv)
break; break;
default: default:
clean_up(); clean_up();
errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); error(EXIT_FAILURE, 0, "main: unknown output format `%c'", config.output_format[0]);
} }
/* Do the job */ /* Do the job */
prepare_memory(); prepare_memory();

View file

@ -42,7 +42,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -53,10 +52,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "defaults.h" #include "error.h"
#include "dhcpd-pools.h"
#include "xalloc.h" #include "xalloc.h"
#include "dhcpd-pools.h"
#include "defaults.h"
/*! \brief Lease file parser. The parser can only read ISC DHCPD /*! \brief Lease file parser. The parser can only read ISC DHCPD
* dhcpd.leases file format. */ * dhcpd.leases file format. */
int parse_leases(void) int parse_leases(void)
@ -70,15 +71,15 @@ int parse_leases(void)
dhcpd_leases = fopen(config.dhcpdlease_file, "r"); dhcpd_leases = fopen(config.dhcpdlease_file, "r");
if (dhcpd_leases == NULL) if (dhcpd_leases == NULL)
err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
#ifdef HAVE_POSIX_FADVISE #ifdef HAVE_POSIX_FADVISE
# ifdef POSIX_FADV_NOREUSE # ifdef POSIX_FADV_NOREUSE
if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0)
err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file);
# endif /* POSIX_FADV_NOREUSE */ # endif /* POSIX_FADV_NOREUSE */
# ifdef POSIX_FADV_SEQUENTIAL # ifdef POSIX_FADV_SEQUENTIAL
if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0)
err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file);
# endif /* POSIX_FADV_SEQUENTIAL */ # endif /* POSIX_FADV_SEQUENTIAL */
#endif /* HAVE_POSIX_FADVISE */ #endif /* HAVE_POSIX_FADVISE */
/* I found out that there's one lease address per 300 bytes in /* I found out that there's one lease address per 300 bytes in
@ -86,7 +87,7 @@ int parse_leases(void)
* If someone has higher density in lease file I'm interested to * If someone has higher density in lease file I'm interested to
* hear about that. */ * hear about that. */
if (stat(config.dhcpdlease_file, &lease_file_stats)) if (stat(config.dhcpdlease_file, &lease_file_stats))
err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
line = xmalloc(sizeof(char) * MAXLEN); line = xmalloc(sizeof(char) * MAXLEN);
line[0] = '\0'; line[0] = '\0';
ipstring = xmalloc(sizeof(char) * MAXLEN); ipstring = xmalloc(sizeof(char) * MAXLEN);
@ -95,7 +96,7 @@ int parse_leases(void)
ethernets = true; ethernets = true;
while (!feof(dhcpd_leases)) { while (!feof(dhcpd_leases)) {
if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases))
err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file);
switch (xstrstr(line)) { switch (xstrstr(line)) {
/* It's a lease, save IP */ /* It's a lease, save IP */
case PREFIX_LEASE: case PREFIX_LEASE:
@ -186,15 +187,15 @@ void parse_config(int is_include, const char *restrict config_file,
/* Open configuration file */ /* Open configuration file */
dhcpd_config = fopen(config_file, "r"); dhcpd_config = fopen(config_file, "r");
if (dhcpd_config == NULL) if (dhcpd_config == NULL)
err(EXIT_FAILURE, "parse_config: %s", config_file); error(EXIT_FAILURE, errno, "parse_config: %s", config_file);
#ifdef HAVE_POSIX_FADVISE #ifdef HAVE_POSIX_FADVISE
# ifdef POSIX_FADV_NOREUSE # ifdef POSIX_FADV_NOREUSE
if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0)
err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file);
# endif /* POSIX_FADV_NOREUSE */ # endif /* POSIX_FADV_NOREUSE */
# ifdef POSIX_FADV_SEQUENTIAL # ifdef POSIX_FADV_SEQUENTIAL
if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0)
err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file);
# endif /* POSIX_FADV_SEQUENTIAL */ # endif /* POSIX_FADV_SEQUENTIAL */
#endif /* HAVE_POSIX_FADVISE */ #endif /* HAVE_POSIX_FADVISE */
/* Very hairy stuff begins. */ /* Very hairy stuff begins. */
@ -364,8 +365,8 @@ void parse_config(int is_include, const char *restrict config_file,
shared_p->backups = 0; shared_p->backups = 0;
if (SHARED_NETWORKS < num_shared_networks + 2) if (SHARED_NETWORKS < num_shared_networks + 2)
/* FIXME: make this to go away by reallocating more space. */ /* FIXME: make this to go away by reallocating more space. */
errx(EXIT_FAILURE, error(EXIT_FAILURE, 0,
"parse_config: increase default.h SHARED_NETWORKS and recompile"); "parse_config: increase default.h SHARED_NETWORKS and recompile");
argument = ITS_NOTHING_INTERESTING; argument = ITS_NOTHING_INTERESTING;
braces_shared = braces; braces_shared = braces;
break; break;
@ -380,7 +381,7 @@ void parse_config(int is_include, const char *restrict config_file,
argument = ITS_NOTHING_INTERESTING; argument = ITS_NOTHING_INTERESTING;
break; break;
default: default:
warnx("impossible occurred, report a bug"); error(0, 0, "impossible occurred, report a bug");
assert(0); assert(0);
} }
} }

View file

@ -38,9 +38,12 @@
* analysis happen as quick as possible.. * analysis happen as quick as possible..
*/ */
#include "dhcpd-pools.h" #include <config.h>
#include "xalloc.h" #include "xalloc.h"
#include "dhcpd-pools.h"
#define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out) #define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out)
#define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add) #define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add)

View file

@ -39,13 +39,9 @@
#include <config.h> #include <config.h>
#include "dhcpd-pools.h"
#include "defaults.h"
#include "progname.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <limits.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
@ -53,7 +49,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include "error.h"
#include "progname.h"
#include "dhcpd-pools.h"
#include "defaults.h"
/*! \brief Set function pointers depending on IP version. /*! \brief Set function pointers depending on IP version.
* \param ip IP version. * \param ip IP version.
@ -378,9 +379,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg)
goto err; goto err;
return num; return num;
err: err:
if (errno) error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str);
err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
} }
/*! \brief Reverse range. /*! \brief Reverse range.
@ -404,7 +403,7 @@ void clean_up(void)
{ {
/* Just in case there something in buffers */ /* Just in case there something in buffers */
if (fflush(NULL)) if (fflush(NULL))
warn("clean_up: fflush"); error(0, 0, "clean_up: fflush");
free(config.dhcpdconf_file); free(config.dhcpdconf_file);
free(config.dhcpdlease_file); free(config.dhcpdlease_file);
free(config.output_file); free(config.output_file);

View file

@ -40,7 +40,6 @@
#include <config.h> #include <config.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <langinfo.h> #include <langinfo.h>
@ -53,10 +52,12 @@
#include <time.h> #include <time.h>
#include "close-stream.h" #include "close-stream.h"
#include "dhcpd-pools.h" #include "error.h"
#include "progname.h" #include "progname.h"
#include "strftime.h" #include "strftime.h"
#include "dhcpd-pools.h"
/*! \brief Text output format, which is the default. /*! \brief Text output format, which is the default.
* FIXME: This function should return void. */ * FIXME: This function should return void. */
int output_txt(void) int output_txt(void)
@ -72,7 +73,7 @@ int output_txt(void)
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_txt: %s", config.output_file); error(EXIT_FAILURE, errno, "output_txt: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -201,12 +202,12 @@ int output_txt(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_txt: fflush"); error(0, 0, "output_txt: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_txt: fclose"); error(0, 0, "output_txt: fclose");
} }
} }
@ -228,7 +229,7 @@ int output_xml(void)
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_xml: %s", config.output_file); error(EXIT_FAILURE, errno, "output_xml: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -242,6 +243,7 @@ int output_xml(void)
if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { if (config.output_format[0] == 'X' || config.output_format[0] == 'J') {
struct leases_t *l; struct leases_t *l;
for (l = leases; l != NULL; l = l->hh.next) { for (l = leases; l != NULL; l = l->hh.next) {
if (l->type == ACTIVE) { if (l->type == ACTIVE) {
fputs("<active_lease>\n\t<ip>", outfile); fputs("<active_lease>\n\t<ip>", outfile);
@ -305,12 +307,12 @@ int output_xml(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_xml: fflush"); error(0, 0, "output_xml: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_xml: fclose"); error(0, 0, "output_xml: fclose");
} }
} }
@ -333,7 +335,7 @@ int output_json(void)
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_json: %s", config.output_file); error(EXIT_FAILURE, errno, "output_json: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -348,6 +350,7 @@ int output_json(void)
if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { if (config.output_format[0] == 'X' || config.output_format[0] == 'J') {
struct leases_t *l; struct leases_t *l;
fprintf(outfile, " \"active_leases\": ["); fprintf(outfile, " \"active_leases\": [");
for (l = leases; l != NULL; l = l->hh.next) { for (l = leases; l != NULL; l = l->hh.next) {
if (l->type == ACTIVE) { if (l->type == ACTIVE) {
@ -443,12 +446,12 @@ int output_json(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_json: fflush"); error(0, 0, "output_json: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_json: fclose"); error(0, 0, "output_json: fclose");
} }
} }
@ -465,14 +468,15 @@ static void html_header(FILE *restrict f)
struct tm *tmp, result; struct tm *tmp, result;
struct stat statbuf; struct stat statbuf;
stat(config.dhcpdlease_file, &statbuf); stat(config.dhcpdlease_file, &statbuf);
tmp = localtime_r(&statbuf.st_mtime, &result); tmp = localtime_r(&statbuf.st_mtime, &result);
if (tmp == NULL) { if (tmp == NULL) {
err(EXIT_FAILURE, "html_header: localtime"); error(EXIT_FAILURE, errno, "html_header: localtime");
} }
if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) { if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) {
errx(EXIT_FAILURE, "html_header: strftime returned 0"); error(EXIT_FAILURE, 0, "html_header: strftime returned 0");
} }
fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n"); fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
@ -652,10 +656,11 @@ int output_html(void)
struct shared_network_t *shared_p; struct shared_network_t *shared_p;
int ret; int ret;
FILE *outfile; FILE *outfile;
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_html: %s", config.output_file); error(EXIT_FAILURE, errno, "output_html: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -754,9 +759,8 @@ int output_html(void)
output_double(outfile, "td", shared_p->backups); output_double(outfile, "td", shared_p->backups);
output_float(outfile, "td", output_float(outfile, "td",
shared_p->available == 0 ? -NAN : (float)(100 * shared_p->available == 0 ? -NAN : (float)(100 *
shared_p-> shared_p->backups)
backups) / / shared_p->available);
shared_p->available);
} }
endrow(outfile); endrow(outfile);
@ -792,18 +796,16 @@ int output_html(void)
output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_double(outfile, "td", shared_networks->touched + shared_networks->used);
output_float(outfile, "td", output_float(outfile, "td",
shared_networks->available == 0 ? -NAN : (float)(100 * shared_networks->available == 0 ? -NAN : (float)(100 *
(shared_networks-> (shared_networks->touched
touched + +
shared_networks-> shared_networks->used))
used)) / / shared_networks->available);
shared_networks->available);
if (config.backups_found == true) { if (config.backups_found == true) {
output_double(outfile, "td", shared_networks->backups); output_double(outfile, "td", shared_networks->backups);
output_float(outfile, "td", output_float(outfile, "td",
shared_networks->available == 0 ? -NAN : (float)(100 * shared_networks->available == 0 ? -NAN : (float)(100 *
shared_networks-> shared_networks->backups)
backups) / / shared_networks->available);
shared_networks->available);
} }
endrow(outfile); endrow(outfile);
} }
@ -814,12 +816,12 @@ int output_html(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_html: fflush"); error(0, 0, "output_html: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_html: fclose"); error(0, 0, "output_html: fclose");
} }
} }
return 0; return 0;
@ -836,10 +838,11 @@ int output_csv(void)
struct shared_network_t *shared_p; struct shared_network_t *shared_p;
FILE *outfile; FILE *outfile;
int ret; int ret;
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_csv: %s", config.output_file); error(EXIT_FAILURE, errno, "output_csv: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -957,12 +960,12 @@ int output_csv(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_cvs: fflush"); error(0, 0, "output_cvs: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_cvs: fclose"); error(0, 0, "output_cvs: fclose");
} }
} }
return 0; return 0;
@ -989,7 +992,7 @@ int output_alarming(void)
if (config.output_file[0]) { if (config.output_file[0]) {
outfile = fopen(config.output_file, "w+"); outfile = fopen(config.output_file, "w+");
if (outfile == NULL) { if (outfile == NULL) {
err(EXIT_FAILURE, "output_alarming: %s", config.output_file); error(EXIT_FAILURE, errno, "output_alarming: %s", config.output_file);
} }
} else { } else {
outfile = stdout; outfile = stdout;
@ -1077,12 +1080,12 @@ int output_alarming(void)
if (outfile == stdout) { if (outfile == stdout) {
ret = fflush(stdout); ret = fflush(stdout);
if (ret) { if (ret) {
warn("output_alarming: fflush"); error(0, 0, "output_alarming: fflush");
} }
} else { } else {
ret = close_stream(outfile); ret = close_stream(outfile);
if (ret) { if (ret) {
warn("output_alarming: fclose"); error(0, 0, "output_alarming: fclose");
} }
} }
return ret_val; return ret_val;

View file

@ -40,15 +40,15 @@
#include <config.h> #include <config.h>
#include <err.h>
#include <errno.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "dhcpd-pools.h" #include "error.h"
#include "progname.h" #include "progname.h"
#include "dhcpd-pools.h"
/*! \brief Compare IP address, with IPv4/v6 determination. /*! \brief Compare IP address, with IPv4/v6 determination.
* \param a Binary IP address. * \param a Binary IP address.
* \param b Binary IP address. * \param b Binary IP address.
@ -237,8 +237,7 @@ comparer_t field_selector(char c)
return comp_tcperc; return comp_tcperc;
default: default:
clean_up(); clean_up();
warnx("field_selector: unknown sort order `%c'", c); error(EXIT_FAILURE, 0, "field_selector: unknown sort order `%c'", c);
errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name);
} }
return NULL; return NULL;
} }
@ -289,6 +288,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *r
{ {
int left, right, i; int left, right, i;
struct range_t hold; struct range_t hold;
/* Merge sort split size */ /* Merge sort split size */
static const int MIN_MERGE_SIZE = 8; static const int MIN_MERGE_SIZE = 8;