Mercurial > gnulib
comparison tests/test-memmem.c @ 40214:452ab00796c7
Fix undefined behaviour.
* lib/bitrotate.h (rotl16, rotr16, rotl8, rotr8): Case x to
'unsigned int', to avoid shift operations on 'int'.
* lib/xmemdup0.c (xmemdup0): Don't invoke memcpy with a zero size.
* tests/test-count-leading-zeros.c (main): Use a random number that has
as many bits as TYPE, not only 2*15 or 2*31 bits.
* tests/test-count-trailing-zeros.c (main): Likewise.
* tests/test-count-one-bits.c (main): Likewise.
* tests/test-memmem.c: Don't include "null-ptr.h".
(main): Use zerosize_ptr() instead of null_ptr().
* modules/memmem-tests (Files): Remove tests/null-ptr.h.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 09 Mar 2019 20:32:25 +0100 |
parents | b06060465f09 |
children |
comparison
equal
deleted
inserted
replaced
40213:cc3fed3b7788 | 40214:452ab00796c7 |
---|---|
24 | 24 |
25 #include <signal.h> | 25 #include <signal.h> |
26 #include <stdlib.h> | 26 #include <stdlib.h> |
27 #include <unistd.h> | 27 #include <unistd.h> |
28 | 28 |
29 #include "null-ptr.h" | |
30 #include "zerosize-ptr.h" | 29 #include "zerosize-ptr.h" |
31 #include "macros.h" | 30 #include "macros.h" |
32 | 31 |
33 int | 32 int |
34 main (int argc, char *argv[]) | 33 main (int argc, char *argv[]) |
79 ASSERT (result == NULL); | 78 ASSERT (result == NULL); |
80 } | 79 } |
81 | 80 |
82 { | 81 { |
83 const char input[] = "foo"; | 82 const char input[] = "foo"; |
84 const char *result = memmem (input, strlen (input), null_ptr (), 0); | 83 const char *result = memmem (input, strlen (input), zerosize_ptr (), 0); |
85 ASSERT (result == input); | 84 ASSERT (result == input); |
86 } | 85 } |
87 | 86 |
88 /* Check that a long periodic needle does not cause false positives. */ | 87 /* Check that a long periodic needle does not cause false positives. */ |
89 { | 88 { |