[tz] [PROPOSED 1/7] Avoid undefined behavior if no Link lines

Paul Eggert eggert at cs.ucla.edu
Wed Oct 26 17:58:22 UTC 2022


On 2022-10-26 07:54, Jonathan Leffler wrote:
> There's no need to sort arrays of size 0 or 1.

Good point, thanks. I installed the first attached patch to do that. The 
second patch just fixes spacing as a style matter.

Although there's a similar issue with bsearch and arrays with zero 
members, I didn't add a size-zero check there, as the base pointer must 
be nonnull when bsearch is called, the C standard says that bsearch does 
the right thing if you give it a valid non-null pointer and a zero 
nmemb, and I didn't see much point to adding an optimization there. 
Whereas with qsort, the base pointer might be null so the code must 
check for either a null pointer or size zero anyway, so why not check 
for size 1 as that's nearly as cheap and arguably clearer?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Tune-qsort-usage-slightly.patch
Type: text/x-patch
Size: 1129 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20221026/6c196a21/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-zic.c-No-space-before-paren.patch
Type: text/x-patch
Size: 1044 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20221026/6c196a21/attachment-0001.bin>


More information about the tz mailing list