[libhid-discuss] libhid gcc Werror patch

Vlatko Kosturjak vlatko.kosturjak at gmail.com
Sun Aug 26 09:00:01 UTC 2012


Hello,

This is patch for libhid so gcc doesn't stop on error if Werror is used:

Problem:
======
gcc -DHAVE_CONFIG_H -I. -I..   -DNDEBUG -I../include -I../hidparser -O2
-Wall -W -Werror -MT lshid.o -MD -MP -MF .deps/lshid.Tpo -c -o lshid.o
lshid.c
lshid.c: In function <E2><80><98>device_iterator<E2><80><99>:
lshid.c:32:87: error: parameter <E2><80><98>len<E2><80><99> set but not
used [-Werror=unused-but-set-parameter]
cc1: all warnings being treated as errors

Patch:
=====
--- lshid.c 2012-08-26 10:54:29.671277650 +0200
+++ lshid.c.mod 2012-08-26 10:54:18.007988938 +0200
@@ -29,6 +29,9 @@

 struct usb_dev_handle;

+/* unused parameter - don't give error on that warning */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
 bool device_iterator (struct usb_dev_handle const* usbdev, void* custom,
unsigned int len)
 {
   bool ret = false;
@@ -36,10 +39,6 @@
   char current_dev_path[10];
   const struct usb_device *device = usb_device((struct usb_dev_handle
*)usbdev);

-  /* only here to prevent the unused warning */
-  /* TODO remove */
-  len = *((unsigned long*)custom);
-
   /* Obtain the device's full path */
   //sprintf(current_dev_path, "%s/%s", usbdev->bus->dirname,
usbdev->device->filename);
   sprintf(current_dev_path, "%s/%s", device->bus->dirname,
device->filename);
@@ -72,6 +71,7 @@

   return ret;
 }
+#pragma GCC diagnostic pop

 int main(void)
 {

Hope it helps,
-- 
Vlatko Kosturjak, Kost
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20120826/7ae8af64/attachment.html>


More information about the libhid-discuss mailing list