]> Savannah Git Hosting - gnulib.git/commit
rawmemchr: modernize and simplify
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 21 Aug 2021 02:25:06 +0000 (19:25 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 21 Aug 2021 02:25:56 +0000 (19:25 -0700)
commitb8ae80b252a4638c52c8f03bbf16b9c8d6bf27de
tree563639f83badc37b99924af9d1ea5595b7d340d6
parenta38c80d8465dc8dfee5b32984a95833d2970c752
rawmemchr: modernize and simplify

* lib/rawmemchr.c (HAVE_RAWMEMCHR): Assume it’s not defined;
otherwise this file would not be compiled.  Include limits.h,
stdalign.h, stdint.h, verify.h.
(rawmemchr): Prefer uintptr_t to unsigned long and to size_t when
it’s the better type.  Verify that longword lacks padding.  Use
alignof rather than sizeof when checking alignment.  Simplify by
assuming C99 decl-after-statement, and by using multiplication
rather than repeated shifting and OR (modern compilers can
optimize the multiplication if needed).  Avoid unnecessary casts.
Don’t assume CHAR_WIDTH is 8.  Convert back and forth between void *
to suppress bogus GCC warnings about alignment.  Omit a
duplicate assignment to char_ptr.
* modules/rawmemchr (Depends-on): Add stdalign, stdint, verify.
ChangeLog
lib/rawmemchr.c
modules/rawmemchr