[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
crc: gcc warnings
From: |
Bruno Haible |
Subject: |
crc: gcc warnings |
Date: |
Thu, 31 Oct 2024 22:23:44 +0100 |
Hi Simon,
Compiling a testdir of module 'crc' with "gcc -Wall", I see these warnings:
gcc -ftrapv -DHAVE_CONFIG_H -I. -I../../gltests -I..
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib
-I/media/develdata/devel/inst-x86_64-64/include -Wall -Wno-error -g -O2 -MT
test-crc.o -MD -MP -MF .deps/test-crc.Tpo -c -o test-crc.o
../../gltests/test-crc.c
../../gltests/test-crc.c: In function ‘main’:
../../gltests/test-crc.c:106:35: warning: pointer targets in passing argument 2
of ‘crc32_update_no_xor’ differ in signedness [-Wpointer-sign]
106 | p = crc32_update_no_xor (0, randomb, MAX_ALIGNMENT + i);
| ^~~~~~~
| |
| const unsigned char *
In file included from ../../gltests/test-crc.c:21:
../../gltests/../gllib/crc.h:52:48: note: expected ‘const char *’ but argument
is of type ‘const unsigned char *’
52 | crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
| ~~~~~~~~~~~~^~~
../../gltests/test-crc.c:119:43: warning: pointer targets in passing argument 2
of ‘crc32_update_no_xor’ differ in signedness [-Wpointer-sign]
119 | p = crc32_update_no_xor (0, randomb + i, (MAX_ALIGNMENT * 2) - i);
| ~~~~~~~~^~~
| |
| const unsigned char *
In file included from ../../gltests/test-crc.c:21:
../../gltests/../gllib/crc.h:52:48: note: expected ‘const char *’ but argument
is of type ‘const unsigned char *’
52 | crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
| ~~~~~~~~~~~~^~~
mv -f .deps/test-crc.Tpo .deps/test-crc.Po
I think that the proper fix is to change the prototypes of the 4 functions
in crc.h from 'const char *buf' to 'const void *buf'. Just like memset(),
memcmp(), etc. take 'void *', not 'char *', parameters.
What do you think?
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- crc: gcc warnings,
Bruno Haible <=