]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Remove redundant code 230/head
authorAlfonso Gregory <83477269+AtariDreams@users.noreply.github.com>
Mon, 30 Aug 2021 16:23:00 +0000 (12:23 -0400)
committerAlfonso Gregory <83477269+AtariDreams@users.noreply.github.com>
Tue, 7 Sep 2021 15:52:41 +0000 (11:52 -0400)
16 files changed:
cgi-bin/template.c
cgi-bin/var.c
cups/auth.c
cups/getdevices.c
cups/ipp-file.c
cups/pwg-media.c
cups/tls-gnutls.c
filter/common.c
filter/rastertohp.c
scheduler/auth.c
scheduler/main.c
scheduler/util.c
systemv/cancel.c
systemv/cupstestppd.c
systemv/lpstat.c
tools/ippeveps.c

index 0b785b2f677f9b93ce8e8d300c815d8fdd369b32..3300a8852e01f8706001f0c12758c9a6f0b6e958 100644 (file)
@@ -33,7 +33,6 @@ cgiCopyTemplateFile(FILE       *out,  /* I - Output file */
 {
   FILE *in;                            /* Input file */
 
-
   fprintf(stderr, "DEBUG2: cgiCopyTemplateFile(out=%p, tmpl=\"%s\")\n", out,
           tmpl ? tmpl : "(null)");
 
@@ -51,7 +50,7 @@ cgiCopyTemplateFile(FILE       *out,  /* I - Output file */
   if ((in = fopen(tmpl, "r")) == NULL)
   {
     fprintf(stderr, "ERROR: Unable to open template file \"%s\" - %s\n",
-            tmpl ? tmpl : "(null)", strerror(errno));
+            tmpl, strerror(errno));
     return;
   }
 
@@ -91,8 +90,6 @@ cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */
   * Convert the language to a locale name...
   */
 
-  locale[0] = '\0';
-
   if ((lang = getenv("LANG")) != NULL)
   {
     locale[0] = '/';
@@ -101,6 +98,10 @@ cgiCopyTemplateLang(const char *tmpl)       /* I - Base filename */
     if ((locptr = strchr(locale, '.')) != NULL)
       *locptr = '\0';                  /* Strip charset */
   }
+  else
+  {
+    locale[0] = '\0';
+  }
 
   fprintf(stderr, "DEBUG2: lang=\"%s\", locale=\"%s\"...\n",
           lang ? lang : "(null)", locale);
index 349a2184536b8c0474e720755d2d09c20d2c2af5..8c8387fa240e57df3fa916111b5626d9fd513cc3 100644 (file)
@@ -304,7 +304,7 @@ cgiInitialize(void)
     if (boundary)
       boundary += 9;
 
-    if (content_type && !strncmp(content_type, "multipart/form-data; ", 21))
+    if (!strncmp(content_type, "multipart/form-data; ", 21))
     {
       if (!cgi_initialize_multipart(boundary))
         return (0);
index b6fec6b983220947f5719808d9620ed6b621afdb..d70622ca5fd0c58c623387338845e7d64faa2c68 100644 (file)
@@ -330,10 +330,6 @@ _cupsSetNegotiateAuthString(
   gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
                                        /* Output token */
 
-
-  (void)method;
-  (void)resource;
-
 #  ifdef __APPLE__
  /*
   * If the weak-linked GSSAPI/Kerberos library is not present, don't try
@@ -450,6 +446,9 @@ _cupsSetNegotiateAuthString(
       }
     }
   }
+#  else
+  (void)method;
+  (void)resource;
 #  endif /* HAVE_GSS_ACQUIRED_CRED_EX_F */
 
   if (major_status == GSS_S_NO_CRED)
@@ -732,9 +731,10 @@ cups_auth_scheme(const char *www_authenticate,     /* I - Pointer into WWW-Authentic
         * Skip quoted value...
         */
 
-        www_authenticate ++;
-        while (*www_authenticate && *www_authenticate != '\"')
+
+        do
           www_authenticate ++;
+        while (*www_authenticate && *www_authenticate != '\"');
       }
     }
 
index 77ee7e492c2927532ada7da24dfae7076c4ecaf9..eca8bbbfc8638332ffb8b7ae615578b303107bda 100644 (file)
@@ -248,20 +248,14 @@ cupsGetDevices(
   httpBlocking(http, blocking);
   httpFlush(http);
 
-  if (status == HTTP_STATUS_ERROR)
-    _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(http->error), 0);
-  else
-  {
-    attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
+  attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
 
-    DEBUG_printf(("cupsGetDevices: status-code=%s, status-message=\"%s\"",
-                 ippErrorString(response->request.status.status_code),
-                 attr ? attr->values[0].string.text : ""));
+  DEBUG_printf(("cupsGetDevices: status-code=%s, status-message=\"%s\"",
+                ippErrorString(response->request.status.status_code),
+                attr ? attr->values[0].string.text : ""));
 
-    _cupsSetError(response->request.status.status_code,
-                 attr ? attr->values[0].string.text :
-                     ippErrorString(response->request.status.status_code), 0);
-  }
+  _cupsSetError(response->request.status.status_code,
+                attr ? attr->values[0].string.text : ippErrorString(response->request.status.status_code), 0);
 
   ippDelete(response);
 
index 5db5932a4e086cdfa6bafe142340dff0c6906d31..5483a607df600c4752114e6745d978dc8086449d 100644 (file)
@@ -303,10 +303,7 @@ _ippFileReadToken(_ipp_file_t *f,  /* I - File to read from */
       * Start of quoted text or regular expression...
       */
 
-      if (ch == '<')
-        quote = '>';
-      else
-        quote = ch;
+      quote = ch;
 
       DEBUG_printf(("1_ippFileReadToken: Start of quoted string, quote=%c, pos=%ld", quote, (long)cupsFileTell(f->fp)));
     }
@@ -571,12 +568,10 @@ parse_value(_ipp_file_t      *f,  /* I  - IPP data file */
   {
     case IPP_TAG_BOOLEAN :
         return (ippSetBoolean(ipp, attr, element, !_cups_strcasecmp(value, "true")));
-        break;
 
     case IPP_TAG_ENUM :
     case IPP_TAG_INTEGER :
         return (ippSetInteger(ipp, attr, element, (int)strtol(value, NULL, 0)));
-        break;
 
     case IPP_TAG_DATE :
         {
@@ -690,7 +685,6 @@ parse_value(_ipp_file_t      *f,    /* I  - IPP data file */
 
           return (ippSetDate(ipp, attr, element, date));
         }
-        break;
 
     case IPP_TAG_RESOLUTION :
        {
@@ -718,7 +712,6 @@ parse_value(_ipp_file_t      *f,    /* I  - IPP data file */
          else
            return (ippSetResolution(ipp, attr, element, (ipp_res_t)0, xres, yres));
        }
-       break;
 
     case IPP_TAG_RANGE :
        {
@@ -733,7 +726,6 @@ parse_value(_ipp_file_t      *f,    /* I  - IPP data file */
 
          return (ippSetRange(ipp, attr, element, lower, upper));
        }
-       break;
 
     case IPP_TAG_STRING :
         valuelen = strlen(value);
@@ -774,7 +766,6 @@ parse_value(_ipp_file_t      *f,    /* I  - IPP data file */
         }
         else
           return (ippSetOctetString(ipp, attr, element, value, (int)valuelen));
-        break;
 
     case IPP_TAG_TEXTLANG :
     case IPP_TAG_NAMELANG :
@@ -787,7 +778,6 @@ parse_value(_ipp_file_t      *f,    /* I  - IPP data file */
     case IPP_TAG_LANGUAGE :
     case IPP_TAG_MIMETYPE :
         return (ippSetString(ipp, attr, element, value));
-        break;
 
     case IPP_TAG_BEGIN_COLLECTION :
         {
@@ -808,14 +798,11 @@ parse_value(_ipp_file_t      *f,  /* I  - IPP data file */
 
          return (status);
        }
-       break;
 
     default :
         report_error(f, v, user_data, "Unsupported value on line %d of \"%s\".", f->linenum, f->filename);
         return (0);
   }
-
-  return (1);
 }
 
 
index 00bb2ed61a89d79c8f6346b1ed5a225d1067b50c..535db08800c483fe52ebc4aa92589295d99a226a 100644 (file)
@@ -448,13 +448,13 @@ pwgInitSize(pwg_size_t *size,             /* I - Size to initialize */
         size->width  = x_dimension->values[0].integer;
        size->length = y_dimension->values[0].integer;
       }
-      else if (!x_dimension)
+      else if (!x_dimension) /* x_dimension is missing */
       {
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                      _("Missing x-dimension in media-size."), 1);
         return (0);
       }
-      else if (!y_dimension)
+      else /* y_dimension must be missing */
       {
        _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                      _("Missing y-dimension in media-size."), 1);
index a99b27a13e3df363efbe28931b656ad1c5fb822b..c1dd0a6b079acf29b2321c0475c26debe60be13d 100644 (file)
@@ -660,7 +660,7 @@ httpCredentialsString(
   if (!buffer)
     return (0);
 
-  if (buffer && bufsize > 0)
+  if (bufsize > 0)
     *buffer = '\0';
 
   if ((first = (http_credential_t *)cupsArrayFirst(credentials)) != NULL &&
@@ -1517,8 +1517,7 @@ _httpTLSStart(http_t *http)               /* I - Connection to server */
 
     DEBUG_printf(("4_httpTLSStart: Using certificate \"%s\" and private key \"%s\".", crtfile, keyfile));
 
-    if (!status)
-      status = gnutls_certificate_set_x509_key_file(*credentials, crtfile, keyfile, GNUTLS_X509_FMT_PEM);
+    status = gnutls_certificate_set_x509_key_file(*credentials, crtfile, keyfile, GNUTLS_X509_FMT_PEM);
   }
 
   if (!status)
index 672b7c8cd5ff5c617a647c3242c946ed10c91d75..e0cbcd384083025743d0e2af37f50150a70a468c 100644 (file)
@@ -301,7 +301,7 @@ WriteLabelProlog(const char *label, /* I - Page label */
 
   if ((classification = getenv("CLASSIFICATION")) == NULL)
     classification = "";
-  if (strcmp(classification, "none") == 0)
+  else if (strcmp(classification, "none") == 0)
     classification = "";
 
  /*
index 409b1c935923f309b6f0a10959ef8ee149e67dd9..31ee0c4c9891a0cee34e47cbbf6494286bfc37d6 100644 (file)
@@ -813,8 +813,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   Shutdown();
 
-  if (ppd)
-    ppdClose(ppd);
+  ppdClose(ppd);
 
  /*
   * Close the raster stream...
index 2f15cc81e65c725add189de8a36e773da2d2bd14..580dcde08e801914c98822f12cdab2529e2b1623 100644 (file)
@@ -734,7 +734,6 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
                                        /* Output token for username */
     gss_name_t         client_name;    /* Client name */
 
-
 #  ifdef __APPLE__
    /*
     * If the weak-linked GSSAPI/Kerberos library is not present, don't try
index 3d9ff32af0f8b0d0717092809291fbcac0808c7e..7c19fa0f9ae63a62ed92783aa6edaa2749607d72 100644 (file)
@@ -233,7 +233,6 @@ main(int  argc,                             /* I - Number of command-line args */
 
           case 'h' : /* Show usage/help */
              usage(0);
-             break;
 
           case 'l' : /* Started by launchd/systemd/upstart... */
 #ifdef HAVE_ONDEMAND
@@ -313,7 +312,6 @@ main(int  argc,                             /* I - Number of command-line args */
               _cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
                                        "aborting."), *opt);
              usage(1);
-             break;
        }
       }
     }
@@ -1903,7 +1901,6 @@ service_add_listener(int fd,              /* I - Socket file descriptor */
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_add_listener: Unable to allocate listener: %s.", strerror(errno));
       exit(EXIT_FAILURE);
-      return;
     }
 
     cupsArrayAdd(Listeners, lis);
@@ -1955,7 +1952,6 @@ service_checkin(void)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Unable to get listener sockets: %s", strerror(error));
       exit(EXIT_FAILURE);
-      return; /* anti-compiler-warning */
     }
 
    /*
@@ -1988,7 +1984,6 @@ service_checkin(void)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Unable to get listener sockets: %s", strerror(-count));
       exit(EXIT_FAILURE);
-      return; /* anti-compiler-warning */
     }
 
    /*
@@ -2012,21 +2007,18 @@ service_checkin(void)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: We did not get started via Upstart.");
       exit(EXIT_FAILURE);
-      return;
     }
 
     if (strcasecmp(e, "socket"))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: We did not get triggered via an Upstart socket event.");
       exit(EXIT_FAILURE);
-      return;
     }
 
     if ((e = getenv("UPSTART_FDS")) == NULL)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Unable to get listener sockets from UPSTART_FDS.");
       exit(EXIT_FAILURE);
-      return;
     }
 
     cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: UPSTART_FDS=%s", e);
@@ -2036,7 +2028,6 @@ service_checkin(void)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Could not parse UPSTART_FDS: %s", strerror(errno));
       exit(EXIT_FAILURE);
-      return;
     }
 
    /*
index 865690444d113d4816fc4043c15f177f16f0c5e1..228733f38885f76851331290bab6b9e5be60010c 100644 (file)
@@ -108,7 +108,7 @@ cupsdCompareNames(const char *s,    /* I - First string */
         return (-1);
       else if (digits > 0)
         return (1);
-      else if (diff)
+      else
         return (diff);
     }
     else if (tolower(*s) < tolower(*t))
@@ -142,10 +142,10 @@ cupsdCompareNames(const char *s,  /* I - First string */
 cups_array_t *                         /* O - CUPS array */
 cupsdCreateStringsArray(const char *s) /* I - Comma-delimited strings */
 {
-  if (!s || !*s)
-    return (NULL);
-  else
+  if (s && *s)
     return (_cupsArrayNewStrings(s, ','));
+  else
+    return (NULL);
 }
 
 
index 4530c04ac76280e112d74e5304d571b9933dee35..8e7b3c185b75dea6d38d1aadeefca943d4bc6208 100644 (file)
@@ -312,8 +312,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                        op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
                        cupsLastErrorString());
 
-       if (response)
-         ippDelete(response);
+          ippDelete(response);
 
        return (1);
       }
@@ -376,8 +375,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                      op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
                      cupsLastErrorString());
 
