Skip to content

Commit

Permalink
Merge pull request #5953 from AtariDreams/appcode2
Browse files Browse the repository at this point in the history
Remove redundant code
  • Loading branch information
michaelrsweet committed Sep 7, 2021
2 parents fd50212 + baa764f commit 95b7060
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 71 deletions.
9 changes: 5 additions & 4 deletions cgi-bin/template.c
Expand Up @@ -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)");

Expand All @@ -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;
}

Expand Down Expand Up @@ -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] = '/';
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cgi-bin/var.c
Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions cups/auth.c
Expand Up @@ -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
Expand Down Expand Up @@ -450,6 +446,9 @@ _cupsSetNegotiateAuthString(
}
}
}
# else
(void)method;
(void)resource;
# endif /* HAVE_GSS_ACQUIRED_CRED_EX_F */

if (major_status == GSS_S_NO_CRED)
Expand Down Expand Up @@ -562,9 +561,9 @@ cups_auth_find(const char *www_authenticate, /* I - Pointer into WWW-Authenticat
* Skip quoted value...
*/

www_authenticate ++;
while (*www_authenticate && *www_authenticate != '\"')
do
www_authenticate ++;
while (*www_authenticate && *www_authenticate != '\"');

DEBUG_printf(("9cups_auth_find: After quoted: \"%s\"", www_authenticate));
}
Expand Down
18 changes: 6 additions & 12 deletions cups/getdevices.c
Expand Up @@ -246,20 +246,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);

Expand Down
15 changes: 1 addition & 14 deletions cups/ipp-file.c
Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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 :
{
Expand Down Expand Up @@ -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 :
{
Expand Down Expand Up @@ -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 :
{
Expand All @@ -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);
Expand Down Expand Up @@ -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 :
Expand All @@ -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 :
{
Expand All @@ -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);
}


Expand Down
4 changes: 2 additions & 2 deletions cups/pwg-media.c
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions cups/tls-gnutls.c
Expand Up @@ -659,7 +659,7 @@ httpCredentialsString(
if (!buffer)
return (0);

if (buffer && bufsize > 0)
if (bufsize > 0)
*buffer = '\0';

if ((first = (http_credential_t *)cupsArrayFirst(credentials)) != NULL &&
Expand Down Expand Up @@ -1516,8 +1516,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)
Expand Down
2 changes: 1 addition & 1 deletion filter/common.c
Expand Up @@ -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 = "";

/*
Expand Down
3 changes: 1 addition & 2 deletions filter/rastertohp.c
Expand Up @@ -813,8 +813,7 @@ main(int argc, /* I - Number of command-line arguments */

Shutdown();

if (ppd)
ppdClose(ppd);
ppdClose(ppd);

/*
* Close the raster stream...
Expand Down
4 changes: 0 additions & 4 deletions scheduler/main.c
Expand Up @@ -232,7 +232,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
Expand Down Expand Up @@ -312,7 +311,6 @@ main(int argc, /* I - Number of command-line args */
_cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
"aborting."), *opt);
usage(1);
break;
}
}
}
Expand Down Expand Up @@ -1888,7 +1886,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);
Expand Down Expand Up @@ -1940,7 +1937,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 */
}

/*
Expand Down
8 changes: 4 additions & 4 deletions scheduler/util.c
Expand Up @@ -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))
Expand Down Expand Up @@ -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);
}


Expand Down
6 changes: 2 additions & 4 deletions systemv/cancel.c
Expand Up @@ -311,8 +311,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);
}
Expand Down Expand Up @@ -375,8 +374,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);
}
Expand Down
1 change: 0 additions & 1 deletion systemv/cupstestppd.c
Expand Up @@ -261,7 +261,6 @@ main(int argc, /* I - Number of command-line args */

default :
usage();
break;
}
}
else
Expand Down

0 comments on commit 95b7060

Please sign in to comment.