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)
Wed, Mar 25, 3:30 AM
Unknown Object (File)
Tue, Mar 24, 6:27 PM
Unknown Object (File)
Mon, Mar 23, 7:17 AM
Unknown Object (File)
Mon, Mar 23, 1:51 AM
Unknown Object (File)
Mon, Mar 23, 12:42 AM
Unknown Object (File)
Sun, Mar 15, 9:42 PM
Unknown Object (File)
Mon, Mar 9, 3:30 PM
Unknown Object (File)
Sun, Mar 1, 8:39 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.