From: Chen Gang <gang.chen.5i5j@gmail.com>
To: mjt@tls.msk.ru, quintela@redhat.com, owasserm@redhat.com,
pbonzini@redhat.com, mst@redhat.com,
Eric Blake <eblake@redhat.com>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-trivial] [PATCH] arch_init: Simplify code for load_xbzrle()
Date: Sat, 10 May 2014 20:51:24 +0800 [thread overview]
Message-ID: <536E20CC.4030401@gmail.com> (raw)
For xbzrle_decode_buffer(), when decoding contents will exceed writing
buffer, it will return -1, so need not check the return value whether
large than writing buffer.
And when failure occurs within load_xbzrle(), it always return -1
without any resources which need release.
So can remove the related checking statements, and also can remove 'rc'
and 'ret' local variables,
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
arch_init.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 60c975d..98ee5b6 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -908,7 +908,6 @@ static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
{
- int ret, rc = 0;
unsigned int xh_len;
int xh_flags;
@@ -933,18 +932,13 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
qemu_get_buffer(f, xbzrle_decoded_buf, xh_len);
/* decode RLE */
- ret = xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
- TARGET_PAGE_SIZE);
- if (ret == -1) {
+ if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
+ TARGET_PAGE_SIZE) == -1) {
fprintf(stderr, "Failed to load XBZRLE page - decode error!\n");
- rc = -1;
- } else if (ret > TARGET_PAGE_SIZE) {
- fprintf(stderr, "Failed to load XBZRLE page - size %d exceeds %d!\n",
- ret, TARGET_PAGE_SIZE);
- abort();
+ return -1;
}
- return rc;
+ return 0;
}
static inline void *host_from_stream_offset(QEMUFile *f,
--
1.7.11.7
WARNING: multiple messages have this Message-ID (diff)
From: Chen Gang <gang.chen.5i5j@gmail.com>
To: mjt@tls.msk.ru, quintela@redhat.com, owasserm@redhat.com,
pbonzini@redhat.com, mst@redhat.com,
Eric Blake <eblake@redhat.com>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] arch_init: Simplify code for load_xbzrle()
Date: Sat, 10 May 2014 20:51:24 +0800 [thread overview]
Message-ID: <536E20CC.4030401@gmail.com> (raw)
For xbzrle_decode_buffer(), when decoding contents will exceed writing
buffer, it will return -1, so need not check the return value whether
large than writing buffer.
And when failure occurs within load_xbzrle(), it always return -1
without any resources which need release.
So can remove the related checking statements, and also can remove 'rc'
and 'ret' local variables,
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
arch_init.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 60c975d..98ee5b6 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -908,7 +908,6 @@ static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size)
static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
{
- int ret, rc = 0;
unsigned int xh_len;
int xh_flags;
@@ -933,18 +932,13 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
qemu_get_buffer(f, xbzrle_decoded_buf, xh_len);
/* decode RLE */
- ret = xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
- TARGET_PAGE_SIZE);
- if (ret == -1) {
+ if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
+ TARGET_PAGE_SIZE) == -1) {
fprintf(stderr, "Failed to load XBZRLE page - decode error!\n");
- rc = -1;
- } else if (ret > TARGET_PAGE_SIZE) {
- fprintf(stderr, "Failed to load XBZRLE page - size %d exceeds %d!\n",
- ret, TARGET_PAGE_SIZE);
- abort();
+ return -1;
}
- return rc;
+ return 0;
}
static inline void *host_from_stream_offset(QEMUFile *f,
--
1.7.11.7
next reply other threads:[~2014-05-10 12:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-10 12:51 Chen Gang [this message]
2014-05-10 12:51 ` [Qemu-devel] [PATCH] arch_init: Simplify code for load_xbzrle() Chen Gang
2014-05-12 10:27 ` [Qemu-trivial] " Juan Quintela
2014-05-12 10:27 ` [Qemu-devel] " Juan Quintela
2014-05-17 7:54 ` [Qemu-trivial] " Michael Tokarev
2014-05-17 7:54 ` [Qemu-devel] " Michael Tokarev
2014-05-18 10:53 ` Chen Gang
2014-05-18 10:53 ` [Qemu-devel] " Chen Gang
2014-05-19 7:46 ` Michael Tokarev
2014-05-19 7:46 ` [Qemu-devel] " Michael Tokarev
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=536E20CC.4030401@gmail.com \
--to=gang.chen.5i5j@gmail.com \
--cc=eblake@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=owasserm@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@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.