-      if (response)
-       ippDelete(response);
+      ippDelete(response);
 
       return (1);
     }
index b94cae94408aa76cffad1a80e252634daeb9bf54..c3a2d19dce002ce1bb1cbe98ec89946bf49789a6 100644 (file)
@@ -261,7 +261,6 @@ main(int  argc,                             /* I - Number of command-line args */
 
          default :
              usage();
-             break;
        }
     }
     else
index fec52b68104db7445b7ad72604d380a4d9059b26..66c3686e5635c8c6ea0ea83e85698d60b350b7cb 100644 (file)
@@ -635,7 +635,7 @@ match_list(const char *list,                /* I - List of names */
   if (!name)
     return (0);
 
-  while (*list)
+  do
   {
    /*
     * Skip leading whitespace and commas...
@@ -661,6 +661,7 @@ match_list(const char *list,                /* I - List of names */
     while (*list && !isspace(*list & 255) && *list != ',')
       list ++;
   }
+  while (*list);
 
   return (0);
 }
@@ -811,8 +812,8 @@ show_accepting(const char  *printers,       /* I - Destinations */
          _cupsLangPrintf(stdout, _("%s not accepting requests since %s -"),
                          printer, printer_state_time);
          _cupsLangPrintf(stdout, _("\t%s"),
-                         (message == NULL || !*message) ?
-                             "reason unknown" : message);
+                         (message && *message) ?
+                             message : "reason unknown");
         }
 
         for (i = 0; i < num_dests; i ++)
