[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YQirECZyPrR791AS@mit.edu>
Date: Mon, 2 Aug 2021 22:33:52 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: wuguanghao <wuguanghao3@...wei.com>
Cc: linux-ext4@...r.kernel.org, linfeilong@...wei.com,
liuzhiqiang26@...wei.com
Subject: Re: [PATCH v3 10/12] hashmap: change return value type of
ext2fs_hashmap_add()
On Wed, Jul 28, 2021 at 09:56:47AM +0800, wuguanghao wrote:
> From: Zhiqiang Liu <liuzhiqiang26@...wei.com>
>
> 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 <liuzhiqiang26@...wei.com>
> Signed-off-by: Wu Guanghao <wuguanghao3@...wei.com>
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
Powered by blists - more mailing lists