Skip to contentSkip to conversation

virtiofsd: move assert just after calloc()

PATCH In review piaojun 2 participants 2 messages Aug 5, 2019 – Aug 14, 2019

lore
Share & tools
lore

piaojun

author
#0 lore raw

PATCH 1/1 virtiofsd: move assert just after calloc()

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

---
 contrib/virtiofsd/fuse_virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/virtiofsd/fuse_virtio.c +1 -1
index d543c6d..8a4f627 100644
@@ -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);
#1 lore raw
Quoted 3 lines · * piaojun ([email protected]) wrote:

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

Thanks, squashed into 'virtiofsd: Start queue threads'

Dave

Quoted 25 lines
---
 contrib/virtiofsd/fuse_virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/virtiofsd/fuse_virtio.c +1 -1
index d543c6d..8a4f627 100644
@@ -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);
Signature · 4 lines
_______________________________________________
Virtio-fs mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virtio-fs

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK