VirtualBox

Changeset 96720 in vbox for trunk/src/VBox/Devices/USB/linux


Ignore:
Timestamp:
Sep 13, 2022 1:04:56 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153605
Message:

USBProxyDevice-linux.cpp: Put struct usbdevfs_urb KUrb at the end of USBPROXYURBLNX as GCC 10 & 11 are still too stupid to accept 'flexible array' in a union. This is a bit more risky, but I could only spot one place converting a struct usbdevfs_urb pointer to PUSBPROXYURBLNX. bugref:10279

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp

    r96719 r96720  
    9595typedef struct USBPROXYURBLNX
    9696{
    97     /** The kernel URB data. */
    98 #if RT_GNUC_PREREQ(6, 0)
    99     /* gcc 6.2 complains about the [] member of KUrb */
    100 # pragma GCC diagnostic push
    101 # pragma GCC diagnostic ignored "-Wpedantic"
    102 #endif
    103     union
    104     {
    105         struct usbdevfs_urb         KUrb;
    106         /** Make sure we've got sufficient space for isochronous packets. */
    107         uint8_t                     abKUrbPadding[  RT_UOFFSETOF(struct usbdevfs_urb, iso_frame_desc)
    108                                                   + sizeof(struct usbdevfs_iso_packet_desc) * 8];
    109     };
    110 #if RT_GNUC_PREREQ(6, 0)
    111 # pragma GCC diagnostic pop
    112 #endif
    11397    /** Node to link the URB in of the existing lists. */
    11498    RTLISTNODE                      NodeList;
    11599    /** If we've split the VUSBURB up into multiple linux URBs, this is points to the head. */
    116     struct USBPROXYURBLNX           *pSplitHead;
     100    struct USBPROXYURBLNX          *pSplitHead;
    117101    /** The next linux URB if split up. */
    118     struct USBPROXYURBLNX           *pSplitNext;
     102    struct USBPROXYURBLNX          *pSplitNext;
    119103    /** Don't report these back. */
    120104    bool                            fCanceledBySubmit;
     
    125109    /** Size to transfer in remaining fragments of a split URB */
    126110    uint32_t                        cbSplitRemaining;
     111
     112#if RT_GNUC_PREREQ(6, 0) /* gcc 6.2 complains about the [] member of KUrb */
     113# pragma GCC diagnostic push
     114# pragma GCC diagnostic ignored "-Wpedantic"
     115#endif
     116    /** The kernel URB data (variable size array included). */
     117    struct usbdevfs_urb             KUrb;
     118#if RT_GNUC_PREREQ(6, 0)
     119# pragma GCC diagnostic pop
     120#endif
    127121} USBPROXYURBLNX, *PUSBPROXYURBLNX;
    128122
     
    278272}
    279273
     274
    280275/**
    281276 * Unlinks the given URB from the in flight list.
     277 *
    282278 * @returns nothing.
    283279 * @param   pDevLnx         The proxy device instance - Linux specific data.
     
    299295}
    300296
     297
    301298/**
    302299 * Allocates a linux URB request structure.
     300 *
    303301 * @returns Pointer to an active URB request.
    304302 * @returns NULL on failure.
     
    327325    {
    328326        RTCritSectLeave(&pDevLnx->CritSect);
    329         pUrbLnx = (PUSBPROXYURBLNX)RTMemAlloc(sizeof(*pUrbLnx));
     327        PVUSBURB pVUrbDummy; RT_NOREF(pVUrbDummy);
     328        pUrbLnx = (PUSBPROXYURBLNX)RTMemAlloc(RT_UOFFSETOF_DYN(USBPROXYURBLNX,
     329                                                               KUrb.iso_frame_desc[RT_ELEMENTS(pVUrbDummy->aIsocPkts)]));
    330330        if (!pUrbLnx)
    331331            return NULL;
     
    996996 * Clean up after a failed URB submit.
    997997 */
    998 static void usbProxyLinuxCleanupFailedSubmit(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pUrbLnx, PUSBPROXYURBLNX pCur, PVUSBURB pUrb, bool *pfUnplugged)
     998static void usbProxyLinuxCleanupFailedSubmit(PUSBPROXYDEV pProxyDev, PUSBPROXYURBLNX pUrbLnx, PUSBPROXYURBLNX pCur,
     999                                             PVUSBURB pUrb, bool *pfUnplugged)
    9991000{
    10001001    if (pUrb->enmType == VUSBXFERTYPE_MSG)
     
    15031504                return NULL;
    15041505            }
    1505         pUrbLnx = (PUSBPROXYURBLNX)pKUrb;
     1506        pUrbLnx = RT_FROM_MEMBER(pKUrb, USBPROXYURBLNX, KUrb);
    15061507
    15071508        /* split list: Is the entire split list done yet? */
     
    15781579            if (pUrb->enmType == VUSBXFERTYPE_ISOC)
    15791580            {
    1580                 AssertCompile(   sizeof(pUrbLnx->abKUrbPadding)
    1581                               >=   RT_UOFFSETOF(struct usbdevfs_urb, iso_frame_desc)
    1582                                  + sizeof(struct usbdevfs_iso_packet_desc) * RT_ELEMENTS(pUrb->aIsocPkts));
    15831581                unsigned i, off;
    15841582                for (i = 0, off = 0; i < pUrb->cIsocPkts; i++)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette