From: Michael Gernoth Date: Tue, 27 Jan 2009 23:54:58 +0000 (+0100) Subject: make crc implementation a bit more readable X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/c8b1eccb76b5f4141da32b74c68468eaa87c7972 make crc implementation a bit more readable --- diff --git a/rsb-crc.c b/rsb-crc.c index 84b7fa2..fa40c49 100644 --- a/rsb-crc.c +++ b/rsb-crc.c @@ -34,31 +34,31 @@ * 4c4: DATA: 0x04c11db7 */ -unsigned int rsb_crc(unsigned int r11, unsigned char *r10, unsigned int r14) { - unsigned int r6 = 0; - unsigned int r3; - int r5; +unsigned int rsb_crc(unsigned int r11_crc, unsigned char *r10_buf, unsigned int r14_len) { + unsigned int r6_pos = 0; + unsigned int r3_data; + int r5_bit; - while (r6 < r14) { - r3 = (*(r6+r10)) << 24; - r11 = r11 ^ r3; + while (r6_pos < r14_len) { + r3_data = (*(r6_pos+r10_buf)) << 24; + r11_crc = r11_crc ^ r3_data; - r5 = 8; + r5_bit = 8; do { - r3 = r11 & 0x80000000; + r3_data = r11_crc & 0x80000000; - if (r3 != 0) { - r3 = r11 << 1; - r11 = r3 ^ POLY; + if (r3_data != 0) { + r3_data = r11_crc << 1; + r11_crc = r3_data ^ POLY; } else { - r11 = r11 << 1; + r11_crc = r11_crc << 1; } - r5--; - } while (r5); + r5_bit--; + } while (r5_bit); - r6++; + r6_pos++; } - return r11; + return r11_crc; }