Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Oct 2019 14:58:17 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r338679 - head/lib/libusb
Message-ID:  <176b6c74-947c-0e0e-6568-effcfac9cd8f@selasky.org>
In-Reply-To: <CACNAnaHeNc74Mvsp6Nxi4PvPYxRQW=w30i26OhC%2B42_YBf8-WQ@mail.gmail.com>
References:  <201809141341.w8EDfbtO070815@repo.freebsd.org> <CACNAnaHeNc74Mvsp6Nxi4PvPYxRQW=w30i26OhC%2B42_YBf8-WQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2019-10-02 14:55, Kyle Evans wrote:
> On Fri, Sep 14, 2018 at 8:41 AM Hans Petter Selasky
> <hselasky@freebsd.org> wrote:
>>
>> Author: hselasky
>> Date: Fri Sep 14 13:41:37 2018
>> New Revision: 338679
>> URL: https://svnweb.freebsd.org/changeset/base/338679
>>
>> Log:
>>    Improve LibUSB debugging by simultaneously allowing both function
>>    and transfer prints. Make sure the debug level comes from the
>>    correct USB context.
>>
>>    Found by:             Ludovic Rousseau <ludovic.rousseau+freebsd@gmail.com>
>>    PR:                   231264
>>    MFC after:            1 week
>>    Approved by:          re (kib)
>>    Sponsored by:         Mellanox Technologies
>>
>> Modified:
>>    head/lib/libusb/libusb10.h
>>    head/lib/libusb/libusb10_io.c
>>
>> Modified: head/lib/libusb/libusb10.h
>> ==============================================================================
>> --- head/lib/libusb/libusb10.h  Fri Sep 14 01:52:34 2018        (r338678)
>> +++ head/lib/libusb/libusb10.h  Fri Sep 14 13:41:37 2018        (r338679)
>> @@ -41,22 +41,24 @@
>>   #define        HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
>>   #define        HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
>>
>> -#define        DPRINTF(ctx, dbg, format, args...) do { \
>> -    if ((ctx)->debug == dbg) {                 \
>> -       switch (dbg) {                          \
>> -       case LIBUSB_DEBUG_FUNCTION:             \
>> -               printf("LIBUSB_FUNCTION: "      \
>> -                   format "\n", ## args);      \
>> -               break;                          \
>> -       case LIBUSB_DEBUG_TRANSFER:             \
>> -               printf("LIBUSB_TRANSFER: "      \
>> -                   format "\n", ## args);      \
>> -               break;                          \
>> -       default:                                \
>> -               break;                          \
>> -       }                                       \
>> -    }                                          \
>> -} while(0)
>> +#define        DPRINTF(ctx, dbg, format, ...) do {                     \
>> +       switch (dbg) {                                          \
>> +       case LIBUSB_DEBUG_FUNCTION:                             \
>> +               if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) {     \
>> +                       printf("LIBUSB_FUNCTION: "              \
>> +                              format "\n", ## __VA_ARGS__);    \
>> +               }                                               \
>> +               break;                                          \
>> +       case LIBUSB_DEBUG_TRANSFER:                             \
>> +               if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) {     \
>> +                       printf("LIBUSB_TRANSFER: "              \
>> +                              format "\n", ## __VA_ARGS__);    \
>> +               }                                               \
>> +               break;                                          \
>> +       default:                                                \
>> +               break;                                          \
>> +       }                                                       \
>> +} while (0)
>>
>>   /* internal structures */
>>
> 
> Hi,
> 
> How are people/users of libusb supposed to disable these messages
> after this? The only thing stopping them was the debug level in the
> context, I guess, because DPRINTF is always compiled to this and the
> users of DPRINTF are just invoking it all willy-nilly.
> 

Feel free to submit a patch. Maybe you need to make a new option for 
user-space like WITH_USB_DEBUG ....

--HPS




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?176b6c74-947c-0e0e-6568-effcfac9cd8f>