]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Silence -Wformat warnings regarding 'int' vs. 'unsigned int' arguments.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:30:59 +0000 (01:30 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Jun 2023 13:54:10 +0000 (15:54 +0200)
* gettext-tools/src/read-catalog-abstract.c (catalog_reader_parse): Use %u
instead of %d in format string.
* gettext-tools/src/read-properties.c (UTF16_VALUE): Cast result to
'unsigned short'.
* gettext-tools/src/write-java.c (write_lookup_code,
write_java2_init_statements, write_java_code): Use %u instead of %d in format
strings.
* gettext-tools/src/x-perl.c (extract_balanced): Cast enum-typed fprintf
argument to 'int'.

gettext-tools/src/read-catalog-abstract.c
gettext-tools/src/read-properties.c
gettext-tools/src/write-java.c
gettext-tools/src/x-perl.c

index aa17eddf83df6891453fe933cc3a8516fc284086..17ed4602e93a691ff8e6285533f8938320b7c723 100644 (file)
@@ -1,6 +1,5 @@
 /* Reading PO files, abstract class.
-   Copyright (C) 1995-1996, 1998, 2000-2009, 2013, 2015, 2021 Free Software
-   Foundation, Inc.
+   Copyright (C) 1995-1996, 1998, 2000-2009, 2013, 2015, 2021, 2023 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -184,8 +183,8 @@ catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp,
   if (error_message_count > 0)
     po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
                /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1), false,
-               xasprintf (ngettext ("found %d fatal error",
-                                    "found %d fatal errors",
+               xasprintf (ngettext ("found %u fatal error",
+                                    "found %u fatal errors",
                                     error_message_count),
                           error_message_count));
 }
index 5ae010b542b6d2e29e9cccea8dd9ce8888557a9c..c5ef74cadf5339ff131262e6d2c7694e945f4779 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading Java .properties files.
-   Copyright (C) 2003, 2005-2007, 2009, 2018, 2020 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005-2007, 2009, 2018, 2020, 2023 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -313,7 +313,7 @@ conv_from_java (char *string)
 #define IS_UNICODE(p4_result) ((p4_result) >= 0x10000)
 
 /* Extract the UTF-16 code of a return value that satisfies IS_UNICODE.  */
-#define UTF16_VALUE(p4_result) ((p4_result) - 0x10000)
+#define UTF16_VALUE(p4_result) ((unsigned short) ((p4_result) - 0x10000))
 
 static int
 phase4_getuc ()
index 970aae6f08a9ef0922be1c8be54231db23104213..7c62effb28e6532528182daa973e3a4c02167b84 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing Java ResourceBundles.
-   Copyright (C) 2001-2003, 2005-2010, 2014, 2016, 2018-2020 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2010, 2014, 2016, 2018-2020, 2023 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -468,7 +468,7 @@ static void
 write_lookup_code (FILE *stream, unsigned int hashsize, bool collisions)
 {
   fprintf (stream, "    int hash_val = msgid.hashCode() & 0x7fffffff;\n");
-  fprintf (stream, "    int idx = (hash_val %% %d) << 1;\n", hashsize);
+  fprintf (stream, "    int idx = (hash_val %% %u) << 1;\n", hashsize);
   if (collisions)
     {
       fprintf (stream, "    {\n");
@@ -478,12 +478,12 @@ write_lookup_code (FILE *stream, unsigned int hashsize, bool collisions)
       fprintf (stream, "      if (msgid.equals(found))\n");
       fprintf (stream, "        return table[idx + 1];\n");
       fprintf (stream, "    }\n");
-      fprintf (stream, "    int incr = ((hash_val %% %d) + 1) << 1;\n",
+      fprintf (stream, "    int incr = ((hash_val %% %u) + 1) << 1;\n",
                hashsize - 2);
       fprintf (stream, "    for (;;) {\n");
       fprintf (stream, "      idx += incr;\n");
-      fprintf (stream, "      if (idx >= %d)\n", 2 * hashsize);
-      fprintf (stream, "        idx -= %d;\n", 2 * hashsize);
+      fprintf (stream, "      if (idx >= %u)\n", 2 * hashsize);
+      fprintf (stream, "        idx -= %u;\n", 2 * hashsize);
       fprintf (stream, "      java.lang.Object found = table[idx];\n");
       fprintf (stream, "      if (found == null)\n");
       fprintf (stream, "        return null;\n");
@@ -747,10 +747,10 @@ write_java2_init_statements (FILE *stream, message_list_ty *mlp,
     {
       const struct table_item *ti = &table_items[j];
 
-      fprintf (stream, "    t[%d] = ", 2 * ti->index);
+      fprintf (stream, "    t[%u] = ", 2 * ti->index);
       write_java_msgid (stream, ti->mp);
       fprintf (stream, ";\n");
-      fprintf (stream, "    t[%d] = ", 2 * ti->index + 1);
+      fprintf (stream, "    t[%u] = ", 2 * ti->index + 1);
       write_java_msgstr (stream, ti->mp);
       fprintf (stream, ";\n");
     }
@@ -836,7 +836,7 @@ write_java_code (FILE *stream, const char *class_name, message_list_ty *mlp,
               }
           }
         fprintf (stream, "  static {\n");
-        fprintf (stream, "    %s[] t = new %s[%d];\n", table_eltype,
+        fprintf (stream, "    %s[] t = new %s[%u];\n", table_eltype,
                  table_eltype, 2 * hashsize);
         if (mlp->nitems > max_items_per_method)
           {
@@ -904,14 +904,14 @@ write_java_code (FILE *stream, const char *class_name, message_list_ty *mlp,
       fprintf (stream, "    return\n");
       fprintf (stream, "      new java.util.Enumeration() {\n");
       fprintf (stream, "        private int idx = 0;\n");
-      fprintf (stream, "        { while (idx < %d && table[idx] == null) idx += 2; }\n",
+      fprintf (stream, "        { while (idx < %u && table[idx] == null) idx += 2; }\n",
                2 * hashsize);
       fprintf (stream, "        public boolean hasMoreElements () {\n");
-      fprintf (stream, "          return (idx < %d);\n", 2 * hashsize);
+      fprintf (stream, "          return (idx < %u);\n", 2 * hashsize);
       fprintf (stream, "        }\n");
       fprintf (stream, "        public java.lang.Object nextElement () {\n");
       fprintf (stream, "          java.lang.Object key = table[idx];\n");
-      fprintf (stream, "          do idx += 2; while (idx < %d && table[idx] == null);\n",
+      fprintf (stream, "          do idx += 2; while (idx < %u && table[idx] == null);\n",
                2 * hashsize);
       fprintf (stream, "          return key;\n");
       fprintf (stream, "        }\n");
index a329f3dd8fd7ee0b1218c70d2c3759258452f0ce..33c6d76f0b090b2d64a4c4522fe59c5bd9f71021 100644 (file)
@@ -3607,7 +3607,7 @@ extract_balanced (message_list_ty *mlp,
 
         default:
           fprintf (stderr, "%s:%d: unknown token type %d\n",
-                   real_file_name, tp->line_number, tp->type);
+                   real_file_name, tp->line_number, (int) tp->type);
           abort ();
         }