Skip to content

enable -Wformat #378

Closed
Closed
@nickdesaulniers

Description

@nickdesaulniers

A previous attempt at re-enabling -Wformat showed that there were LOTS of instances of this warning throughout the codebase. Simply re-applying that patch and doing an arm64 defconfig, I experienced 236 unique instances of this warning. Similar to @kees ' work enabling -Wvla, I'd like to find and fix all of these, then re-send the patch re-enabling the warning.

Assuming these aren't false positives, I think the only tricky cases we may encounter may come from config dependent types. ex.

#ifdef CONFIG_FOO
int bar = 0;
#else 
float bar = 0;
#endif 
printk("bar: %d\n"); // warning: format specifies type 'int' but the argument has type 'float' [-Wformat]

which can be fixed via:

+prink("bar: "
+#ifdef CONFIG_FOO
+    "%d"
+#else
+    "%f"
+#endif
+    "\n");
-printk("bar: %d\n");

(or whatever maintainers prefer). I don't expect many of those cases, but maybe I'm mistaken.

Also (meta), usually we file individual issues, but maybe it's better to use this one lone issue to track all the instances? (not sure; open to thoughts).

Also, let's find a way to split the work? And keep each other cc'ed when sending patches? (we should probably set up a mailing list to always cc for patches related to Clang Built Linux)

Metadata

Metadata

Labels

-WformatReported upstreamThis bug was filed on LLVM’s issue tracker, Phabricator, or the kernel mailing list.[BUG] linuxA bug that should be fixed in the mainline kernel.[FIXED][LINUX] 6.0This bug was fixed in Linux 6.0enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions