VirtualBox

Changeset 82347 in vbox


Ignore:
Timestamp:
Dec 3, 2019 4:32:17 PM (5 years ago)
Author:
vboxsync
Message:

Dev/E1000: Deal with trivial issues detected by parfait.

Location:
trunk/src/VBox/Devices/Network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevE1000.cpp

    r82129 r82347  
    17801780    while (csum >> 16)
    17811781        csum = (csum >> 16) + (csum & 0xFFFF);
    1782     return ~csum;
     1782    Assert(csum < 65536);
     1783    return (uint16_t)~csum;
    17831784}
    17841785
     
    29172918{
    29182919#ifdef IN_RING3
    2919     uint32_t value;
     2920    uint32_t value = 0; /* Get rid of false positive in parfait. */
    29202921    int      rc = e1kRegReadDefault(pDevIns, pThis, offset, index, &value);
    29212922    if (RT_SUCCESS(rc))
     
    32433244        E1kLog2(("%s e1kRegWriteRCTL: Setting receive buffer size to %d (old %d)\n",
    32443245                 pThis->szPrf, cbRxBuf, pThis->u16RxBSize));
    3245     pThis->u16RxBSize = cbRxBuf;
     3246    Assert(cbRxBuf < 65536);
     3247    pThis->u16RxBSize = (uint16_t)cbRxBuf;
    32463248
    32473249    /* Update the register */
     
    40414043    {
    40424044        E1kLog3(("%s Inserting VLAN tag %08x\n",
    4043             pThis->szPrf, RT_BE2H_U16(VET) | (RT_BE2H_U16(pThis->u16VTagTCI) << 16)));
     4045            pThis->szPrf, RT_BE2H_U16((uint16_t)VET) | (RT_BE2H_U16(pThis->u16VTagTCI) << 16)));
    40444046        memmove((uint8_t*)pSg->aSegs[0].pvSeg + 16, (uint8_t*)pSg->aSegs[0].pvSeg + 12, cbFrame - 12);
    4045         *((uint32_t*)pSg->aSegs[0].pvSeg + 3) = RT_BE2H_U16(VET) | (RT_BE2H_U16(pThis->u16VTagTCI) << 16);
     4047        *((uint32_t*)pSg->aSegs[0].pvSeg + 3) = RT_BE2H_U16((uint16_t)VET) | (RT_BE2H_U16(pThis->u16VTagTCI) << 16);
    40464048        pSg->cbUsed += 4;
    40474049        cbFrame     += 4;
     
    43784380        while (csum >> 16)
    43794381            csum = (csum >> 16) + (csum & 0xFFFF);
    4380         pTcpHdr->chksum = csum;
     4382        Assert(csum < 65536);
     4383        pTcpHdr->chksum = (uint16_t)csum;
    43814384        /* Compute final checksum */
    43824385        e1kInsertChecksum(pThis, pThis->aTxPacketFallback, pThis->u16TxPktLen,
     
    59545957    for (unsigned i = E1K_NUM_OF_BINARY_SEARCHABLE; i < RT_ELEMENTS(g_aE1kRegMap); i++)
    59555958        if (offReg - g_aE1kRegMap[i].offset < g_aE1kRegMap[i].size)
    5956             return i;
     5959            return (int)i;
    59575960
    59585961# ifdef VBOX_STRICT
     
    60126015            return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "unsupported op size: offset=%#10x cb=%#10x\n", offReg, cb);
    60136016    }
    6014     if (index != -1)
     6017    if (index > 0)
    60156018    {
    60166019        RT_UNTRUSTED_VALIDATED_FENCE(); /* paranoia because of port I/O. */
     
    60326035            //pThis->iStatIntLost += pThis->iStatIntLostOne;
    60336036            //pThis->iStatIntLostOne = 0;
    6034             rc = g_aE1kRegMap[index].pfnRead(pDevIns, pThis, offReg & 0xFFFFFFFC, index, &u32);
     6037            rc = g_aE1kRegMap[index].pfnRead(pDevIns, pThis, offReg & 0xFFFFFFFC, (uint32_t)index, &u32);
    60356038            u32 &= mask;
    60366039            //e1kCsLeave(pThis);
     
    60786081    VBOXSTRICTRC rc     = VINF_SUCCESS;
    60796082    int          idxReg = e1kRegLookup(offReg);
    6080     if (RT_LIKELY(idxReg != -1))
     6083    if (RT_LIKELY(idxReg > 0))
    60816084    {
    60826085        RT_UNTRUSTED_VALIDATED_FENCE(); /* paranoia because of port I/O. */
     
    60936096            //pThis->iStatIntLost += pThis->iStatIntLostOne;
    60946097            //pThis->iStatIntLostOne = 0;
    6095             rc = g_aE1kRegMap[idxReg].pfnRead(pDevIns, pThis, offReg & 0xFFFFFFFC, idxReg, pu32);
     6098            rc = g_aE1kRegMap[idxReg].pfnRead(pDevIns, pThis, offReg & 0xFFFFFFFC, (uint32_t)idxReg, pu32);
    60966099            //e1kCsLeave(pThis);
    60976100            Log6(("%s At %08X read  %08X          from %s (%s)\n",
     
    61266129    VBOXSTRICTRC rc    = VINF_SUCCESS;
    61276130    int          index = e1kRegLookup(offReg);
    6128     if (RT_LIKELY(index != -1))
     6131    if (RT_LIKELY(index > 0))
    61296132    {
    61306133        RT_UNTRUSTED_VALIDATED_FENCE(); /* paranoia because of port I/O. */
     
    61436146            //pThis->iStatIntLost += pThis->iStatIntLostOne;
    61446147            //pThis->iStatIntLostOne = 0;
    6145             rc = g_aE1kRegMap[index].pfnWrite(pDevIns, pThis, offReg, index, u32Value);
     6148            rc = g_aE1kRegMap[index].pfnWrite(pDevIns, pThis, offReg, (uint32_t)index, u32Value);
    61466149            //e1kCsLeave(pThis);
    61476150        }
     
    77907793        LogRel(("%s: WARNING! Link up delay is disabled!\n", pThis->szPrf));
    77917794
    7792     uint32_t uStatNo = iInstance;
    7793     rc = pHlp->pfnCFGMQueryU32Def(pCfg, "StatNo", &uStatNo, iInstance);
     7795    uint32_t uStatNo = (uint32_t)iInstance;
     7796    rc = pHlp->pfnCFGMQueryU32Def(pCfg, "StatNo", &uStatNo, (uint32_t)iInstance);
    77947797    if (RT_FAILURE(rc))
    77957798        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to get the \"StatNo\" value"));
  • trunk/src/VBox/Devices/Network/DevE1000Phy.cpp

    r81465 r82347  
    5050
    5151#define REG(x) pPhy->au16Regs[x##_IDX]
    52 
    53 
    54 /* External callback declaration */
    55 void e1kPhyLinkResetCallback(PPDMDEVINS pDevIns);
    5652
    5753
     
    244240        if (s_regMap[index].u32Address == u32Address)
    245241        {
    246             return index;
     242            return (int)index;
    247243        }
    248244    }
     
    263259    uint16_t u16   = 0;
    264260
    265     if (index != -1)
    266     {
    267         u16 = s_regMap[index].pfnRead(pPhy, index, pDevIns);
     261    if (index > 0)
     262    {
     263        u16 = s_regMap[index].pfnRead(pPhy, (uint32_t)index, pDevIns);
    268264        PhyLog(("PHY#%d At %02d read  %04X      from %s (%s)\n",
    269265                pPhy->iInstance, s_regMap[index].u32Address, u16,
     
    288284    int index = Phy::lookupRegister(u32Address);
    289285
    290     if (index != -1)
     286    if (index > 0)
    291287    {
    292288        PhyLog(("PHY#%d At %02d write      %04X  to  %s (%s)\n",
    293289                pPhy->iInstance, s_regMap[index].u32Address, u16Value,
    294290                s_regMap[index].pszAbbrev, s_regMap[index].pszName));
    295         s_regMap[index].pfnWrite(pPhy, index, u16Value, pDevIns);
     291        s_regMap[index].pfnWrite(pPhy, (uint32_t)index, u16Value, pDevIns);
    296292    }
    297293    else
  • trunk/src/VBox/Devices/Network/DevE1000Phy.h

    r81465 r82347  
    108108#define MDIO_WRITE_OP 1
    109109
     110/* External callback declaration */
     111void e1kPhyLinkResetCallback(PPDMDEVINS pDevIns);
     112
     113
    110114typedef struct Phy::Phy_st PHY;
    111115typedef PHY *PPHY;
  • trunk/src/VBox/Devices/Network/DevEEPROM.cpp

    r81765 r82347  
    115115EEPROM93C46::State EEPROM93C46::opWriteAll()
    116116{
    117     for (int i = 0; i < SIZE; i++)
     117    for (unsigned i = 0; i < SIZE; i++)
    118118        storeWord(i, m_u16Word);
    119119    return WAITING_CS_FALL;
     
    264264    pHlp->pfnSSMPutU8(  pSSM, EEPROM93C46_SAVEDSTATE_VERSION);
    265265    Assert((uint32_t)m_eState < UINT32_C(256));
    266     pHlp->pfnSSMPutU8(  pSSM, m_eState);
     266    pHlp->pfnSSMPutU8(  pSSM, (uint8_t)m_eState);
    267267    Assert((uint32_t)m_eOp < UINT32_C(256));
    268     pHlp->pfnSSMPutU8(  pSSM, m_eOp);
     268    pHlp->pfnSSMPutU8(  pSSM, (uint8_t)m_eOp);
    269269    pHlp->pfnSSMPutBool(pSSM, m_fWriteEnabled);
    270270    pHlp->pfnSSMPutU32( pSSM, m_u32InternalWires);
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