From: krw Date: Fri, 23 Jun 2017 16:09:38 +0000 (+0000) Subject: Use a const char * for "/etc/resolv.conf.tail" instead of repeating the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5226fbea0d61af3276df68a976215946f4c40b06;p=openbsd Use a const char * for "/etc/resolv.conf.tail" instead of repeating the text in various forms in different error messages. Also makes the error messages consistent by always displaying the full path name. --- diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 0201bfe25b4..57ef5f3c485 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.443 2017/06/21 16:39:05 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.444 2017/06/23 16:09:38 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -443,6 +443,7 @@ int sock; int main(int argc, char *argv[]) { + const char *tail_path = "/etc/resolv.conf.tail"; struct interface_info *ifi; struct ifreq ifr; struct ieee80211_nwid nwid; @@ -585,26 +586,25 @@ main(int argc, char *argv[]) if (ignore_list) apply_ignore_list(ignore_list); - tailfd = open("/etc/resolv.conf.tail", O_RDONLY); + tailfd = open(tail_path, O_RDONLY); if (tailfd == -1) { if (errno != ENOENT) - fatal("Cannot open /etc/resolv.conf.tail"); + fatal("Cannot open %s", tail_path); } else if (fstat(tailfd, &sb) == -1) { - fatal("Cannot stat /etc/resolv.conf.tail"); + fatal("Cannot stat %s", tail_path); } else { if (sb.st_size > 0 && sb.st_size < LLONG_MAX) { config->resolv_tail = calloc(1, sb.st_size + 1); if (config->resolv_tail == NULL) { - fatalx("no memory for resolv.conf.tail " - "contents"); + fatalx("no memory for %s contents", tail_path); } tailn = read(tailfd, config->resolv_tail, sb.st_size); if (tailn == -1) - fatal("Couldn't read resolv.conf.tail"); + fatal("Couldn't read %s", tail_path); else if (tailn == 0) - fatalx("Got no data from resolv.conf.tail"); + fatalx("Got no data from %s", tail_path); else if (tailn != sb.st_size) - fatalx("Short read of resolv.conf.tail"); + fatalx("Short read of %s", tail_path); } close(tailfd); }