Page MenuHomeFreeBSD

clang: Reject %n for __attribute__((format(__freebsd_kprintf__)))
ClosedPublic

Authored by cem on May 9 2020, 5:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 25, 11:01 PM
Unknown Object (File)
Tue, Jul 21, 2:09 AM
Unknown Object (File)
Sat, Jul 18, 1:03 PM
Unknown Object (File)
Thu, Jul 9, 3:30 PM
Unknown Object (File)
Wed, Jul 8, 7:17 PM
Unknown Object (File)
May 20 2026, 12:27 AM
Unknown Object (File)
Apr 29 2026, 10:37 PM
Unknown Object (File)
Apr 29 2026, 10:35 PM
Subscribers
None

Details

Summary

A follow-up to r360849.

Reported by: imp

Test Plan

Seems to work:

/home/conrad/a.c:94:21: warning: invalid conversion specifier 'n' [-Wformat-invalid-specifier]
        my_kprintflike("2 %n %s\n", &loops, "not ok");
                          ~^

a.c:

extern void
my_kprintflike(const char *s, ...) __attribute__((__format__(__freebsd_kprintf__, 1, 2)));

int main(int argc, char **argv)
{

        my_kprintflike("1 %s\n", "ok");
        my_kprintflike("2 %n %s\n", &loops, "not ok");
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

cem requested review of this revision.May 9 2020, 5:53 PM
cem created this revision.

Sounds good to me, we'll want to submit this upstream with a test case.

This revision is now accepted and ready to land.May 9 2020, 6:21 PM

Sounds good to me, we'll want to submit this upstream with a test case.

Hm, unfortunately our contrib version of LLVM excludes the test subdirectories, so I can't easily add a test case here. I expect it would be easy for someone with an existing upstream relationship with LLVM to write one.

Love it. Easy to upstream.