On Wed, Nov 10, 2021 at 02:36:18PM +0100, Laszlo Ersek wrote:
How about:
if (ADD_SIZE_T_OVERFLOW (v->cap, 1, &newcap) ||
ADD_SIZE_T_OVERFLOW (v->cap, newcap / 2, &newcap) ||
MUL_SIZE_T_OVERFLOW (newcap, itemsize, &newbytes) ||
newbytes < reqbytes) {
/* If that either overflows or is less than the minimum requested,
* fall back to the requested capacity.
*/
...
}
Oh that's a lot better. Let me do that instead ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top