On 06/10/2013 05:05 PM, Guan Nan Ren wrote: > I have been trying to fix this bug these days, but I failed to find a good way > to bypass the warning you mentioned above caused by a gcc bug: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28492 > > I can not find a better way than the casting in your code to compress the warning. > other than this, there are some points needed to pay attention. > 1, the log string output from udev ends with newline character which we could remove. Yes that would be nice. > 2, we can use debug mode for these logs. Or we could use the message priority libudev gave us. > > The following is the code with my code squashed in your casting code to fix this bug > > diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c > index 620cd58..dc989e9 100644 > --- a/src/node_device/node_device_udev.c > +++ b/src/node_device/node_device_udev.c > @@ -348,15 +348,32 @@ static int udevGenerateDeviceName(struct udev_device *device, > } > > > -static void udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED, > - int priority ATTRIBUTE_UNUSED, > - const char *file, > - int line, > - const char *fn, > - const char *fmt, > - va_list args) > +typedef void (*udevLogFunctionPtr)(struct udev *udev, > + int priority, > + const char *file, > + int line, > + const char *fn, > + const char *format, > + va_list args); > + > +static void > +ATTRIBUTE_FMT_PRINTF(6,0) > +udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED, > + int priority ATTRIBUTE_UNUSED, > + const char *file ATTRIBUTE_UNUSED, > + int line ATTRIBUTE_UNUSED, > + const char *fn ATTRIBUTE_UNUSED, You're ignoring priority, file, line and fn. I think those might be useful. I'll send another version. > + const char *fmt, > + va_list args) > { > - VIR_ERROR_INT(VIR_LOG_FROM_LIBRARY, file, line, fn, fmt, args); > + char *eol = NULL; > + char buffer[LINE_MAX]; > + vsnprintf(buffer, sizeof(buffer), fmt, args); > + > + if ((eol = strpbrk(buffer, "\n\r"))) > + *(eol++) = 0; > + > + VIR_DEBUG("%s", buffer); > } > Jan -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list