crc32c: use uint_t types

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2017-01-05 14:39:15 +01:00
parent 55eacac425
commit 443b104833
3 changed files with 10 additions and 10 deletions

View File

@@ -355,7 +355,7 @@ void* iscsi_smalloc(struct iscsi_context *iscsi, size_t size);
void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size); void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size);
void iscsi_sfree(struct iscsi_context *iscsi, void* ptr); void iscsi_sfree(struct iscsi_context *iscsi, void* ptr);
unsigned long crc32c(char *buf, int len); uint32_t crc32c(uint8_t *buf, int len);
struct scsi_task *iscsi_scsi_get_task_from_pdu(struct iscsi_pdu *pdu); struct scsi_task *iscsi_scsi_get_task_from_pdu(struct iscsi_pdu *pdu);

View File

@@ -43,7 +43,7 @@
/* */ /* */
/*****************************************************************/ /*****************************************************************/
static unsigned long crctable[256] = { uint32_t crctable[256] = {
0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L,
0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL,
0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL,
@@ -110,9 +110,9 @@ static unsigned long crctable[256] = {
0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L
}; };
unsigned long crc32c(char *buf, int len) uint32_t crc32c(uint8_t *buf, int len)
{ {
unsigned long crc = 0xffffffff; uint32_t crc = 0xffffffff;
while (len-- > 0) { while (len-- > 0) {
crc = (crc>>8) ^ crctable[(crc ^ (*buf++)) & 0xFF]; crc = (crc>>8) ^ crctable[(crc ^ (*buf++)) & 0xFF];
} }

View File

@@ -677,7 +677,7 @@ iscsi_read_from_socket(struct iscsi_context *iscsi)
static int iscsi_pdu_update_headerdigest(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) static int iscsi_pdu_update_headerdigest(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{ {
unsigned long crc; uint32_t crc;
if (pdu->outdata.size < ISCSI_RAW_HEADER_SIZE + ISCSI_DIGEST_SIZE) { if (pdu->outdata.size < ISCSI_RAW_HEADER_SIZE + ISCSI_DIGEST_SIZE) {
iscsi_set_error(iscsi, "PDU too small (%u) to contain header digest", iscsi_set_error(iscsi, "PDU too small (%u) to contain header digest",
@@ -685,12 +685,12 @@ static int iscsi_pdu_update_headerdigest(struct iscsi_context *iscsi, struct isc
return -1; return -1;
} }
crc = crc32c((char *)pdu->outdata.data, ISCSI_RAW_HEADER_SIZE); crc = crc32c(pdu->outdata.data, ISCSI_RAW_HEADER_SIZE);
pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+3] = (crc >> 24)&0xff; pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+3] = (crc >> 24);
pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+2] = (crc >> 16)&0xff; pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+2] = (crc >> 16);
pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+1] = (crc >> 8)&0xff; pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+1] = (crc >> 8);
pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+0] = (crc) &0xff; pdu->outdata.data[ISCSI_RAW_HEADER_SIZE+0] = (crc);
return 0; return 0;
} }