Closed mschulz-at-hilscher closed 5 months ago
Btw. where is memcmp_s defined in the C standard? I did not find it in https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1172.pdf
I was wondering why diff
in memcmp_s(const void *dest, rsize_t dmax, const void *src, rsize_t slen, int *diff)
is defined as int
and not as ssize_t for example.
PR would be nice, thanks.
Ad ssize_t: Our memcmp_is an extension, thus only int. Preventing DOS. https://en.cppreference.com/w/c/string/byte/memcmp
Ad ssize_t: Our memcmp_is an extension, thus only int. Preventing DOS. https://en.cppreference.com/w/c/string/byte/memcmp
Shall I then change the tests to use int
s instead of int32_t
s in the tests when I create a PR? Or would it be better to get rid of int
completely and change the API to use ssize_t
instead?
Yes, int please
When compiling for systems where types such as int32_t are unequal to int (e.g., long int), then compilation fails. Please, use the defines from inttypes.h when defining format strings.
For example:
If you want, I could also create a PR with the required changes. During configure one would need to check that inttypes.h is available and otherwise fallback to default definitions assuing that int32_t equals int, for example.
Alternatively, one could define variables as int instead of int32_t if this type is expected by the APIs anyways.