[sheepdog] [PATCH] sheepfs: Add the check in volume_remove_entry
Hitoshi Mitake
mitake.hitoshi at gmail.com
Thu Jun 25 15:54:21 CEST 2015
At Thu, 25 Jun 2015 19:36:36 +0800,
Ziye Yang wrote:
>
> This patch is used to check whether vdi is valid
>
> Signed-off-by: Ziye Yang <ziye.yang at intel.com>
> ---
> sheepfs/volume.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Applied, thanks. I have some comments for potential problems below.
>
> diff --git a/sheepfs/volume.c b/sheepfs/volume.c
> index d43304c..b8c2469 100644
> --- a/sheepfs/volume.c
> +++ b/sheepfs/volume.c
> @@ -512,7 +512,7 @@ int volume_remove_entry(const char *entry)
> {
> char path[PATH_MAX], *ch;
> uint32_t vid;
> - struct vdi_inode *vdi;
> + struct vdi_inode *vdi = NULL;
>
> ch = strchr(entry, '\n');
> if (ch != NULL)
> @@ -531,6 +531,10 @@ int volume_remove_entry(const char *entry)
> sd_read_lock(&vdi_inode_tree_lock);
> vdi = vdi_inode_tree_search(vid);
> sd_rw_unlock(&vdi_inode_tree_lock);
> +
> + if(!vdi)
> + return -1;
The above condition means bugs in sheepfs. Could you enhance your
intention with unlikely() macro? In addition, adding the check to
other callers would be helpful.
Thanks,
Hitoshi
> +
> destroy_socket_pool(vdi->socket_pool, SOCKET_POOL_SIZE);
>
> sd_write_lock(&vdi_inode_tree_lock);
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> https://lists.wpkg.org/mailman/listinfo/sheepdog
More information about the sheepdog
mailing list