Eric Blake <[EMAIL PROTECTED]> writes: > Any objections against this patch? I ask because it intentionally > violates the C99 constraint of not reading beyond the end of an array. > However, the excess read can only occur on the final longword of an array, > and only with an aligned longword read, so on all hardware I know of, the > read won't fault even though it reads more bytes than strictly necessary; > people accessing volatile I/O memory with side effects on read should not > be using strchrnul in the first place. This code gives a much faster > search than the original byte-wise approach.
This approach will cause false-positive warnings under memory debuggers such as Valgrind. However, anyone who notices such a warning should be able to spot from the comments in the function that it is still correct code given the assumption you have above, so I don't think that is a big deal. -- Ben Pfaff http://benpfaff.org