[PATCH v10 1/5] PID namespace translation support

Dmitry V. Levin ldv at altlinux.org
Sat Aug 22 17:52:27 UTC 2020


On Wed, Aug 19, 2020 at 08:16:33PM +0200, Ákos Uzonyi wrote:
[...]
> +static uint64_t *
> +trie_get_node(struct trie *t, uint64_t key, bool auto_create)
> +{
> +	void **cur_node = &(t->data);
> +
> +	if (t->key_size < 64 && key > (uint64_t) 1 << t->key_size)
> +		return NULL;
> +
> +	for (uint8_t cur_depth = 0; cur_depth <= t->max_depth; cur_depth++) {
> +		uint8_t offs = trie_get_node_bit_offs(t, cur_depth);
> +		uint8_t sz = trie_get_node_size(t, cur_depth);
> +
> +		if (!*cur_node) {
> +			if (!auto_create)
> +				return NULL;
> +
> +			if (cur_depth == t->max_depth)
> +				*cur_node = trie_create_data_block(t);
> +			else
> +				*cur_node = calloc(1 << sz, 1);
> +
> +			if (!*cur_node) {
> +				fprintf(stderr, "Out of memory");
> +				exit(1);
> +			}

This should rather be error_msg_and_die("Out of memory");

Or better use xcalloc instead of calloc here and in
trie_create_data_block.


-- 
ldv


More information about the Strace-devel mailing list