Simon Josefsson wrote:
> > 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?
> 
> Ouch.  Ideally maybe uint8_t should have been used, but both uint8_t and
> void* is an API change compared to current char*.

While the crc _implementation_ uses uint8_t*, from the caller's perspective:
the caller passes the bounds of some region of memory. Whether these are
'unsigned char' values, 'char' values, 'bool' values, or even a struct that
represents a network packet, the crc functions are made for all of these,
right?

What is the problem with changing the 'const char *' to 'const void *'?
All callers that call the functions directly will be fine. Only code that
uses function pointers will need change. For crc32_update, crc32_no_xor,
crc32_update_no_xor, no such uses exist; for crc32, my guess is that no
such uses exist either.

> How about patching
> test-crc.c to pass a char* to these functions, as they should receive?

To me, that would be a not-so-good fix.

Bruno

[1] 
https://codesearch.debian.net/search?q=%5Cbcrc32_update%5Cb%5B%5E+%28%5D+-path%3Acrc.h+-path%3Acrc.c+-path%3AChangeLog&literal=0
[2] 
https://codesearch.debian.net/search?q=crc32_no_xor+-path%3Acrc.h+-path%3Acrc.c&literal=1
[3] 
https://codesearch.debian.net/search?q=crc32_update_no_xor+-path%3Acrc.h+-path%3Acrc.c&literal=1




Reply via email to