[dpdk-dev] [PATCH v12 02/12] librte_pcapng: add new library for writing pcapng files

Stephen Hemminger stephen at networkplumber.org
Fri Oct 15 19:40:26 CEST 2021


On Fri, 15 Oct 2021 09:36:00 +0000
"Pattan, Reshma" <reshma.pattan at intel.com> wrote:

> > +	buf = calloc(1, len);
> > +	if (!buf)
> > +		return -1;  
> 
> How about returning -ENOMEM

It could but not necessary.
The other code is returning result of write and therefore would be -1 on
write error.

This is in internal local function and the only caller is just checking for < 0.

PS: In reality, malloc can't fail on Linux. Process gets oom killed instead
(unless someone has gone and tweaked the memory allocator to not overcommit).


More information about the dev mailing list