From: Bruno Haible Date: Fri, 2 Jun 2023 23:30:59 +0000 (+0200) Subject: Silence -Wformat warnings regarding 'int' vs. 'unsigned int' arguments. X-Git-Tag: v0.22~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32a4a7f1d7899422f0dd5511a0c43727315f88a0;p=thirdparty%2Fgettext.git Silence -Wformat warnings regarding 'int' vs. 'unsigned int' arguments. * 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'. --- diff --git a/gettext-tools/src/read-catalog-abstract.c b/gettext-tools/src/read-catalog-abstract.c index aa17eddf8..17ed4602e 100644 --- a/gettext-tools/src/read-catalog-abstract.c +++ b/gettext-tools/src/read-catalog-abstract.c @@ -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 @@ -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)); } diff --git a/gettext-tools/src/read-properties.c b/gettext-tools/src/read-properties.c index 5ae010b54..c5ef74cad 100644 --- a/gettext-tools/src/read-properties.c +++ b/gettext-tools/src/read-properties.c @@ -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 , 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 () diff --git a/gettext-tools/src/write-java.c b/gettext-tools/src/write-java.c index 970aae6f0..7c62effb2 100644 --- a/gettext-tools/src/write-java.c +++ b/gettext-tools/src/write-java.c @@ -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 , 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"); diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index a329f3dd8..33c6d76f0 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -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 (); }