From nobody Tue Jul 8 19:44:42 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bcBQN3rxzz61R55; Tue, 08 Jul 2025 19:44:44 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bcBQN37BBz4K7j; Tue, 08 Jul 2025 19:44:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752003884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UyZGMx9sMYvh8EidQA15n0pe/82w3Q8s4ip+z4hP7/c=; b=nk5E61xeSn63Ewc1fAGzXUd/iLC95N1HvQPulaHPm4K1h9YsBM27fINc+WSxXU46JyTlLD Kx9j6skk/rhCx5L/Ev01Zhmq0/byjQpWAi9HDzDFfT+C2E9hA2Si9wRxgWqoO+CYeGdD/g iZs3e0K3qMoI6mv1eWfhS8M7F6v6eRCwvQQDu5syYVzyRUy+518+QkQQpiJTlgz05R6I3x N7ibHVv43ecyj7TcQYsmmqz1Wv+tbyZ8qw9lbHCW8KlYSRdM1wkiTSYH8+q7t3MVLd2rgr bVW7gd+KnH4n7/Yt1VdiQ75Ne68+mxMF9Uz2T60cuf1YwTCtVmgOJMkqYHBmZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752003884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UyZGMx9sMYvh8EidQA15n0pe/82w3Q8s4ip+z4hP7/c=; b=HqZc4f4pB5lOO20JIA0oSx6MpxLUy7DVREnMm8BswE40Un+nfnSUZurtaYRcnKNITXV12h LVFmnCq1H/+WC3DNnHDMmn1AdlsyQuh7wtd+tdj0Gr96ZN1imKseGBJ98UrRTRd9uU/Ws2 kp8dHz4eScg6aJT1XqgsHKlLGh2f33oEDhrELH8+URtQkeveWtZ1w95DBh47z9bLfjYJz4 /Dw8rnGjKDNhb0/Y9wtFR2JEtj+8dUjPAKcYJvgPGuFTpAUh2cWGWyjbu85fZdx/Is80FT 9HluDwzu2K/uV9DMOH3v4LZohUnRkxVnDawvGoLOPTEErMWto74H3Xp4J7G5JQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752003884; a=rsa-sha256; cv=none; b=M2eskOFW64rq3kWAAuJCZfHdrVBQc2crSOd6Wd06vup/Dyx1k0VpPDfuk4qfzhVRKwCPpg /8gecosaLel2EmdE4hucU1KeiaiUNFx96UXsCP9eKwIZ2LVUYbpndTIs4UgOrbVg64zvHL DyoYo+g4KDuhlk11G3mYxOK/c3u7KDeWBH7P6stXTfb2lRi9sC5QO7x7pnab0CZucLfMPK qHZCKe95GFYPfIVpkK0sLgbOz+NRw0PA0Uxx28mwVOTlnQViE2d2t/hdxpWn4vldYXyYRF Vttc9W7bf2hNP8q9DN7InZAAV+awU7j2RAWY6XtnC45hI85WpgQfD+qCJ+wLVw== Received: from [10.9.4.95] (unknown [209.182.120.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: kevans/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4bcBQM6RKGzrsn; Tue, 08 Jul 2025 19:44:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Message-ID: Date: Tue, 8 Jul 2025 14:44:42 -0500 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: git: f84a0da4e060 - main - libusb: rename bNumDeviceCapabilities to bNumDeviceCaps for compatibility with libusb To: Adrian Chadd , ShengYi Hung Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202507081512.568FCeX8049407@gitrepo.freebsd.org> Content-Language: en-US From: Kyle Evans In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 7/8/25 14:40, Adrian Chadd wrote: > hi! Thanks for this! > > Could we possibly wrap stuff like these compat macros in a #define that > we can undefine? So we can make sure no new code shows up that uses the > "old" paths? > > eg LIBUSB10_NO_BACKWARDS_COMPAT / LIBUSB20_NO_BACKWARDS_COMPAT ? > > Thanks! > The latter, please. +1 Thanks, Kyle Evans > > > -adrian > > > On Tue, 8 Jul 2025 at 08:12, ShengYi Hung > wrote: > > The branch main has been updated by aokblast: > > URL: https://cgit.FreeBSD.org/src/commit/? > id=f84a0da4e0608a970c775f3d605f8de2b0b8d322 cgit.FreeBSD.org/src/commit/? > id=f84a0da4e0608a970c775f3d605f8de2b0b8d322> > > commit f84a0da4e0608a970c775f3d605f8de2b0b8d322 > Author:     ShengYi Hung > AuthorDate: 2025-06-07 19:43:15 +0000 > Commit:     ShengYi Hung > CommitDate: 2025-07-08 15:11:41 +0000 > >     libusb: rename bNumDeviceCapabilities to bNumDeviceCaps for > compatibility with libusb > >     THe member bNumDeviceCapabilities is referred to as > bNumDeviceCaps in >     the upstream libusb project. > >     To improve compatibility, we are renaming the member accordingly. > >     For backward compatibility, a mocro will be defined to map >     bNumDeviceCapabilities to bNumDeviceCaps. > >     See: https://github.com/libusb/libusb/ > commit/02ebafc85d3f219842cbabaf78abc8100b6656e5 libusb/libusb/commit/02ebafc85d3f219842cbabaf78abc8100b6656e5> > >     Reviewed by:    kevans >     Approved by:    markj (mentor) >     MFC after:      2 weeks >     Sponsored by:   FreeBSD Foundation >     Differential Revision: https://reviews.freebsd.org/D50740 > > --- >  lib/libusb/libusb.h        |  5 ++++- >  lib/libusb/libusb10_desc.c | 11 ++++++----- >  lib/libusb/libusb20_desc.h |  6 +++++- >  3 files changed, 15 insertions(+), 7 deletions(-) > > diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h > index 0aad29aa4ecc..491af3d0a5ec 100644 > --- a/lib/libusb/libusb.h > +++ b/lib/libusb/libusb.h > @@ -418,7 +418,10 @@ typedef struct libusb_bos_descriptor { >         uint8_t bLength; >         uint8_t bDescriptorType; >         uint16_t wTotalLength; > -       uint8_t bNumDeviceCapabilities; > +#ifndef bNumDeviceCapabilities > +#define bNumDeviceCapabilities bNumDeviceCaps > +#endif > +       uint8_t bNumDeviceCaps; >         struct libusb_usb_2_0_device_capability_descriptor > *usb_2_0_ext_cap; >         struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap; >         struct libusb_bos_dev_capability_descriptor **dev_capability; > diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c > index 3e36009cbb3a..5f4c46740688 100644 > --- a/lib/libusb/libusb10_desc.c > +++ b/lib/libusb/libusb10_desc.c > @@ -470,10 +470,11 @@ libusb_parse_bos_descriptor(const void *buf, > int len, >                         ptr->bDescriptorType = dtype; >                         ptr->wTotalLength = ((const uint8_t *)buf)[2] | >                             (((const uint8_t *)buf)[3] << 8); > -                       ptr->bNumDeviceCapabilities = ((const > uint8_t *)buf)[4]; > +                       ptr->bNumDeviceCaps = ((const uint8_t *)buf)[4]; >                         ptr->usb_2_0_ext_cap = NULL; >                         ptr->ss_usb_cap = NULL; > -                       ptr->dev_capability = calloc(ptr- > >bNumDeviceCapabilities, sizeof(void *)); > +                       ptr->dev_capability = calloc(ptr- > >bNumDeviceCaps, > +                           sizeof(void *)); >                         if (ptr->dev_capability == NULL) { >                                 free(ptr); >                                 return (LIBUSB_ERROR_NO_MEM); > @@ -485,7 +486,7 @@ libusb_parse_bos_descriptor(const void *buf, int > len, >                 if (dlen >= 3 && >                     ptr != NULL && >                     dtype == LIBUSB_DT_DEVICE_CAPABILITY) { > -                       if (index != ptr->bNumDeviceCapabilities) { > +                       if (index != ptr->bNumDeviceCaps) { >                                 ptr->dev_capability[index] = > malloc(dlen); >                                 if (ptr->dev_capability[index] == > NULL) { > > libusb_free_bos_descriptor(ptr); > @@ -542,7 +543,7 @@ libusb_parse_bos_descriptor(const void *buf, int > len, >         } > >         if (ptr != NULL) { > -               ptr->bNumDeviceCapabilities = index; > +               ptr->bNumDeviceCaps = index; >                 return (0);             /* success */ >         } > > @@ -557,7 +558,7 @@ libusb_free_bos_descriptor(struct > libusb_bos_descriptor *bos) >         if (bos == NULL) >                 return; > > -       for (i = 0; i != bos->bNumDeviceCapabilities; i++) > +       for (i = 0; i != bos->bNumDeviceCaps; i++) >                 free(bos->dev_capability[i]); >         free(bos->dev_capability); >         free(bos); > diff --git a/lib/libusb/libusb20_desc.h b/lib/libusb/libusb20_desc.h > index 017148a34b1c..0f7c9294ebc8 100644 > --- a/lib/libusb/libusb20_desc.h > +++ b/lib/libusb/libusb20_desc.h > @@ -298,11 +298,15 @@ LIBUSB20_MAKE_STRUCT(LIBUSB20_USB_20_DEVCAP_DESC); > >  LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_USB_DEVCAP_DESC); > > +#ifndef bNumDeviceCapabilities > +#define bNumDeviceCapabilities bNumDeviceCaps > +#endif > + >  #define        LIBUSB20_BOS_DESCRIPTOR(m,n) \ >    m(n, UINT8_T,  bLength, ) \ >    m(n, UINT8_T,  bDescriptorType, ) \ >    m(n, UINT16_T, wTotalLength, ) \ > -  m(n, UINT8_T,  bNumDeviceCapabilities, ) \ > +  m(n, UINT8_T,  bNumDeviceCaps, ) \ > >  LIBUSB20_MAKE_STRUCT(LIBUSB20_BOS_DESCRIPTOR); >