]> git.proxmox.com Git - qemu.git/blobdiff - slirp/cksum.c
rng-egd: remove redundant free
[qemu.git] / slirp / cksum.c
index ee7e8644adc783d9cf17876bd608d29bd02a5cd7..63286600e7cb1505ad3eceb3d630857272bc66a8 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  */
 
 #define ADDCARRY(x)  (x > 65535 ? x -= 65535 : x)
-#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
+#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1];        \
+        (void)ADDCARRY(sum);}
 
 int cksum(struct mbuf *m, int len)
 {
-       register u_int16_t *w;
+       register uint16_t *w;
        register int sum = 0;
        register int mlen = 0;
        int byte_swapped = 0;
 
        union {
-               u_int8_t        c[2];
-               u_int16_t       s;
+               uint8_t  c[2];
+               uint16_t s;
        } s_util;
        union {
-               u_int16_t s[2];
-               u_int32_t l;
+               uint16_t s[2];
+               uint32_t l;
        } l_util;
 
        if (m->m_len == 0)
           goto cont;
-       w = mtod(m, u_int16_t *);
+       w = mtod(m, uint16_t *);
 
        mlen = m->m_len;
 
        if (len < mlen)
           mlen = len;
+#ifdef DEBUG
        len -= mlen;
+#endif
        /*
         * Force to even boundary.
         */
-       if ((1 & (long) w) && (mlen > 0)) {
+       if ((1 & (uintptr_t)w) && (mlen > 0)) {
                REDUCE;
                sum <<= 8;
-               s_util.c[0] = *(u_int8_t *)w;
-               w = (u_int16_t *)((int8_t *)w + 1);
+               s_util.c[0] = *(uint8_t *)w;
+               w = (uint16_t *)((int8_t *)w + 1);
                mlen--;
                byte_swapped = 1;
        }
@@ -111,16 +110,15 @@ int cksum(struct mbuf *m, int len)
        if (byte_swapped) {
                REDUCE;
                sum <<= 8;
-               byte_swapped = 0;
                if (mlen == -1) {
-                       s_util.c[1] = *(u_int8_t *)w;
+                       s_util.c[1] = *(uint8_t *)w;
                        sum += s_util.s;
                        mlen = 0;
                } else
-                 
+
                   mlen = -1;
        } else if (mlen == -1)
-          s_util.c[0] = *(u_int8_t *)w;
+          s_util.c[0] = *(uint8_t *)w;
 
 cont:
 #ifdef DEBUG