[Virtio-fs] [PATCH] virtiofsd: move assert just after calloc()

Dr. David Alan Gilbert dgilbert at redhat.com
Wed Aug 14 17:14:43 UTC 2019


* piaojun (piaojun at huawei.com) wrote:
> It's better to assert NULL pointer just after calloc().
> 
> Signed-off-by: Jun Piao <piaojun at huawei.com>

Thanks, squashed into 'virtiofsd: Start queue threads'

Dave

> ---
>  contrib/virtiofsd/fuse_virtio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/contrib/virtiofsd/fuse_virtio.c b/contrib/virtiofsd/fuse_virtio.c
> index d543c6d..8a4f627 100644
> --- a/contrib/virtiofsd/fuse_virtio.c
> +++ b/contrib/virtiofsd/fuse_virtio.c
> @@ -748,9 +748,9 @@ static void fv_queue_set_started(VuDev *dev, int qidx, bool started)
>                  }
>                  if (!vud->qi[qidx]) {
>                          vud->qi[qidx] = calloc(sizeof(struct fv_QueueInfo), 1);
> +                        assert(vud->qi[qidx]);
>                          vud->qi[qidx]->virtio_dev = vud;
>                          vud->qi[qidx]->qidx = qidx;
> -                        assert(vud->qi[qidx]);
>                  } else {
>                          /* Shouldn't have been started */
>                          assert(vud->qi[qidx]->kick_fd == -1);
> -- 
> 
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs at redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
--
Dr. David Alan Gilbert / dgilbert at redhat.com / Manchester, UK




More information about the Virtio-fs mailing list