From owner-svn-src-head@freebsd.org  Wed Oct  2 12:55:58 2019
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id 28E5C12E4E6;
 Wed,  2 Oct 2019 12:55:58 +0000 (UTC)
 (envelope-from kevans@freebsd.org)
Received: from smtp.freebsd.org (smtp.freebsd.org
 [IPv6:2610:1c1:1:606c::24b:4])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "smtp.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 46jx2k0Dlcz4N8G;
 Wed,  2 Oct 2019 12:55:58 +0000 (UTC)
 (envelope-from kevans@freebsd.org)
Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com
 [209.85.222.171])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK))
 (Authenticated sender: kevans)
 by smtp.freebsd.org (Postfix) with ESMTPSA id D4681AE0E;
 Wed,  2 Oct 2019 12:55:57 +0000 (UTC)
 (envelope-from kevans@freebsd.org)
Received: by mail-qk1-f171.google.com with SMTP id q203so14859622qke.1;
 Wed, 02 Oct 2019 05:55:57 -0700 (PDT)
X-Gm-Message-State: APjAAAU0KHlg1PrGmJqqudRMoWYl7Tg/8xy1c70yheC+OwGrZTFJ+8fm
 /FpGvh4HRgC6Da3Ha/Ho8VxGqE+mIpByr5OtE98=
X-Google-Smtp-Source: APXvYqwqBKamfKaKnkDO/pkDoi7gCmhVX5qCbt8icrVC8gBsUHqD/3S9AYVy/gh1a9PkU2bOwRBHc2qzsmIG2HogkJU=
X-Received: by 2002:ae9:e88a:: with SMTP id a132mr3656603qkg.120.1570020957436; 
 Wed, 02 Oct 2019 05:55:57 -0700 (PDT)
MIME-Version: 1.0
References: <201809141341.w8EDfbtO070815@repo.freebsd.org>
In-Reply-To: <201809141341.w8EDfbtO070815@repo.freebsd.org>
From: Kyle Evans <kevans@freebsd.org>
Date: Wed, 2 Oct 2019 07:55:45 -0500
X-Gmail-Original-Message-ID: <CACNAnaHeNc74Mvsp6Nxi4PvPYxRQW=w30i26OhC+42_YBf8-WQ@mail.gmail.com>
Message-ID: <CACNAnaHeNc74Mvsp6Nxi4PvPYxRQW=w30i26OhC+42_YBf8-WQ@mail.gmail.com>
Subject: Re: svn commit: r338679 - head/lib/libusb
To: Hans Petter Selasky <hselasky@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>
Content-Type: text/plain; charset="UTF-8"
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Oct 2019 12:55:58 -0000

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.

Thanks,

Kyle Evans