]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix clang warnings, clean up cupsArray usage.
authorMichael R Sweet <msweet@msweet.org>
Thu, 25 Sep 2025 21:50:53 +0000 (17:50 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 25 Sep 2025 21:50:53 +0000 (17:50 -0400)
cgi-bin/home.c
cgi-bin/ipp-var.c
cups/array.c
cups/oauth.c
cups/string-private.h
cups/string.c
cups/testdnssd.c
locale/cups_uk.po
tools/ipptool.c
xcode/CUPS.xcodeproj/project.pbxproj

index 84c8d7e28a1449dd010541b173a9f80bd12916fd..a4e38febf970e1fa9f5330218ac1e4c83077fd19 100644 (file)
@@ -112,7 +112,6 @@ do_login(void)
   fputs("DEBUG2: do_login()\n", stderr);
 
   // Get the metadata...
-  oauth_uri = getenv("CUPS_OAUTH_SERVER");
   if ((metadata = cupsOAuthGetMetadata(oauth_uri)) == NULL)
   {
     show_error(cgiText(_("OAuth Login")), cgiText(_("Unable to get authorization server information")), cupsGetErrorString());
@@ -261,7 +260,6 @@ finish_login(void)
   }
 
   // Get the metadata...
-  oauth_uri = getenv("CUPS_OAUTH_SERVER");
   if ((metadata = cupsOAuthGetMetadata(oauth_uri)) == NULL)
   {
     show_error(cgiText(_("OAuth Login")), cgiText(_("Unable to get authorization server information")), cupsGetErrorString());
index 0f00a7511870667cbdecf53311887960c22919d2..939c3734c15aabaf271f656a111b9bbed2bb887e 100644 (file)
@@ -86,8 +86,12 @@ cgiGetAttributes(ipp_t      *request,        /* I - IPP request */
   attrs[0]  = NULL;                    /* Eliminate compiler warning */
 
   while ((ch = getc(in)) != EOF)
+  {
     if (ch == '\\')
-      getc(in);
+    {
+      if (getc(in) == EOF)
+        break;
+    }
     else if (ch == '{' && num_attrs < (int)(sizeof(attrs) / sizeof(attrs[0])))
     {
      /*
@@ -95,10 +99,15 @@ cgiGetAttributes(ipp_t      *request,       /* I - IPP request */
       */
 
       for (nameptr = name; (ch = getc(in)) != EOF;)
+      {
         if (strchr("}]<>=!~ \t\n", ch))
+        {
           break;
+        }
         else if (nameptr > name && ch == '?')
+       {
          break;
+       }
        else if (nameptr < (name + sizeof(name) - 1))
        {
          if (ch == '_')
@@ -106,6 +115,7 @@ cgiGetAttributes(ipp_t      *request,       /* I - IPP request */
          else
             *nameptr++ = (char)ch;
        }
+      }
 
       *nameptr = '\0';
 
@@ -117,15 +127,21 @@ cgiGetAttributes(ipp_t      *request,     /* I - IPP request */
       */
 
       for (i = 0; i < num_attrs; i ++)
+      {
         if (!strcmp(attrs[i], name))
          break;
+      }
 
       if (i >= num_attrs)
       {
        attrs[num_attrs] = strdup(name);
        num_attrs ++;
       }
+
+      if (ch == EOF)
+        break;
     }
+  }
 
  /*
   * If we have attributes, add a requested-attributes attribute to the
index a12ce99cd9ff968eb5c4fc0c8567145f6d2e0721..f21ec7445d6036a17f3a3c508a67a939d6770361 100644 (file)
@@ -433,6 +433,20 @@ cupsArrayFirst(cups_array_t *a)            // I - Array
 }
 
 
+//
+// '_cupsArrayFree()' - Free a string in an array.
+//
+
+void
+_cupsArrayFree(void *s,                        // I - String to free
+               void *data)             // I - Callback data (unused)
+{
+  (void)data;
+
+  free(s);
+}
+
+
 //
 // 'cupsArrayGetCount()' - Get the number of elements in the array.
 //
@@ -827,7 +841,7 @@ cupsArrayNewStrings(const char *s,  // I - Delimited strings or `NULL`
   cups_array_t *a;                     // Array
 
 
-  if ((a = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, (cups_acopy_cb_t)_cupsArrayStrdup, (cups_afree_cb_t)_cupsArrayFree)) != NULL)
+  if ((a = cupsArrayNew3(_cupsArrayStrcmp, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree)) != NULL)
     cupsArrayAddStrings(a, s, delim);
 
   return (a);
@@ -988,6 +1002,50 @@ cupsArraySave(cups_array_t *a)            // I - Array
 }
 
 
+//
+// '_cupsArrayStrcasecmp()' - Compare two strings in an array, ignoring case...
+//
+
+int                                    // O - Result of comparison
+_cupsArrayStrcasecmp(void *s,          // I - First string
+                     void *t,          // I - Second string
+                     void *data)       // I - Callback data (unused)
+{
+  (void)data;
+
+  return (_cups_strcasecmp((const char *)s, (const char *)t));
+}
+
+
+//
+// '_cupsArrayStrcmp()' - Compare two strings in an array.
+//
+
+int                                    // O - Result of comparison
+_cupsArrayStrcmp(void *s,              // I - first string to compare
+                void *t,               // I - second string to compare
+                 void *data)           // I - Callback data (unused)
+{
+  (void)data;
+
+  return (strcmp((const char *)s, (const char *)t));
+}
+
+
+//
+// '_cupsArrayStrdup()' - Copy a string in an array.
+//
+
+void *                                 // O - Copy of string
+_cupsArrayStrdup(void *s,              // I - String to copy
+                 void *data)           // I - Callback data (unused)
+{
+  (void)data;
+
+  return (strdup((const char *)s));
+}
+
+
 //
 // 'cupsArrayUserData()' - Return the user data for an array.
 //
@@ -1253,43 +1311,3 @@ cups_array_find(cups_array_t *a, // I - Array
 
   return (current);
 }
-
-
-/*
- * '_cupsArrayStrcmp()' - Meant to be passed as a pointer to CUPS arrays instead
- * of strcmp. Will also work if called directly.
- */
-
-int _cupsArrayStrcmp(const char *s1, /* I - first string to compare */
-                     const char *s2, /* I - second string to compare */
-                     void *data)     /* Unused */
-{
-  (void)data;
-  return (strcmp(s1, s2));
-}
-
-
-/*
- * '_cupsArrayStrdup()' - Meant to be passed as a pointer to CUPS arrays instead
- * of strdup. Will also work if called directly.
- */
-
-char *_cupsArrayStrdup(const char *element, /* I - element to duplicate */
-                       void *data)          /* Unused */
-{
-  (void)data;
-  return (strdup(element));
-}
-
-
-/*
- * '_cupsArrayFree()' - Meant to be passed as a pointer to CUPS arrays instead
- * of free. Will also work if called directly.
- */
-
-void _cupsArrayFree(void *element, /* I - element to free */
-                    void *data)    /* Unused */
-{
-  (void)data;
-  free(element);
-}
index 0388cb15f61b7a47c8aa8fded04254d76ba2dfb7..7aa371ed491db85770eb2039929a8109455eb68b 100644 (file)
@@ -861,7 +861,7 @@ cupsOAuthGetDeviceGrant(
   char         *client_id = NULL,      // `client_id` value
                *scopes_supported = NULL;
                                        // Supported scopes
-  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  *grant = NULL;          // Device grant
index 966382238cd4119f79581785429fe79830384a9c..62178c13c8b8037f44675bedb597dd3dd3142a4b 100644 (file)
@@ -129,10 +129,10 @@ extern void       _cups_strcpy(char *dst, const char *src) _CUPS_PRIVATE;
 extern int     _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE;
 extern int     _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE;
 
-extern int     _cupsArrayStrcasecmp(const char *s, const char *t, void *data) _CUPS_PRIVATE;
-extern int     _cupsArrayStrcmp(const char *s1, const char *s2, void *data) _CUPS_PRIVATE;
-extern char    *_cupsArrayStrdup(const char *element, void *data) _CUPS_PRIVATE;
-extern void    _cupsArrayFree(void *element, void *data) _CUPS_PRIVATE;
+extern void    _cupsArrayFree(void *s, void *data) _CUPS_PRIVATE;
+extern int     _cupsArrayStrcasecmp(void *s, void *t, void *data) _CUPS_PRIVATE;
+extern int     _cupsArrayStrcmp(void *s, void *t, void *data) _CUPS_PRIVATE;
+extern void    *_cupsArrayStrdup(void *s, void *data) _CUPS_PRIVATE;
 
 extern char    *_cupsStrAlloc(const char *s) _CUPS_PRIVATE;
 extern char    *_cupsStrDate(char *buf, size_t bufsize, time_t timeval) _CUPS_PRIVATE;
index 615caadf022ee526c5c79ae8aaa7a927606eebb0..a3786da379c66d7c93eab8111ec40d89f57978b7 100644 (file)
@@ -30,7 +30,7 @@ static cups_array_t   *stringpool = NULL;
  * Local functions...
  */
 
-static int compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b, void *data);
+static int     compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b, void *data);
 static void    validate_end(char *s, char *end);
 
 
@@ -1162,17 +1162,3 @@ validate_end(char *s,                    // I - Pointer to start of string
     }
   }
 }
-
-
-/*
- * '_cupsArrayStrcasecmp()' - Compare two strings...
- */
-
-int /* O - Result of comparison */
-_cupsArrayStrcasecmp(const char *s, /* I - First string */
-                         const char *t, /* I - Second string */
-                         void *data)    /* I - Unused */
-{
-  (void)data;
-  return (_cups_strcasecmp(s, t));
-}
index bdf4413c371caa2836f570b2caca305f15150250..e67497d42cfcbb19faf2fe0d87e51416b11f109b 100644 (file)
@@ -1,7 +1,7 @@
 //
 // DNS-SD API test program for CUPS.
 //
-// Copyright © 2022-2024 by OpenPrinting.
+// Copyright © 2022-2025 by OpenPrinting.
 //
 // Licensed under Apache License v2.0.  See the file "LICENSE" for more
 // information.
@@ -10,6 +10,7 @@
 #include <config.h>
 #include "test-internal.h"
 #include "dnssd.h"
+#include "string-private.h"
 #include "thread.h"
 
 
@@ -60,14 +61,14 @@ main(int  argc,                             // I - Number of command-line arguments
 //  cups_dnssd_query_t *query;         // DNS-SD query request
   cups_dnssd_resolve_t *resolve;       // DNS-SD resolve request
   cups_dnssd_service_t *service;       // DNS-SD service registration
-  size_t               num_txt;        // Number of TXT record key/value pairs
+  int                  num_txt;        // Number of TXT record key/value pairs
   cups_option_t                *txt;           // TXT record key/value pairs
   testdata_t           testdata;       // Test data
 
 
   // Clear test data...
   memset(&testdata, 0, sizeof(testdata));
-  testdata.messages = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+  testdata.messages = cupsArrayNew3(NULL, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree);
 #if _WIN32
   snprintf(testdata.name, sizeof(testdata.name), "Test Service %d", (int)GetCurrentProcessId());
 #else
@@ -319,6 +320,9 @@ browse_print_cb(
                                        // Test data
 
 
+  (void)browse;
+  (void)flags;
+
   printf("%5u %s.%s.%s\n", if_index, name, regtype, domain);
 
   cupsMutexLock(&data->mutex);
index e849465abc4c5588b7f9a7f0cc60e22d1c0b3dbd..00b95d04980d3f59f99cad418daba55ba0c6debe 100644 (file)
@@ -5379,7 +5379,7 @@ msgstr ""
 
 #: cups/ppd.c:2017
 msgid "No"
-msgstr ""
+msgstr "Ні"
 
 #: cups/http-support.c:1349
 msgid "No Content"
@@ -7097,7 +7097,7 @@ msgstr ""
 
 #: cups/ppd.c:2015
 msgid "Yes"
-msgstr ""
+msgstr "Так"
 
 #: scheduler/client.c:2048
 msgid "You cannot access this page."
index f44b4779ec1d30b347090e02c707cdd84ca6c715..ccdd6f4289546a40e2a8a85fd7f64b2a794c3c68 100644 (file)
@@ -841,7 +841,7 @@ alloc_data(void)
   data->family       = AF_UNSPEC;
   data->def_transfer = IPPTOOL_TRANSFER_AUTO;
   data->def_version  = 20;
-  data->errors       = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
+  data->errors       = cupsArrayNew3(NULL, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree);
   data->pass         = true;
   data->prev_pass    = true;
   data->request_id   = (cupsGetRand() % 1000) * 137;
@@ -1933,7 +1933,7 @@ do_test(ipp_file_t     *f,                // I - IPP data file
              break;
        }
 
-       exp_errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
+       exp_errors = cupsArrayNew3(NULL, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree);
        exp_member = strchr(expect->name, '/') != NULL;
        exp_pass   = false;
 
@@ -6970,7 +6970,7 @@ with_distinct_values(
   }
 
   // Collect values and determine they are all unique...
-  values = cupsArrayNew3((cups_array_cb_t)_cupsArrayStrcmp, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
+  values = cupsArrayNew3((cups_array_cb_t)_cupsArrayStrcmp, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree);
 
   for (i = 0; i < count; i ++)
   {
index fe9f4e0179a26cb242c52697f3d17db37b49f26e..b7e1cd7581a74c731c8ba0ff25099af1e4e4ccfe 100644 (file)
                278C58E3136B647200836530 /* testhttp.c in Sources */ = {isa = PBXBuildFile; fileRef = 278C58E2136B647200836530 /* testhttp.c */; };
                279AE6F52395B80F004DD600 /* libpam.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 279AE6F42395B80F004DD600 /* libpam.tbd */; };
                27A034821A8BDC3A00650675 /* lpadmin.c in Sources */ = {isa = PBXBuildFile; fileRef = 2732E08D137A3F5200FAFEF6 /* lpadmin.c */; };
-               27A034851A8BDC5C00650675 /* libcups2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups2.dylib */; };
+               27A9AE9D2E85EEB200D3B3F6 /* libcups2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups2.dylib */; };
                27B493C22C8FC125004C7A73 /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2915B49110003F877F /* GSS.framework */; };
                27B493C32C8FC125004C7A73 /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2915B49110003F877F /* GSS.framework */; };
                27B493C42C8FC125004C7A73 /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72D53A2915B49110003F877F /* GSS.framework */; };
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               27A034851A8BDC5C00650675 /* libcups2.dylib in Frameworks */,
+                               27A9AE9D2E85EEB200D3B3F6 /* libcups2.dylib in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXProject;
                        attributes = {
                                BuildIndependentTargetsInParallel = YES;
-                               LastUpgradeCheck = 1600;
+                               LastUpgradeCheck = 2600;
                                ORGANIZATIONNAME = "Apple Inc.";
                                TargetAttributes = {
                                        270695FD1CADF3E200FFE5FB = {
                                        "-D_CUPS_SOURCE",
                                        "-Wno-shorten-64-to-32",
                                );
+                               STRING_CATALOG_GENERATE_SYMBOLS = YES;
                                USE_HEADERMAP = NO;
                                WARNING_CFLAGS = "-Wno-deprecated-declarations";
                        };
                                        "-D_CUPS_SOURCE",
                                        "-Wno-shorten-64-to-32",
                                );
+                               STRING_CATALOG_GENERATE_SYMBOLS = YES;
                                USE_HEADERMAP = NO;
                                WARNING_CFLAGS = "-Wno-deprecated-declarations";
                        };