Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1552427 > unrolled thread
| Started by | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| First post | 2017-01-06 01:40 +0100 |
| Last post | 2017-01-09 23:20 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] lib/vsprintf.c: remove %Z support Andrew Morton <akpm@linux-foundation.org> - 2017-01-06 01:40 +0100
[PATCH] checkpatch.pl: warn against using %Z Alexey Dobriyan <adobriyan@gmail.com> - 2017-01-09 23:10 +0100
Re: [PATCH] checkpatch.pl: warn against using %Z Joe Perches <joe@perches.com> - 2017-01-09 23:20 +0100
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2017-01-06 01:40 +0100 |
| Subject | Re: [PATCH] lib/vsprintf.c: remove %Z support |
| Message-ID | <sWqJz-2cg-1@gated-at.bofh.it> |
On Wed, 4 Jan 2017 02:01:27 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote: > Now that %z is standartised in C99 there is no reason to support %Z. > Unlike %L it doesn't even make format strings smaller. > > Use BUILD_BUG_ON in a couple ATM drivers. > > In case anyone didn't notice lib/vsprintf.o is about half of SLUB > which is in my opinion is quite an achievement. Hopefully this patch > inspires someone else to trim vsprintf.c more. There's a risk that more %Z uses will sneak into the tree during the 4.10 development cycle, and possibly even later. So I added a note-to-self to re-grep the tree before sending this upstream, but that won't prevent people adding new instances later on: code which was tested under earlier kernels which has %Z support. The best suggestion I have is to add a checkpatch rule to try to catch new %Z's being added.
[toc] | [next] | [standalone]
| From | Alexey Dobriyan <adobriyan@gmail.com> |
|---|---|
| Date | 2017-01-09 23:10 +0100 |
| Subject | [PATCH] checkpatch.pl: warn against using %Z |
| Message-ID | <sXQiB-1l8-23@gated-at.bofh.it> |
| In reply to | #1552427 |
%Z is going to be removed in favour of %z.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5189,6 +5189,12 @@ sub process {
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
last;
}
+ # check for %Z
+ if ($string =~ /(?<!%)%[\*\d\.\$]*Z[diouxX]/) {
+ WARN("PRINTF_Z",
+ "%Z is non-standard C, use %z\n" . $herecurr);
+ last;
+ }
if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
ERROR("PRINTF_0xDECIMAL",
"Prefixing 0x with decimal output is defective\n" . $herecurr);
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-01-09 23:20 +0100 |
| Subject | Re: [PATCH] checkpatch.pl: warn against using %Z |
| Message-ID | <sXQsi-1ot-21@gated-at.bofh.it> |
| In reply to | #1554748 |
On Tue, 2017-01-10 at 02:59 +0300, Alexey Dobriyan wrote:
> %Z is going to be removed in favour of %z.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>
> scripts/checkpatch.pl | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5189,6 +5189,12 @@ sub process {
> "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
> last;
> }
> + # check for %Z
> + if ($string =~ /(?<!%)%[\*\d\.\$]*Z[diouxX]/) {
> + WARN("PRINTF_Z",
> + "%Z is non-standard C, use %z\n" . $herecurr);
> + last;
> + }
> if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
> ERROR("PRINTF_0xDECIMAL",
> "Prefixing 0x with decimal output is defective\n" . $herecurr);
Right concept, slightly incorrect implementation.
diouxX isn't necessary, ?<!% isn't necessary either as
there's a s/%%/__/g above it, last; probably isn't a
good idea as a single string could have both %Lu and
%Zu and unrelated, thanks for reminding me, I knew but
forgot to fix, the PRINTF_0xDECIMAL is defective as
there's a requirement that the match string only use
upper case.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web