@@ -827,8 +828,8 @@ show_accepting(const char  *printers,       /* I - Destinations */
                              _("%s/%s not accepting requests since %s -"),
                              printer, dests[i].instance, printer_state_time);
              _cupsLangPrintf(stdout, _("\t%s"),
-                             (message == NULL || !*message) ?
-                                 "reason unknown" : message);
+                             (message && *message) ?
+                                 message : "reason unknown");
             }
          }
       }
@@ -951,7 +952,7 @@ show_classes(const char *dests)             /* I - Destinations */
       printer_uri = NULL;
       members     = NULL;
 
-      while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
+      do
       {
         if (!strcmp(attr->name, "printer-name") &&
            attr->value_tag == IPP_TAG_NAME)
@@ -967,6 +968,7 @@ show_classes(const char *dests)             /* I - Destinations */
 
         attr = attr->next;
       }
+         while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER);
 
      /*
       * If this is a remote class, grab the class info from the
@@ -1790,10 +1792,10 @@ show_printers(const char  *printers,    /* I - Destinations */
 
         if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
        {
-         if (!message || !*message)
-           _cupsLangPuts(stdout, _("\treason unknown"));
+         if (message && *message)
+               _cupsLangPrintf(stdout, "\t%s", message);
          else
-           _cupsLangPrintf(stdout, "\t%s", message);
+           _cupsLangPuts(stdout, _("\treason unknown"));
        }
 
         if (long_status > 1)
@@ -1910,10 +1912,10 @@ show_printers(const char  *printers,    /* I - Destinations */
 
             if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
            {
-             if (!message || !*message)
-               _cupsLangPuts(stdout, _("\treason unknown"));
-             else
+             if (message && *message)
                _cupsLangPrintf(stdout, "\t%s", message);
+             else
+               _cupsLangPuts(stdout, _("\treason unknown"));
             }
 
             if (long_status > 1)
index 52e14ee167b774c8e42a0f2f6bcbe60a6923fe25..cdedc8899a564244d669c19e6f553cbc21e2f9d5 100644 (file)
@@ -185,7 +185,7 @@ ascii85(const unsigned char *data,  /* I - Data to write */
   if (length > 0)
   {
     // Copy any remainder into the leftdata array...
-    if ((length - leftcount) > 0)
+    if (length > leftcount)
       memcpy(leftdata + leftcount, data, (size_t)(length - leftcount));
 
     memset(leftdata + length, 0, (size_t)(4 - length));