From: Ævar Arnfjörð Bjarmason Date: Tue, 13 Jul 2021 08:05:21 GMT Subject: [PATCH v2 6/6] strbuf.h: add a comment about "missing" strftime() checking Message-ID: In-Reply-To: We've recently added missing __attribute__((format)) checking of printf formats in various places, but in the case of strbuf_addftime() we've intentionally omitted adding an: __attribute__((format (strftime, 2, 0))) There was a proposed change[1] to do that, but I agree that it's not worth it, see e.g. [2] for the rationale. Let's add a comment to note this. 1. http://lore.kernel.org/git/patch-4.6-3bf8637c16a-20210710T084445Z-avarab@gmail.com 2. https://lore.kernel.org/git/YOyhd%2FodtQxwQk2W@coredump.intra.peff.net/ Signed-off-by: Ævar Arnfjörð Bjarmason --- strbuf.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/strbuf.h b/strbuf.h index f1e9821a54..04952e94c4 100644 --- a/strbuf.h +++ b/strbuf.h @@ -425,6 +425,12 @@ void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap); * with modifiers (e.g. %Ez) are passed to `strftime`. * `suppress_tz_name`, when set, expands %Z internally to the empty * string rather than passing it to `strftime`. + * + * Note: The omission of "__attribute__((format (strftime, [...])))" + * is intentional. As noted above we take %z and %Z which aren't + * portable. It would "work" anyway on modern compilers, but since + * this is mainly used in date.c (via"git log --date=") we + * don't have any constant formats to check. */ void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm, int tz_offset, -- 2.32.0-dev