[PATCH] fix -Wsign-conversion warning with gcc 8.2
Sinan Kaya
okaya at kernel.org
Mon Mar 14 20:42:15 UTC 2022
# HG changeset patch
# User Sinan Kaya <sinan.kaya at microsoft.com>
# Date 1647289518 14400
# Mon Mar 14 16:25:18 2022 -0400
# Node ID f22520b612969dbfa17205129510927519370000
# Parent a736a7a613ea6e182ff86fbadcb98bb0f8891c0b
fix -Wsign-conversion warning with gcc 8.2
Getting compiler warning with -Wsign-conversion.
/usr/include/nginx/core/ngx_crc32.h:31:47: warning: conversion to
'uint32_t' {aka 'unsigned int'} from 'int' may change the sign of the
result [-Wsign-conversion]
31 | crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^
(crc >> 4);
diff -r a736a7a613ea -r f22520b61296 src/core/ngx_crc32.h
--- a/src/core/ngx_crc32.h Tue Feb 08 17:35:27 2022 +0300
+++ b/src/core/ngx_crc32.h Mon Mar 14 16:25:18 2022 -0400
@@ -28,7 +28,8 @@
while (len--) {
c = *p++;
crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4);
- crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4);
+ crc = ngx_crc32_table_short[(crc ^ (u_char)(c >> 4)) & 0xf];
+ crc = crc ^ (crc >> 4);
}
return crc ^ 0xffffffff;
More information about the nginx-devel
mailing list