[pisa-src] r1652 - trunk/libpisa/checksum.h

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 12 Nov 2009 12:59:32 +0100

Author: tjansen
Date: Thu Nov 12 12:59:29 2009
New Revision: 1652

Log:
Renamed variables to be more meaningful.

Modified:
   trunk/libpisa/checksum.h

Modified: trunk/libpisa/checksum.h
==============================================================================
--- trunk/libpisa/checksum.h    Thu Nov 12 12:53:03 2009        (r1651)
+++ trunk/libpisa/checksum.h    Thu Nov 12 12:59:29 2009        (r1652)
@@ -17,24 +17,24 @@
 
 /**
  * Fold a 32-bit checksum into a 16-bit checksum.
- * @param c checksum that will be folded
+ * @param checksum checksum that will be folded
  * @return folded checksum (16 bit)
  */
-static inline uint16_t pisa_csum_fold(uint32_t c)
+static inline uint16_t pisa_csum_fold(uint32_t checksum)
 {
-       while (c >> 16)
-               c = (c & 0xffff) + (c >> 16);
-       return c;
+       while (checksum >> 16)
+               checksum = (checksum & 0xffff) + (checksum >> 16);
+       return checksum;
 }
 
 /**
  * Unfold a 16-bit checksum into a 32-bit checksum.
- * @param c checksum that will be unfolded
+ * @param checksum checksum that will be unfolded
  * @return unfolded checksum (32 bit)
  */
-static inline uint32_t pisa_csum_unfold(uint16_t c)
+static inline uint32_t pisa_csum_unfold(uint16_t checksum)
 {
-       return (uint32_t) c;
+       return (uint32_t) checksum;
 }
 
 /**
@@ -45,12 +45,12 @@
  *     should be replaced.
  * @param after 4 bytes that will become part of the new checksum.
  */
-static inline void pisa_csum_replace4(uint16_t *addr, uint32_t before, 
uint32_t after)
+static inline void pisa_csum_replace4(uint16_t *checksum, uint32_t before, 
uint32_t after)
 {
-       uint32_t csum = pisa_csum_unfold(~*addr);
-       csum += ((~before) & 0xffff) + ((~before) >> 16);
-       csum += (after & 0xffff) + (after >> 16);
-       *addr = ~pisa_csum_fold(csum);
+       uint32_t checksum_new = pisa_csum_unfold(~*checksum);
+       checksum_new += ((~before) & 0xffff) + ((~before) >> 16);
+       checksum_new += (after & 0xffff) + (after >> 16);
+       *checksum = ~pisa_csum_fold(checksum_new);
 }
 
 #endif /* PISA_CHECKSUM_H */

Other related posts:

  • » [pisa-src] r1652 - trunk/libpisa/checksum.h - Thomas Jansen