Welcome! Log In Create A New Profile

Advanced

[PATCH] fix -Wsign-conversion warning with gcc 8.2

Sinan Kaya
March 14, 2022 04:44PM
# HG changeset patch
# User Sinan Kaya <sinan.kaya@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;
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] fix -Wsign-conversion warning with gcc 8.2

Sinan Kaya 679 March 14, 2022 04:44PM

Re: [PATCH] fix -Wsign-conversion warning with gcc 8.2

Andres Beltran 53 May 26, 2022 05:44PM

Re: [PATCH] fix -Wsign-conversion warning with gcc 8.2

Maxim Dounin 59 May 26, 2022 10:44PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 133
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready