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)
Fri, Apr 26, 6:28 AM
Unknown Object (File)
Fri, Apr 26, 6:28 AM
Unknown Object (File)
Fri, Apr 26, 4:04 AM
Unknown Object (File)
Thu, Apr 25, 9:31 PM
Unknown Object (File)
Jan 14 2024, 6:18 AM
Unknown Object (File)
Dec 20 2023, 8:39 AM
Unknown Object (File)
Nov 12 2023, 9:25 AM
Unknown Object (File)
Nov 10 2023, 3:45 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.