From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Taylor Blau" <me@ttaylorr.com>,
"Derrick Stolee" <derrickstolee@github.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 1/2] gettext API users: don't explicitly cast ngettext()'s "n"
Date: Mon, 7 Mar 2022 16:27:07 +0100 [thread overview]
Message-ID: <patch-v2-1.2-83fd21741ad-20220307T152316Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.2-00000000000-20220307T152316Z-avarab@gmail.com>
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>
---
builtin/index-pack.c | 2 +-
builtin/merge-recursive.c | 2 +-
strbuf.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 3c2e6aee3cc..89339e83a0d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -579,7 +579,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;
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index a4bfd8fc51d..b9acbf5d342 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -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>" */
diff --git a/strbuf.c b/strbuf.c
index 00abeb55afd..dd9eb85527a 100644
--- 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);
}
}
--
2.35.1.1242.gfeba0eae32b
next prev parent reply other threads:[~2022-03-07 15:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 11:37 [PATCH 0/2] string-list.h: make "nr" and "alloc" a "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 11:38 ` [PATCH 1/2] gettext API users: correct use of casts for Q_() Ævar Arnfjörð Bjarmason
2022-03-07 13:41 ` Derrick Stolee
2022-03-07 13:54 ` Ævar Arnfjörð Bjarmason
2022-03-07 15:53 ` Derrick Stolee
2022-03-07 11:38 ` [PATCH 2/2] string-list API: change "nr" and "alloc" to "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 13:43 ` Derrick Stolee
2022-03-07 14:10 ` Ævar Arnfjörð Bjarmason
2022-03-07 15:27 ` [PATCH v2 0/2] string-list.h: make "nr" and "alloc" a "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 15:27 ` Ævar Arnfjörð Bjarmason [this message]
2022-03-07 15:27 ` [PATCH v2 2/2] string-list API: change "nr" and "alloc" to "size_t" Ævar Arnfjörð Bjarmason
2022-03-07 16:23 ` Philip Oakley
2022-03-07 20:43 ` Junio C Hamano
2022-03-07 23:34 ` Philip Oakley
2022-03-07 15:55 ` [PATCH v2 0/2] string-list.h: make "nr" and "alloc" a "size_t" Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v2-1.2-83fd21741ad-20220307T152316Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).