Re: Compile warning for CX18 / v4l2-common Ubuntu 8.10

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2009-01-17 at 07:34 -0500, Brandon Jenkins wrote:
> A pull from v4l-dvb today:
> 
> Kernel build directory is /lib/modules/2.6.27-7-generic/build
> make -C /lib/modules/2.6.27-7-generic/build
> SUBDIRS=/root/drivers/v4l-dvb/v4l  modules
> make[2]: Entering directory `/usr/src/linux-headers-2.6.27-7-generic'
> ...
> /opt/drivers/v4l-dvb/v4l/cx18-driver.c: In function 'cx18_request_module':
> /opt/drivers/v4l-dvb/v4l/cx18-driver.c:735: warning: format not a
> string literal and no format arguments
> 
>   CC [M]  /root/drivers/v4l-dvb/v4l/v4l2-common.o
> /root/drivers/v4l-dvb/v4l/v4l2-common.c: In function 'v4l2_ctrl_query_fill':
> /root/drivers/v4l-dvb/v4l/v4l2-common.c:559: warning: format not a
> string literal and no format arguments
> /root/drivers/v4l-dvb/v4l/v4l2-common.c: In function 'v4l2_ctrl_query_menu':
> /root/drivers/v4l-dvb/v4l/v4l2-common.c:724: warning: format not a
> string literal and no format arguments
> /root/drivers/v4l-dvb/v4l/v4l2-common.c: In function
> 'v4l2_ctrl_query_menu_valid_items':
> /root/drivers/v4l-dvb/v4l/v4l2-common.c:742: warning: format not a
> string literal and no format arguments
> /root/drivers/v4l-dvb/v4l/v4l2-common.c: In function 'v4l2_i2c_new_subdev':
> /root/drivers/v4l-dvb/v4l/v4l2-common.c:947: warning: format not a
> string literal and no format arguments
> /root/drivers/v4l-dvb/v4l/v4l2-common.c: In function
> 'v4l2_i2c_new_probed_subdev':
> /root/drivers/v4l-dvb/v4l/v4l2-common.c:1008: warning: format not a
> string literal and no format arguments

First, they are just warnings, so everything still builds right?

Second, yes these calls appear to be mildly abusing the format argument
of snprintf() and request_module().  These are declared as


extern int snprintf(char * buf, size_t size, const char * fmt, ...)
        __attribute__ ((format (printf, 3, 4)));

extern int request_module(const char * name, ...) __attribute__ ((format
(printf, 1, 2)));


Note the attribute flag that tells the compiler it may want to do some
extra checking of the arguments - they are like printf()'s arguments.
The "problem" is that we're not calling them like printf() should be
called.

With a "char *" variable "foo", we do something like

	printf(foo);

instead of 

	printf("%s", foo);

which is what the warnings are griping about.  The __attribute__ is
telling the compiler that the format argument should be string constant.

For the cx18 module, one should be able to make it go away with:

diff -r 262c623d8a28 linux/drivers/media/video/cx18/cx18-driver.c
--- a/linux/drivers/media/video/cx18/cx18-driver.c	Sat Jan 17 08:59:31 2009 -0500
+++ b/linux/drivers/media/video/cx18/cx18-driver.c	Sat Jan 17 09:30:28 2009 -0500
@@ -733,7 +733,7 @@
 {
 	if ((hw & id) == 0)
 		return hw;
-	if (request_module(name) != 0) {
+	if (request_module("%s", name) != 0) {
 		CX18_ERR("Failed to load module %s\n", name);
 		return hw & ~id;
 	}


Signed-off-by: Andy Walls <awalls@xxxxxxxxx>

Please test as an SOB line doesn't mean that the patch compiles or
works. ;)   I don't normally get those warnings so my setup may be a
little different/lax.

Regards,
Andy


> Thanks,
> 
> Brandon


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux