]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gettext API users: don't explicitly cast ngettext()'s "n"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 7 Mar 2022 15:27:07 +0000 (16:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Mar 2022 19:57:52 +0000 (11:57 -0800)
Change a few stray users of the inline gettext.h Q_() function to stop
casting its "n" argument, the vast majority of the users of that
wrapper API use the implicit cast to "unsigned long".

The ngettext() function (which Q_() resolves to) takes an "unsigned
long int", and so does our Q_() wrapper for it, see 0c9ea33b90f (i18n:
add stub Q_() wrapper for ngettext, 2011-03-09). The function isn't
ours, but provided by e.g. GNU libintl.

This amends code added in added in 7171a0b0cf5 (index-pack: correct
"len" type in unpack_data(), 2016-07-13). The cast it added for the
printf format to die() was needed, but not the cast to Q_().

Likewise the casts in strbuf.c added in 8f354a1faed (l10n: localizable
upload progress messages, 2019-07-02) and for
builtin/merge-recursive.c in ccf7813139f (i18n: merge-recursive: mark
error messages for translation, 2016-09-15) weren't needed.

In the latter case the cast was copy/pasted from the argument to
warning() itself, added in b74d779bd90 (MinGW: Fix compiler warning in
merge-recursive, 2009-05-23). The cast for warning() is needed, but
not the one for ngettext()'s "n" argument.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
builtin/merge-recursive.c
strbuf.c

index c45273de3b124942553647ae0f216b4e6a3bb3d1..49c83d06f2a293743909cc7013f1ee27a8596b4f 100644 (file)
@@ -583,7 +583,7 @@ static void *unpack_data(struct object_entry *obj,
                if (!n)
                        die(Q_("premature end of pack file, %"PRIuMAX" byte missing",
                               "premature end of pack file, %"PRIuMAX" bytes missing",
-                              (unsigned int)len),
+                              len),
                            (uintmax_t)len);
                from += n;
                len -= n;
index a4bfd8fc51d6b26edda7a1c8afca4946f6ff485d..b9acbf5d3427e7dd88533351db5d2fc245cc25f6 100644 (file)
@@ -58,7 +58,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
                                   "Ignoring %s.",
                                   "cannot handle more than %d bases. "
                                   "Ignoring %s.",
-                                   (int)ARRAY_SIZE(bases)-1),
+                                   ARRAY_SIZE(bases)-1),
                                (int)ARRAY_SIZE(bases)-1, argv[i]);
        }
        if (argc - i != 3) /* "--" "<head>" "<remote>" */
index 00abeb55afdd68089676d2007fbfd248b5a45e79..dd9eb85527ab5a2f5007907b2cb3ce76ed5ccc3f 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -875,9 +875,9 @@ static void strbuf_humanise(struct strbuf *buf, off_t bytes,
                strbuf_addf(buf,
                                humanise_rate == 0 ?
                                        /* TRANSLATORS: IEC 80000-13:2008 byte */
-                                       Q_("%u byte", "%u bytes", (unsigned)bytes) :
+                                       Q_("%u byte", "%u bytes", bytes) :
                                        /* TRANSLATORS: IEC 80000-13:2008 byte/second */
-                                       Q_("%u byte/s", "%u bytes/s", (unsigned)bytes),
+                                       Q_("%u byte/s", "%u bytes/s", bytes),
                                (unsigned)bytes);
        }
 }