VirtualBox

Changeset 107932 in vbox for trunk/src/VBox/Devices/USB


Ignore:
Timestamp:
Jan 24, 2025 10:36:44 AM (4 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167169
Message:

DevXHCI: Fixed remaining Parfait warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DevXHCI.cpp

    r107924 r107932  
    45464546    RTGCPHYS        GCPhysInpSlot;
    45474547    RTGCPHYS        GCPhysOutSlot;
    4548     RTGCPHYS        GCPhysOutEndp;
    45494548    XHCI_INPC_CTX   icc;            /* Input Control Context (ICI=0). */
    45504549    XHCI_SLOT_CTX   out_slot_ctx;   /* Slot context (DCI=0). */
    45514550    XHCI_EP_CTX     out_endp_ctx;   /* Endpoint Context (DCI=1). */
    45524551    unsigned        cc = XHCI_TCC_SUCCESS;
    4553     uint32_t        uAddFlags;
    4554     uint32_t        uDropFlags;
    4555     unsigned        num_inp_ctx;
    4556     unsigned        num_out_ctx;
    4557     XHCI_DEV_CTX    dc_inp;
    4558     XHCI_DEV_CTX    dc_out;
    45594552    unsigned        uDCI;
    4560 
    4561     RT_ZERO(dc_inp);
    45624553
    45634554    Assert(uSlotID);
     
    45824573
    45834574        /* Check for deconfiguration request. */
    4584         if (fDC) {
    4585             if (out_slot_ctx.slot_state == XHCI_SLTST_CONFIGURED) {
     4575        if (fDC)
     4576        {
     4577            if (out_slot_ctx.slot_state == XHCI_SLTST_CONFIGURED)
     4578            {
    45864579                /* Disable all enabled endpoints. */
    4587                 uDropFlags = 0xFFFFFFFC; /** @todo r=bird: Why do you set uDropFlags and uAddFlags in a code path that doesn't use
    4588                                           * them?  This is a _very_ difficult function to get the hang of the way it's written.
    4589                                           * Stuff like this looks like there's a control flow flaw (as to the do-break-while-false
    4590                                           * loop which doesn't do any clean up or logging at the end and seems only sever the very
    4591                                           * dubious purpose of making sure ther's only one return statement).   The insistance on
    4592                                           * C-style variable declarations (top of function), makes checking state harder, which is
    4593                                           * why it's discouraged. */
    4594                 uAddFlags  = 0;
    4595 
    4596                 /* Start with EP1. */
    4597                 GCPhysOutEndp = GCPhysOutSlot + sizeof(XHCI_SLOT_CTX) + sizeof(XHCI_EP_CTX);
    4598 
     4580                /* This is a shortcut for handling the DC flag. It could also
     4581                 * be accomplished by setting
     4582                 *
     4583                 *  uDropFlags = 0xFFFFFFFC;
     4584                 *  uAddFlags  = 0;
     4585                 *
     4586                 *  and letting the generic code deal with it. However, here we minimize
     4587                 *  memory accesses.
     4588                 */
     4589
     4590                /* Disable EP1. */
     4591                RTGCPHYS        GCPhysOutEndp = GCPhysOutSlot + sizeof(XHCI_SLOT_CTX) + sizeof(XHCI_EP_CTX);
    45994592                PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysOutEndp, &out_endp_ctx, sizeof(out_endp_ctx));
    46004593                out_endp_ctx.ep_state = XHCI_EPST_DISABLED;
    46014594                PDMDevHlpPCIPhysWriteMeta(pDevIns, GCPhysOutEndp, &out_endp_ctx, sizeof(out_endp_ctx));
    4602                 GCPhysOutEndp += sizeof(XHCI_EP_CTX);   /* Point to the next EP context. */
    46034595
    46044596                /* Finally update the output slot context. */
     
    46094601            }
    46104602            else
    4611                 /* NB: Attempts to deconfigure a slot in Addressed state are ignored. */
     4603                /* NB: Attempts to deconfigure a slot in Addressed state are silently ignored. */
    46124604                Log(("Ignoring attempt to deconfigure slot in Addressed state!\n"));
    46134605            break;
     
    46194611        Assert(icc.add_flags || icc.drop_flags);    /* Make sure there's something to do. */
    46204612
    4621         uAddFlags  = icc.add_flags;
    4622         uDropFlags = icc.drop_flags;
     4613        uint32_t    uAddFlags  = icc.add_flags;
     4614        uint32_t    uDropFlags = icc.drop_flags;
    46234615        LogFlowFunc(("Add Flags=%08X, Drop Flags=%08X\n", uAddFlags, uDropFlags));
     4616
     4617        /* Start out with an empty input device context. */
     4618        XHCI_DEV_CTX    dc_inp;
     4619        RT_ZERO(dc_inp);
    46244620
    46254621        /* If and only if any 'add context' flag is set, fetch the corresponding
     
    46334629             * including the one with the highest 'add' bit set.
    46344630             */
    4635             num_inp_ctx = ASMBitLastSetU32(uAddFlags);
     4631            unsigned    num_inp_ctx = ASMBitLastSetU32(uAddFlags);
    46364632            Assert(num_inp_ctx);
    46374633            PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysInpSlot, &dc_inp, num_inp_ctx * sizeof(XHCI_DS_ENTRY));
     
    46454641         * including the one with the highest 'add' or 'drop' bit set.
    46464642         */
    4647         num_out_ctx = ASMBitLastSetU32(uAddFlags | uDropFlags);
     4643        XHCI_DEV_CTX    dc_out;
     4644        unsigned        num_out_ctx = ASMBitLastSetU32(uAddFlags | uDropFlags);
    46484645        PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysOutSlot, &dc_out, num_out_ctx * sizeof(XHCI_DS_ENTRY));
    46494646
     
    46744671
    46754672        /* Finally update the device context. */
    4676         if (fDC || dc_inp.entry[0].sc.ctx_ent == 1)
     4673        if (/*fDC ||*/ dc_inp.entry[0].sc.ctx_ent == 1)
    46774674        {
    46784675            dc_out.entry[0].sc.slot_state = XHCI_SLTST_ADDRESSED;
Note: See TracChangeset for help on using the changeset viewer.

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