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
F150901834: D24786.diff
Sat, Apr 4, 8:17 PM
F150866881: D24786.diff
Sat, Apr 4, 2:24 PM
F150768902: D24786.id71595.diff
Fri, Apr 3, 10:37 PM
F150765370: D24786.diff
Fri, Apr 3, 10:04 PM
Unknown Object (File)
Thu, Apr 2, 1:02 AM
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
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

Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 31006
Build 28712: arc lint + arc unit

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.