提交 53b40056 编写于 作者: L Li Hongzhang

fix codedex report errors

上级 e4c3b5bd
...@@ -293,10 +293,10 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char *data, size_t size) { ...@@ -293,10 +293,10 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char *data, size_t size) {
auto *bp_align = reinterpret_cast<const uint8_t *>(MEM_ALIGN(pval, 2)); auto *bp_align = reinterpret_cast<const uint8_t *>(MEM_ALIGN(pval, 2));
// process the not alignment bits when size < 4 byte // process the not alignment bits when size < 4 byte
if (bp_align <= ep) { if (bp_align <= ep && bp < bp_align) {
// Process bytes until finished or p is 4-byte aligned // Process bytes until finished or p is 4-byte aligned
while (bp != bp_align) { while (bp != bp_align) {
crc = crc_table_o32[(crc & 0xFF) ^ (*bp++)] ^ (crc >> 8); crc = crc_table_o32[(crc ^ (*bp++)) & 0xFF] ^ (crc >> 8);
} }
} }
...@@ -307,7 +307,7 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char *data, size_t size) { ...@@ -307,7 +307,7 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char *data, size_t size) {
// Process the last not alignment bytes // Process the last not alignment bytes
while (bp < ep) { while (bp < ep) {
crc = crc_table_o32[(crc & 0xFF) ^ (*bp++)] ^ (crc >> 8); crc = crc_table_o32[(crc ^ (*bp++)) & 0xFF] ^ (crc >> 8);
} }
return crc ^ 0xFFFFFFFFU; return crc ^ 0xFFFFFFFFU;
} }
...@@ -53,7 +53,7 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char* data, size_t size); ...@@ -53,7 +53,7 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char* data, size_t size);
// A function return the crc32c value // A function return the crc32c value
uint32_t GetMaskCrc32cValue(const char* data, size_t n) { uint32_t GetMaskCrc32cValue(const char* data, size_t n) {
if (data == nullptr && n > 0) { if (data == nullptr) {
// Return early to prevent MakeCrc32c resulting in segmentfault // Return early to prevent MakeCrc32c resulting in segmentfault
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册