2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

net/sysctl: put common multiplier outside the brackets

Also add an explanation of the logic behind this calculation.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov 2025-01-16 10:25:24 +08:00 committed by Pavel Tikhomirov
parent 7eaf43368d
commit 7f35e46e9d

View File

@ -2149,10 +2149,16 @@ static int dump_netns_conf(struct ns_id *ns, struct cr_imgset *fds)
list_for_each_entry(p, &ns->net.ids, node)
i++;
/*
* Here we allocate one single big buffer for storing multiple arrays
* of protobuf entries and pointers to entries in it and we later use
* xptr_pull_s to claim a part of this buffer of proper size for each
* particular array. Next we read data from sysctl files to those
* arrays and then finally save them into images.
*/
o_buf = buf = xmalloc(i * (sizeof(NetnsId *) + sizeof(NetnsId)) +
size4 * (sizeof(SysctlEntry *) + sizeof(SysctlEntry)) * 2 +
size6 * (sizeof(SysctlEntry *) + sizeof(SysctlEntry)) * 2 +
sizex * (sizeof(SysctlEntry *) + sizeof(SysctlEntry)));
(size4 * 2 + size6 * 2 + sizex) *
(sizeof(SysctlEntry *) + sizeof(SysctlEntry)));
if (!buf)
goto out;