Thread (9 messages) 9 messages, 2 authors, 2021-08-03

Re: [PATCH v3 10/12] hashmap: change return value type of ext2fs_hashmap_add()

From: "Theodore Ts'o" <tytso@mit.edu>
Date: 2021-08-03 02:34:01

On Wed, Jul 28, 2021 at 09:56:47AM +0800, wuguanghao wrote:
From: Zhiqiang Liu <redacted>

In ext2fs_hashmap_add(), new entry is allocated by calling
malloc(). If malloc() return NULL, it will cause a
segmentation fault problem.

Here, we change return value type of ext2fs_hashmap_add()
from void to int. If allocating new entry fails, we will
return 1, and the callers should also verify the return
value of ext2fs_hashmap_add().

Signed-off-by: Zhiqiang Liu <redacted>
Signed-off-by: Wu Guanghao <redacted>
Thanks, applied.

Note: I changed ext2fs_hashmap_add() to return an int instead of an
errocode_t.  The commit description said it was going to be an int,
and the code returns -1 (so I fixed the commit description to reflect
-1).  Note that errcode_t is not appropriate for non-errno / com_err
error codes.  So making the function prototype of hashmap_add() to
return an int is the correct thing to do.

Cheers,

					- Ted
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help