]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r328237:
authorhselasky <hselasky@FreeBSD.org>
Wed, 7 Feb 2018 15:06:54 +0000 (15:06 +0000)
committerhselasky <hselasky@FreeBSD.org>
Wed, 7 Feb 2018 15:06:54 +0000 (15:06 +0000)
commit95f395e1bf1d833593f8e7531972a9a3f4ffb16d
treecfde50996f7f91ce7e3c49b04d798ad14764da1e
parented03e6abd0f7fe4a4e615b0dcdbb4cfa31979dbc
MFC r328237:
Use the __alloc_size2 attribute where relevant.

This follows the documented use in GCC. It is basically only relevant for
calloc(3), reallocarray(3) and  mallocarray(9).

NOTE: Without this change clang 5.0.1 can produce incorrect optimisation
code for static processing of data using the allocated object. For example
this has been seen compiling the mlx4 core module, which allocates a
fixed size array which is then sorted by a fixed order loop. The
optimised result, -O2, is incorrect unless this patch is in place.

Suggested by: Mark Millard
Reference: https://docs.freebsd.org/cgi/mid.cgi?9DE674C6-EAA3-4E8A-906F-446E74D82FC4
include/stdlib.h
sys/sys/malloc.h