From: Mitsyanko Igor <i.mitsyanko@samsung.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] hw/lan9118: Add save/load support
Date: Thu, 12 Jan 2012 14:16:56 +0400 [thread overview]
Message-ID: <4F0EB318.3070209@samsung.com> (raw)
In-Reply-To: <1324332111-29059-1-git-send-email-peter.maydell@linaro.org>
On 12/20/2011 02:01 AM, Peter Maydell wrote:
> Implement save/load for the LAN9118.
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> Does anybody have a nicer solution to the "can't put an enum in a
> VMStateDescription" problem?
>
> hw/lan9118.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 103 insertions(+), 23 deletions(-)
>
> diff --git a/hw/lan9118.c b/hw/lan9118.c
> index 7e64c5d..6542a26 100644
> --- a/hw/lan9118.c
> +++ b/hw/lan9118.c
> @@ -136,17 +136,36 @@ enum tx_state {
> };
Hi Peter, I have a small question. Wouldn't it be better to use uint32_t
for variables that actually have positive values only? That would make
code easier to understand. For example in this state
> typedef struct {
> - enum tx_state state;
> + /* state is a tx_state but we can't put enums in VMStateDescriptions. */
> + uint32_t state;
> uint32_t cmd_a;
> uint32_t cmd_b;
> - int buffer_size;
> - int offset;
> - int pad;
> - int fifo_used;
> - int len;
> + int32_t buffer_size;
> + int32_t offset;
> + int32_t pad;
> + int32_t fifo_used;
> + int32_t len;
> uint8_t data[2048];
> } LAN9118Packet;
all member variables (except maybe buffer_size) can have positive values
only. buffer_size is probably positive-only too because this code
while (n--) {
s->txp->data[s->txp->len] = val & 0xff;
s->txp->len++;
val >>= 8;
s->txp->buffer_size--;
}
looks wrong (I haven't dug dip into it though) and must be
...
while (s->txp->buffer_size && (n--)) {
...
--
Mitsyanko Igor
ASWG, Moscow R&D center, Samsung Electronics
email: i.mitsyanko@samsung.com
next prev parent reply other threads:[~2012-01-12 10:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 22:01 [Qemu-devel] [PATCH] hw/lan9118: Add save/load support Peter Maydell
2012-01-04 10:41 ` Peter Maydell
2012-01-10 16:55 ` Peter Maydell
2012-01-11 22:53 ` Peter Maydell
2012-01-12 4:23 ` Andreas Färber
2012-01-12 10:16 ` Mitsyanko Igor [this message]
2012-01-12 10:18 ` Peter Maydell
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=4F0EB318.3070209@samsung.com \
--to=i.mitsyanko@samsung.com \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--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 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.