cleanup initialization of chngdir. inspired by Ross L Richardson.
authorbenno <benno@openbsd.org>
Mon, 30 Jul 2018 09:59:03 +0000 (09:59 +0000)
committerbenno <benno@openbsd.org>
Mon, 30 Jul 2018 09:59:03 +0000 (09:59 +0000)
ok tb@

usr.sbin/acme-client/main.c

index 4bbc250..d96bf40 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: main.c,v 1.40 2018/07/30 09:56:50 benno Exp $ */
+/*     $Id: main.c,v 1.41 2018/07/30 09:59:03 benno Exp $ */
 /*
  * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
  *
@@ -160,13 +160,10 @@ main(int argc, char *argv[])
                /* XXX replace with existance check in parse.y */
                err(EXIT_FAILURE, "no account key in config?");
        }
-       if (domain->challengedir == NULL)
-               chngdir = strdup(WWW_DIR);
-       else
-               chngdir = domain->challengedir;
 
-       if (chngdir == NULL)
-               err(EXIT_FAILURE, "strdup");
+       if ((chngdir = domain->challengedir) == NULL)
+               if ((chngdir = strdup(WWW_DIR)) == NULL)
+                       err(EXIT_FAILURE, "strdup");
 
        /*
         * Do some quick checks to see if our paths exist.