Thread (33 messages) 33 messages, 11 authors, 2022-07-11

RE: [PATCH 00/12] Clang -Wformat warning fixes

From: Jan Engelhardt <hidden>
Date: 2022-06-10 09:25:54
Also in: alsa-devel, linux-acpi, linux-edac, linux-mm, lkml, llvm, netfilter-devel

On Friday 2022-06-10 11:14, David Laight wrote:
quoted
quoted
Yep, IMHO definitely should be fixed.
It is even possible that using "%s" is faster because the printf
code doesn't have to scan the string for format effectors.
I see no special handling; the vsnprintf function just loops
over fmt as usual and I see no special casing of fmt by
e.g. strcmp(fmt, "%s") == 0 to take a shortcut.
Consider the difference between:
printf("fubar");
and
printf("%s", "fubar");
In the former all of "fubar" is checked for '%'.
In the latter only the length of "fubar" has to be counted.
To check the length of "fubar", printf first needs to know that there
even is an argument to be pulled from the stack, which it does by
evaluating the format string.

So, in fairness, it's more like:

 >> In the latter, all of "%s" is checked for '%'.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help