VirtualBox

Changeset 32257 in vbox


Ignore:
Timestamp:
Sep 6, 2010 8:27:05 PM (14 years ago)
Author:
vboxsync
Message:

iprt/ipv4.cpp: fixed mixed code/declaration C warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/ipv4.cpp

    r28800 r32257  
    299299DECLINLINE(uint32_t) rtNetIPv4AddDataChecksum(void const *pvData, size_t cbData, uint32_t u32Sum, bool *pfOdd)
    300300{
     301    uint16_t const *pw = (uint16_t const *)pvData;
    301302    if (*pfOdd)
    302303    {
     
    316317
    317318    /* iterate the data. */
    318     uint16_t const *pw = (uint16_t const *)pvData;
    319319    while (cbData > 1)
    320320    {
     
    398398RTDECL(uint16_t) RTNetUDPChecksum(uint32_t u32Sum, PCRTNETUDP pUdpHdr)
    399399{
     400    bool fOdd;
    400401    u32Sum = rtNetIPv4AddUDPChecksum(pUdpHdr, u32Sum);
    401     bool fOdd = false;
     402    fOdd = false;
    402403    u32Sum = rtNetIPv4AddDataChecksum(pUdpHdr + 1, RT_BE2H_U16(pUdpHdr->uh_ulen) - sizeof(*pUdpHdr), u32Sum, &fOdd);
    403404    return rtNetIPv4FinalizeChecksum(u32Sum);
     
    419420RTDECL(uint16_t) RTNetIPv4UDPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETUDP pUdpHdr, void const *pvData)
    420421{
     422    bool fOdd;
    421423    uint32_t u32Sum = rtNetIPv4PseudoChecksum(pIpHdr);
    422424    u32Sum = rtNetIPv4AddUDPChecksum(pUdpHdr, u32Sum);
    423     bool fOdd = false;
     425    fOdd = false;
    424426    u32Sum = rtNetIPv4AddDataChecksum(pvData, RT_BE2H_U16(pUdpHdr->uh_ulen) - sizeof(*pUdpHdr), u32Sum, &fOdd);
    425427    return rtNetIPv4FinalizeChecksum(u32Sum);
     
    442444     * Size validation.
    443445     */
     446    size_t cb;
    444447    if (RT_UNLIKELY(cbPktMax < RTNETUDP_MIN_LEN))
    445448        return false;
    446     size_t cb = RT_BE2H_U16(pUdpHdr->uh_ulen);
     449    cb = RT_BE2H_U16(pUdpHdr->uh_ulen);
    447450    if (RT_UNLIKELY(cb > cbPktMax))
    448451        return false;
     
    510513RTDECL(uint16_t) RTNetIPv4TCPChecksum(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, void const *pvData)
    511514{
     515    bool fOdd;
     516    size_t cbData;
    512517    uint32_t u32Sum = rtNetIPv4PseudoChecksum(pIpHdr);
    513518    u32Sum = rtNetIPv4AddTCPChecksum(pTcpHdr, u32Sum);
    514     bool fOdd = false;
    515     size_t cbData = RT_BE2H_U16(pIpHdr->ip_len) - pIpHdr->ip_hl * 4 - pTcpHdr->th_off * 4;
     519    fOdd = false;
     520    cbData = RT_BE2H_U16(pIpHdr->ip_len) - pIpHdr->ip_hl * 4 - pTcpHdr->th_off * 4;
    516521    u32Sum = rtNetIPv4AddDataChecksum(pvData ? pvData : (uint8_t const *)pTcpHdr + pTcpHdr->th_off * 4,
    517522                                      cbData, u32Sum, &fOdd);
     
    536541RTDECL(uint16_t) RTNetTCPChecksum(uint32_t u32Sum, PCRTNETTCP pTcpHdr, void const *pvData, size_t cbData)
    537542{
     543    bool fOdd;
    538544    u32Sum = rtNetIPv4AddTCPChecksum(pTcpHdr, u32Sum);
    539     bool fOdd = false;
     545    fOdd = false;
    540546    u32Sum = rtNetIPv4AddDataChecksum(pvData, cbData, u32Sum, &fOdd);
    541547    return rtNetIPv4FinalizeChecksum(u32Sum);
     
    556562DECLINLINE(bool) rtNetIPv4IsTCPSizeValid(PCRTNETIPV4 pIpHdr, PCRTNETTCP pTcpHdr, size_t cbHdrMax, size_t cbPktMax)
    557563{
     564    size_t cbTcpHdr;
     565    size_t cbTcp;
     566
    558567    Assert(cbPktMax >= cbHdrMax);
    559568
     
    563572    if (RT_UNLIKELY(cbPktMax < RTNETTCP_MIN_LEN))
    564573        return false;
    565     size_t cbTcpHdr = pTcpHdr->th_off * 4;
     574    cbTcpHdr = pTcpHdr->th_off * 4;
    566575    if (RT_UNLIKELY(cbTcpHdr > cbHdrMax))
    567576        return false;
    568     size_t cbTcp = RT_BE2H_U16(pIpHdr->ip_len) - pIpHdr->ip_hl * 4;
     577    cbTcp = RT_BE2H_U16(pIpHdr->ip_len) - pIpHdr->ip_hl * 4;
    569578    if (RT_UNLIKELY(cbTcp > cbPktMax))
    570579        return false;
     
    642651RTDECL(bool) RTNetIPv4IsDHCPValid(PCRTNETUDP pUdpHdr, PCRTNETBOOTP pDhcp, size_t cbDhcp, uint8_t *pMsgType)
    643652{
     653    ssize_t cbLeft;
     654    uint8_t MsgType;
     655    PCRTNETDHCPOPT pOpt;
     656
    644657    AssertPtrNull(pMsgType);
    645658    if (pMsgType)
     
    674687     * (because that seems to be indicating that it's BOOTP and not DHCP).
    675688     */
    676     ssize_t cbLeft = (ssize_t)cbDhcp - RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_cookie) + sizeof(pDhcp->bp_vend.Dhcp.dhcp_cookie);
     689    cbLeft = (ssize_t)cbDhcp - RT_OFFSETOF(RTNETBOOTP, bp_vend.Dhcp.dhcp_cookie) + sizeof(pDhcp->bp_vend.Dhcp.dhcp_cookie);
    677690    if (cbLeft < 0)
    678691        return true;
     
    681694    if (cbLeft < 1)
    682695        return true;
    683     PCRTNETDHCPOPT pOpt = (PCRTNETDHCPOPT)&pDhcp->bp_vend.Dhcp.dhcp_opts[0];
     696    pOpt = (PCRTNETDHCPOPT)&pDhcp->bp_vend.Dhcp.dhcp_opts[0];
    684697    if (pOpt->dhcp_opt == RTNET_DHCP_OPT_END)
    685698        return false;
     
    691704     * we don't accept END without MSG_TYPE.
    692705     */
    693     uint8_t MsgType = 0;
     706    MsgType = 0;
    694707    while (cbLeft > 0)
    695708    {
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