]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge pull request #5155 from DavieV/check-printer-first
authorMichael R Sweet <michaelrsweet@gmail.com>
Mon, 30 Oct 2017 16:04:06 +0000 (12:04 -0400)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2017 16:04:06 +0000 (12:04 -0400)
Rearranging order of null checks in lpadmin

systemv/lpadmin.c

index f9a1970b5c704d515251402b395486b694832616..c608c2d30f01451e995eb8c732040be154f16441 100644 (file)
@@ -601,27 +601,26 @@ main(int  argc,                   /* I - Number of command-line arguments */
 
   if (num_options || file)
   {
-    if (!http)
-    {
-      http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
-
-      if (http == NULL)
-      {
-       _cupsLangPrintf(stderr,
-                       _("lpadmin: Unable to connect to server: %s"),
-                       strerror(errno));
-       return (1);
-      }
-    }
-
     if (printer == NULL)
     {
       _cupsLangPuts(stderr,
                     _("lpadmin: Unable to set the printer options:\n"
-                     "         You must specify a printer name first."));
+                      "         You must specify a printer name first."));
       return (1);
     }
 
+    if (!http)
+    {
+      http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
+                          cupsEncryption(), 1, 30000, NULL);
+
+      if (http == NULL) {
+        _cupsLangPrintf(stderr, _("lpadmin: Unable to connect to server: %s"),
+                        strerror(errno));
+        return (1);
+      }
+    }
+
     if (set_printer_options(http, printer, num_options, options, file))
       return (1);
   }