qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Su Hang" <suhang16@mails.ucas.ac.cn>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Should we check arguments for function `from_bcd` and `to_bcd`?
Date: Thu, 22 Mar 2018 15:03:03 +0800 (GMT+08:00)	[thread overview]
Message-ID: <dca9a53.33fd5.1624c84a277.Coremail.suhang16@mails.ucas.ac.cn> (raw)

When I was reading 'qemu/hw/timer/m48t59.c'(Line:328) and run with
`make check-qtest-ppc`,
I found when write an invalid value 0xc to address 0x1FFF,
`from_bcd` return 12 instead of raising an exception(or error).

"""(qemu/hw/timer/m48t59.c)
    case 0x1FFF:
    case 0x07FF:
        /* year */
    tmp = from_bcd(val);
    if (tmp >= 0 && tmp <= 99) {
"""


"""(qemu/include/qemu/bcd.h)
/* Convert a byte between binary and BCD.  */
static inline uint8_t to_bcd(uint8_t val)
{
    return ((val / 10) << 4) | (val % 10);
}

static inline uint8_t from_bcd(uint8_t val)
{
    return ((val >> 4) * 10) + (val & 0x0f);
}
"""

Su Hang

             reply	other threads:[~2018-03-22  7:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22  7:03 Su Hang [this message]
2018-03-22  9:12 ` [Qemu-devel] Should we check arguments for function `from_bcd` and `to_bcd`? Paolo Bonzini
2018-03-22 10:33   ` Su Hang

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=dca9a53.33fd5.1624c84a277.Coremail.suhang16@mails.ucas.ac.cn \
    --to=suhang16@mails.ucas.ac.cn \
    --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).