All of lore.kernel.org
 help / color / mirror / Atom feed
* [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc()
@ 2019-08-05  1:53 piaojun
  2019-08-14 17:14 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: piaojun @ 2019-08-05  1:53 UTC (permalink / raw)
  To: virtio-fs

It's better to assert NULL pointer just after calloc().

Signed-off-by: Jun Piao <piaojun@huawei.com>
---
 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);
-- 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc()
  2019-08-05  1:53 [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc() piaojun
@ 2019-08-14 17:14 ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Dr. David Alan Gilbert @ 2019-08-14 17:14 UTC (permalink / raw)
  To: piaojun; +Cc: virtio-fs

* piaojun (piaojun@huawei.com) wrote:
> It's better to assert NULL pointer just after calloc().
> 
> Signed-off-by: Jun Piao <piaojun@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@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-14 17:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-05  1:53 [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc() piaojun
2019-08-14 17:14 ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.