Page MenuHomeFreeBSD

riscv: Don't use the '#' modifier with '%b'
AcceptedPublic

Authored by jhb on Fri, Jan 30, 3:06 PM.
Tags
None
Referenced Files
F143684298: D54966.diff
Sat, Jan 31, 6:34 AM
F143644088: D54966.id170779.diff
Sat, Jan 31, 3:50 AM
F143591155: D54966.id.diff
Sat, Jan 31, 12:22 AM
F143568292: D54966.diff
Fri, Jan 30, 10:52 PM
Subscribers

Details

Reviewers
mhorne
jrtc27
Summary

This is not documented as a valid modifier in printf(9) and GCC at
least warns about the combination being invalid. By my reading, clang
should also be warning (PrintfSpecifier::hasValidAlternativeForm
returns false for FreeBSDbArg) but apparently isn't.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70237
Build 67120: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Fri, Jan 30, 3:06 PM

I have no idea why clang fails to warn about this as I noted in the commit log. OTOH, if we want to make '%#b' a real thing, we need to document it in the manpage and fix both compilers to intentionally (vs accidentally) accept it.

In D54966#1256747, @jhb wrote:

I have no idea why clang fails to warn about this as I noted in the commit log. OTOH, if we want to make '%#b' a real thing, we need to document it in the manpage and fix both compilers to intentionally (vs accidentally) accept it.

I thought someone else was working on more %b for FreeBSD; or at least 64bit %b argument support. Was it @tuexen? I'd be happy to %#b supported :)

In D54966#1256752, @bz wrote:
In D54966#1256747, @jhb wrote:

I have no idea why clang fails to warn about this as I noted in the commit log. OTOH, if we want to make '%#b' a real thing, we need to document it in the manpage and fix both compilers to intentionally (vs accidentally) accept it.

I thought someone else was working on more %b for FreeBSD; or at least 64bit %b argument support. Was it @tuexen? I'd be happy to %#b supported :)

\# isn't about what (length) it's about how ("alternate format"). 64-bit %b is called %l[l]b, provided compilers are told length modifiers are valid for %b.

mhorne added inline comments.
sys/riscv/riscv/identcpu.c
593

May as well retain this as it does actually work.

This revision is now accepted and ready to land.Fri, Jan 30, 5:04 PM
In D54966#1256752, @bz wrote:
In D54966#1256747, @jhb wrote:

I have no idea why clang fails to warn about this as I noted in the commit log. OTOH, if we want to make '%#b' a real thing, we need to document it in the manpage and fix both compilers to intentionally (vs accidentally) accept it.

I thought someone else was working on more %b for FreeBSD; or at least 64bit %b argument support. Was it @tuexen? I'd be happy to %#b supported :)

I want to use %lb and %llb in the kernel. clang warns about this but it works when you disable warnings. Teaching clang that FreeBSD supports %b with a length modified in the kernel context is still on my todo list... Once that is in, I plan do document that in printf.9.