HomeFreeBSD

Fix null pointer subtraction in mergesort()

Description

Fix null pointer subtraction in mergesort()

Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]

if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                       ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

MFC after: 3 days

Details

Provenance
dimAuthored on Aug 27 2021, 5:45 PM
Parents
R10:fd80208a5f92: Add SDT probes virtqueue::enqueue_segments:{entry,return}
Branches
Unknown
Tags
Unknown