Changeset 16563


Ignore:
Timestamp:
06/01/13 22:08:31 (12 years ago)
Author:
tbretz
Message:
Turned the login in the loop to ensure no access if no data (can this happen at all?) and fixed a typo (unsigned short is uint16_t not uint32_t)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/checksum.h

    r16546 r16563  
    11#ifndef MARS_checksum
    22#define MARS_checksum
    3 
    4 #include <arpa/inet.h>
    53
    64namespace std
     
    6765        }
    6866
    69         const uint32_t *sbuf = reinterpret_cast<const uint32_t*>(buf);
     67        const uint16_t *sbuf = reinterpret_cast<const uint16_t *>(buf);
    7068
    7169        uint32_t *hilo  = reinterpret_cast<uint32_t*>(&buffer);
     
    8482        while (1)
    8583        {
     84            if (sbuf==end)
     85                break;
     86
    8687            hilo[0] += ntohs(*sbuf++);
     88
    8789            if (sbuf==end)
    8890                break;
    8991
    9092            hilo[1] += ntohs(*sbuf++);
    91             if (sbuf==end)
    92                 break;
    9393        }
    9494
Note: See TracChangeset for help on using the changeset viewer.