Skip to content

Commit

Permalink
Fix some clang-detected issues (mostly with debug printfs and missing…
Browse files Browse the repository at this point in the history
… void

casts), and fix the Xcode project file.
  • Loading branch information
michaelrsweet committed Sep 10, 2024
1 parent 327af60 commit 6d33b1f
Show file tree
Hide file tree
Showing 14 changed files with 1,305 additions and 552 deletions.
13 changes: 10 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ CHANGES - OpenPrinting CUPS 2.5b1 - (TBA)
Changes in CUPS v2.5b1 (TBA)
----------------------------

- Added `cupsDNSSD` APIs.
- Added multiple language support for IPP Everywhere.
- Added `cupsConcatString`, `cupsCopyString`, and `cupsFormatString` string
APIs.
- Added multiple language support for IPP Everywhere.
- Added new APIs for form, JSON, JWT, IPP, and raster setup.
- Added new `cupsRasterInitHeader` API.
- Added `httpConnectURI` API.
- Added `ippAddCredentialsString`, `ippGetFirstAttribute`,
`ippGetNextAttribute`, `ippRestore`, and `ippSave` APIs.
- Added new DNS-SD APIs.
- Added new JSON APIs.
- Added new JWT APIs.
- Added new OAuth APIs.
- Added new WWW form APIs.
- Added "job-sheets-col" support (Issue #138)
- Added "--list-all" option for cupsfilter (Issue #194)
- Added support for wide-area DNS-SD with Avahi (Issue #319)
Expand Down
4 changes: 2 additions & 2 deletions cups/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ _cupsEncodeOption(
else
{
ippDeleteAttribute(ipp, attr);
free(copy);
return (NULL);
}
break;
Expand Down Expand Up @@ -684,8 +685,7 @@ _cupsEncodeOption(
}
}

if (copy)
free(copy);
free(copy);

return (attr);
}
Expand Down
8 changes: 4 additions & 4 deletions cups/form.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ cupsFormDecode(const char *data, // I - URL-encoded form data
while (*data)
{
// Get the name and value...
DEBUG_printf("2cupsFormDecode: LOOP data=%p, *data='%c'", data, data ? *data : '?');
DEBUG_printf("2cupsFormDecode: LOOP data=%p, *data='%c'", (void *)data, data ? *data : '?');
data = decode_string(data, name, sizeof(name));

if (!data || *data != '=')
{
DEBUG_printf("2cupsFormDecode: NAMEERROR data=%p, *data='%c'", data, data ? *data : '?');
DEBUG_printf("2cupsFormDecode: NAMEERROR data=%p, *data='%c'", (void *)data, data ? *data : '?');
goto decode_error;
}

Expand All @@ -83,7 +83,7 @@ cupsFormDecode(const char *data, // I - URL-encoded form data

if (!data || (*data && *data != '&'))
{
DEBUG_printf("2cupsFormDecode: VALUEERROR data=%p, *data='%c'", data, data ? *data : '?');
DEBUG_printf("2cupsFormDecode: VALUEERROR data=%p, *data='%c'", (void *)data, data ? *data : '?');
goto decode_error;
}
else if (*data)
Expand All @@ -92,7 +92,7 @@ cupsFormDecode(const char *data, // I - URL-encoded form data

if (!*data)
{
DEBUG_printf("2cupsFormDecode: POSTERROR data=%p, *data='%c'", data, data ? *data : '?');
DEBUG_printf("2cupsFormDecode: POSTERROR data=%p, *data='%c'", (void *)data, data ? *data : '?');
goto decode_error;
}
}
Expand Down
7 changes: 7 additions & 0 deletions cups/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,9 @@ httpLoadCredentials(
cups_array_t **credentials, // O - Array of credentials
const char *common_name) // I - Common name
{
(void)path;
(void)common_name;

if (credentials)
*credentials = NULL;

Expand Down Expand Up @@ -2372,6 +2375,10 @@ httpSaveCredentials(
cups_array_t *credentials, // O - Array of credentials
const char *common_name) // I - Common name
{
(void)path;
(void)credentials;
(void)common_name;

return (-1);
}

Expand Down
6 changes: 3 additions & 3 deletions cups/oauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ cupsOAuthGetAuthorizationCode(
*error_code, // Error code
*error_desc, // Error description
*state_value; // State value
size_t num_form; // Number of form variables
int num_form; // Number of form variables
cups_option_t *form = NULL; // Form variables

num_form = cupsFormDecode(reqres + resourcelen, &form);
Expand Down Expand Up @@ -973,7 +973,7 @@ cupsOAuthGetTokens(
const char *token_ep; // Token endpoint
char *value, // Prior value
*nonce = NULL; // Prior nonce value
size_t num_form = 0; // Number of form variables
int num_form = 0; // Number of form variables
cups_option_t *form = NULL; // Form variables
char *request = NULL; // Form request data
cups_json_t *response = NULL; // JSON response variables
Expand Down Expand Up @@ -1180,7 +1180,7 @@ cupsOAuthMakeAuthorizationURL(
const char *authorization_ep; // Authorization endpoint
unsigned char sha256[32]; // SHA-256 hash of code verifier
char code_challenge[64]; // Hashed code verifier string
size_t num_vars = 0; // Number of form variables
int num_vars = 0; // Number of form variables
cups_option_t *vars = NULL; // Form variables
char *url; // URL for authorization page

Expand Down
2 changes: 1 addition & 1 deletion cups/ppd-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ _ppdCacheCreateWithPPD(
* Add localized text for PWG keyword to message catalog...
*/

snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_name);
snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_keyword);
ppd_get_strings(ppd, langs, "OutputBin", choice, msg_id);
}
}
Expand Down
10 changes: 5 additions & 5 deletions cups/testform.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct _form_data_s // Form test data
{
const char *url, // URL prefix, if any
*encoded; // URL-encoded data
size_t num_pairs; // Number of name=value pairs
int num_pairs; // Number of name=value pairs
const char * const * pairs; // name=value pairs
} _form_data_t;

Expand Down Expand Up @@ -140,7 +140,7 @@ main(int argc, // I - Number of command-line arguments
int i; // Looping var
const char *opt; // Current option
const char *url = NULL; // URL, if any
size_t num_vars; // Number of variables
int num_vars; // Number of variables
cups_option_t *vars; // Variables
char *data; // Form data

Expand Down Expand Up @@ -184,7 +184,7 @@ main(int argc, // I - Number of command-line arguments
}
else
{
size_t j; // Looping var
int j; // Looping var

for (j = 0; j < num_vars; j ++)
printf("%s=%s\n", vars[j].name, vars[j].value);
Expand Down Expand Up @@ -263,7 +263,7 @@ main(int argc, // I - Number of command-line arguments
static void
do_test(_form_data_t *test) // I - Test data
{
size_t i, // Looping var
int i, // Looping var
num_vars; // Number of variables
cups_option_t *vars; // Variables
char *data; // Form data
Expand All @@ -277,7 +277,7 @@ do_test(_form_data_t *test) // I - Test data
}
else
{
size_t count; // Max count
int count; // Max count
const char *value; // Value

for (i = 0, count = 2 * test->num_pairs; i < count; i += 2)
Expand Down
11 changes: 7 additions & 4 deletions cups/testlang.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,16 @@ test_language(const char *lang) /* I - Locale language code, NULL for default *
puts("PASS");
}

printf("language->language: \"%s\"\n", language->language);
printf("_cupsEncodingName(language): \"%s\"\n", _cupsEncodingName(language->encoding));
printf("language->language: \"%s\"\n", language ? language->language : NULL);
printf("_cupsEncodingName(language): \"%s\"\n", language ? _cupsEncodingName(language->encoding) : NULL);

errors += test_string(language, "No");
errors += test_string(language, "Yes");

if (language != language2)
{
printf("language2->language: \"%s\"\n", language2->language);
printf("_cupsEncodingName(language2): \"%s\"\n", _cupsEncodingName(language2->encoding));
printf("language2->language: \"%s\"\n", language2 ? language2->language : NULL);
printf("_cupsEncodingName(language2): \"%s\"\n", language2 ? _cupsEncodingName(language2->encoding) : NULL);
}

loc = localeconv();
Expand Down Expand Up @@ -345,6 +345,9 @@ test_string(cups_lang_t *language, /* I - Language */
* For any other locale, the string pointers should be different.
*/

if (!language)
return (1);

printf("_cupsLangString(\"%s\"): ", msgid);
msgstr = _cupsLangString(language, msgid);
if (strcmp(language->language, "C") && msgid == msgstr)
Expand Down
6 changes: 3 additions & 3 deletions cups/testthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ show_supported(http_t *http, // I - Connection to destination
const char *value) // I - Value, if any
{
ipp_attribute_t *attr; // Attribute
size_t i, // Looping var
int i, // Looping var
count; // Number of values


Expand Down Expand Up @@ -221,8 +221,8 @@ show_supported(http_t *http, // I - Connection to destination
case IPP_TAG_STRING :
for (i = 0; i < count; i ++)
{
size_t j; // Looping var
int len; // Length of value
int j; // Looping var
int len; // Length of value
unsigned char *data = ippGetOctetString(attr, i, &len);
// Pointer to octet string

Expand Down
4 changes: 2 additions & 2 deletions cups/tls-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ httpCopyPeerCredentials(http_t *http) // I - Connection to server
BIO *bio = BIO_new(BIO_s_mem());
// Memory buffer for cert

DEBUG_printf("1httpCopyPeerCredentials: chain[%d/%d]=%p", i + 1, count, cert);
DEBUG_printf("1httpCopyPeerCredentials: chain[%d/%d]=%p", i + 1, count, (void *)cert);

#ifdef DEBUG
char subjectName[256], issuerName[256];
Expand All @@ -1384,7 +1384,7 @@ httpCopyPeerCredentials(http_t *http) // I - Connection to server

STACK_OF(GENERAL_NAME) *names; // subjectAltName values
names = X509_get_ext_d2i(cert, NID_subject_alt_name, /*crit*/NULL, /*idx*/NULL);
DEBUG_printf("1httpCopyPeerCredentials: subjectAltNames=%p(%d)", names, names ? sk_GENERAL_NAME_num(names) : 0);
DEBUG_printf("1httpCopyPeerCredentials: subjectAltNames=%p(%d)", (void *)names, names ? sk_GENERAL_NAME_num(names) : 0);
if (names)
GENERAL_NAMES_free(names);
#endif // DEBUG
Expand Down
2 changes: 1 addition & 1 deletion scheduler/testlpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ main(int argc, /* I - Number of command-line arguments */
strcmp(op, "remove-job") && strcmp(op, "status-long") &&
strcmp(op, "status-short")))
{
printf("op=\"%s\", dest=\"%s\", opargs=%p\n", op, dest, opargs);
printf("op=\"%s\", dest=\"%s\", opargs=%p\n", op, dest, (void *)opargs);
usage();
}

Expand Down
4 changes: 2 additions & 2 deletions scheduler/testmime.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ print_rules(mime_magic_t *rules) /* I - Rules to print */

while (rules != NULL)
{
printf("%s[%p] ", indent, rules);
printf("%s[%p] ", indent, (void *)rules);

if (rules->invert)
printf("NOT ");
Expand Down Expand Up @@ -410,7 +410,7 @@ print_rules(mime_magic_t *rules) /* I - Rules to print */
else
puts("AND (");

strcat(indent, "\t");
strlcat(indent, "\t", sizeof(indent));
print_rules(rules->child);
indent[strlen(indent) - 1] = '\0';
printf("%s)\n", indent);
Expand Down
2 changes: 1 addition & 1 deletion scheduler/testspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ main(int argc, /* I - Number of command-line arguments */

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

0 comments on commit 6d33b1f

Please sign in to comment.