]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/crc32c_intel_baseline: accept null data buffer
authorSage Weil <sage@inktank.com>
Sat, 28 Sep 2013 04:03:28 +0000 (21:03 -0700)
committerSage Weil <sage@inktank.com>
Wed, 16 Oct 2013 16:28:14 +0000 (09:28 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/crc32c_intel_baseline.c

index 3a92c77b63cb12e93ffcbafe951391b70872b637..390898171df6a553f312a6421bf96fd8ffa70c8e 100644 (file)
@@ -115,13 +115,21 @@ uint32_t ceph_crc32c_intel_baseline(uint32_t crc_init2, unsigned char const *buf
        unsigned int crc;
        unsigned char* p_buf;
 
-       p_buf = (unsigned char*)buffer;
-       unsigned char const * p_end = buffer + len;
+       if (buffer) {
+               p_buf = (unsigned char*)buffer;
+               unsigned char const * p_end = buffer + len;
 
-       crc = crc_init;
+               crc = crc_init;
+
+               while (p_buf < (unsigned char *) p_end ){
+                       crc = (crc >> 8) ^ crc32_table_iscsi_base[(crc & 0x000000FF) ^ *p_buf++];
+               }
+       } else {
+               crc = crc_init;
+               while (len--) {
+                       crc = (crc >> 8) ^ crc32_table_iscsi_base[(crc & 0x000000FF)];
+               }
 
-       while(p_buf < (unsigned char *) p_end ){
-               crc = (crc >> 8) ^ crc32_table_iscsi_base[(crc & 0x000000FF) ^ *p_buf++] ;
        }
        return crc;      
 }