On Thu, Aug 03 2017, Rob Pierce <r...@2keys.ca> wrote:
> As a result ifstated.c no longer needs err.h.
>
> Index: ifstated.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ifstated/ifstated.c,v
> retrieving revision 1.56
> diff -u -p -r1.56 ifstated.c
> --- ifstated.c        24 Jul 2017 12:33:59 -0000      1.56
> +++ ifstated.c        3 Aug 2017 23:59:13 -0000
> @@ -37,7 +37,6 @@
>  #include <signal.h>
>  #include <stdint.h>
>  #include <syslog.h>
> -#include <err.h>
>  #include <event.h>
>  #include <unistd.h>
>  #include <ifaddrs.h>
> @@ -102,7 +101,7 @@ main(int argc, char *argv[])
>                       break;
>               case 'D':
>                       if (cmdline_symset(optarg) < 0)
> -                             errx(1, "could not parse macro definition %s",
> +                             fatalx("could not parse macro definition %s",
>                                   optarg);
>                       break;
>               case 'f':
> @@ -135,7 +134,7 @@ main(int argc, char *argv[])
>       if (opts & IFSD_OPT_NOACTION) {
>               if ((newconf = parse_config(configfile, opts)) == NULL)
>                       exit(1);
> -             warnx("configuration OK");
> +             fprintf(stderr, "configuration OK\n");

This changes the output from

  ifstated: configuration OK

to

  configuration OK

which is a bit less helpful.  To keep the output the same, you could use
warnx, fprintf + __progname/getprogname instead, or just

                errx(0, "configuration OK");

I don't really have a preference here.

>               exit(0);
>       }
>  
> @@ -147,7 +146,7 @@ main(int argc, char *argv[])
>       log_setverbose(opts & IFSD_OPT_VERBOSE);
>  
>       if ((rt_fd = socket(PF_ROUTE, SOCK_RAW, 0)) < 0)
> -             err(1, "no routing socket");
> +             fatal("no routing socket");
>  
>       rtfilter = ROUTE_FILTER(RTM_IFINFO);
>       if (setsockopt(rt_fd, PF_ROUTE, ROUTE_MSGFILTER,
> @@ -604,7 +603,7 @@ fetch_ifstate(void)
>       struct ifaddrs *ifap, *ifa;
>  
>       if (getifaddrs(&ifap) != 0)
> -             err(1, "getifaddrs");
> +             fatal("getifaddrs");
>  
>       for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
>               if (ifa->ifa_addr->sa_family == AF_LINK) {
>


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to