From: piaojun <piaojun@huawei.com>
To: virtio-fs@redhat.com
Subject: [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc()
Date: Mon, 5 Aug 2019 09:53:23 +0800 [thread overview]
Message-ID: <5D478C13.3020406@huawei.com> (raw)
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);
--
next reply other threads:[~2019-08-05 1:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 1:53 piaojun [this message]
2019-08-14 17:14 ` [Virtio-fs] [PATCH] virtiofsd: move assert just after calloc() Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5D478C13.3020406@huawei.com \
--to=piaojun@huawei.com \
--cc=virtio-fs@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.