From: Laszlo Ersek <lersek@redhat.com>
To: afaerber@suse.de, mdroth@linux.vnet.ibm.com, pbonzini@redhat.com,
qemu-devel@nongnu.org, lersek@redhat.com
Subject: [Qemu-devel] [PATCH qom-next] qapi: exclude negative values in uint*_t Visitor interfaces
Date: Wed, 6 Jun 2012 18:00:27 +0200 [thread overview]
Message-ID: <1338998427-13253-1-git-send-email-lersek@redhat.com> (raw)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
(To be applied on top of 0f2de4a8.)
qapi/qapi-visit-core.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 9a29674..81f697f 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -106,7 +106,7 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
} else {
value = *obj;
v->type_int(v, &value, name, errp);
- if (value > UINT8_MAX) {
+ if (value < 0 || value > UINT8_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint8_t");
return;
@@ -125,7 +125,7 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp
} else {
value = *obj;
v->type_int(v, &value, name, errp);
- if (value > UINT16_MAX) {
+ if (value < 0 || value > UINT16_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint16_t");
return;
@@ -144,7 +144,7 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp
} else {
value = *obj;
v->type_int(v, &value, name, errp);
- if (value > UINT32_MAX) {
+ if (value < 0 || value > UINT32_MAX) {
error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
"uint32_t");
return;
@@ -163,6 +163,11 @@ void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp
} else {
value = *obj;
v->type_int(v, &value, name, errp);
+ if (value < 0) {
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
+ "uint64_t");
+ return;
+ }
*obj = value;
}
}
--
1.7.1
next reply other threads:[~2012-06-06 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-06 16:00 Laszlo Ersek [this message]
2012-06-06 16:30 ` [Qemu-devel] [PATCH qom-next] qapi: exclude negative values in uint*_t Visitor interfaces Michael Roth
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=1338998427-13253-1-git-send-email-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=afaerber@suse.de \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).