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, Oct 26, 4:19 PM
Unknown Object (File)
Sat, Oct 26, 4:18 PM
Unknown Object (File)
Sat, Oct 26, 4:18 PM
Unknown Object (File)
Sat, Oct 26, 3:58 PM
Unknown Object (File)
Tue, Oct 22, 8:44 AM
Unknown Object (File)
Oct 4 2024, 3:19 PM
Unknown Object (File)
Sep 30 2024, 1:38 AM
Unknown Object (File)
Sep 30 2024, 1:37 AM
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.