[PATCH]: Cleanup: Remove trivial gcc format string warnings when compiling with -Wformat-security (part 3: verified code)

From: Floris Kraak
Date: Tue Feb 10 2009 - 08:49:33 EST


On Tue, Feb 10, 2009 at 2:26 PM, Floris Kraak <randakar@xxxxxxxxx> wrote:
> On Thu, Feb 5, 2009 at 3:41 PM, Floris Kraak <randakar@xxxxxxxxx> wrote:
>>
>> Here's the patch that I get when I blindly patch every single location
>> that emits this warning.
>>
>> If needed I can attempt to split this monster into 135 patches but
>> given my limited experience with the tools involved a little help on
>> how to go about creating such a series would be appreciated ;-)
>>
>
> Here's the first part of a split series of patches dealing with this.
> I will reply to this message with further patches in the series.
>

This patch contains changes that have been verified / acked by
responsible kernel devs.
Right now that list is limited to a single dev & driver - in this case
no bug beyond surpressing the warning is fixed.

---
[PATCH]: Cleanup: Remove trivial gcc format string warnings when
compiling with -Wformat-security (part 3: verified code)

When compiling the kernel with an allyesconfig and the gcc flags
-Wformat and -Wformat-security the build process emits ~150 warnings
along these lines:

init/main.c:557: warning: format not a string literal and no format arguments
init/initramfs.c:582: warning: format not a string literal and no
format arguments
arch/x86/kernel/dumpstack.c:115: warning: format not a string literal
and no format arguments
...

Many of these warnings are harmless - the format string is statically
set within the kernel itself and is known to not contain any format
qualifiers.
This patch contains changes to the pvrusb2 driver.

Signed-off-by: Floris Kraak <randakar@xxxxxxxxx>
Acked-by: Mike Isely <isely@xxxxxxxxx>
---
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index fa304e5..42ccab0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1967,7 +1967,7 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
if (!pvr2_hdw_dev_ok(hdw)) return;

for (idx = 0; idx < hdw->hdw_desc->client_modules.cnt; idx++) {
- request_module(hdw->hdw_desc->client_modules.lst[idx]);
+ request_module("%s", hdw->hdw_desc->client_modules.lst[idx]);
}

if (!hdw->hdw_desc->flag_no_powerup) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.c
b/drivers/media/video/pvrusb2/pvrusb2-std.c
index ca9f83a..c18091e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-std.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-std.c
@@ -216,7 +216,7 @@ unsigned int pvr2_std_id_to_str(char *bufPtr,
unsigned int bufSize,
bufSize -= c2;
bufPtr += c2;
c2 = scnprintf(bufPtr,bufSize,
- ip->name);
+ "%s", ip->name);
c1 += c2;
bufSize -= c2;
bufPtr += c2;

---
Regards,
Floris
---
"They that give up essential liberty to obtain temporary safety,
deserve neither liberty nor safety."
-- Ben Franklin

"The course of history shows that as a government grows, liberty
decreases."
-- Thomas Jefferson
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/