From: John Snow <jsnow@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Lieven <pl@kamp.de>,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] ide: do not set s->end_transfer_func to ide_transfer_cancel
Date: Tue, 20 Mar 2018 18:19:01 -0400 [thread overview]
Message-ID: <5e659013-eb37-219b-d5e3-c4c93548a368@redhat.com> (raw)
In-Reply-To: <20180223152640.11459-4-pbonzini@redhat.com>
On 02/23/2018 10:26 AM, Paolo Bonzini wrote:
> There is code checking s->end_transfer_func and it was not taught
> about ide_transfer_cancel. We can just use ide_transfer_stop because
> s->end_transfer_func is only ever called in the DRQ phase: after
> ide_transfer_cancel, the value of s->end_transfer_func is only used
> as a marker and never used to actually invoke the function.
>
I think you're right, but I think it's also pretty non-obvious to a
reader that a callback might be used in this way.
"John, it's your component dude, why don't you fix that?"
Err, I'm afraid of disturbing the delicate balance of spaghetti code.
*cough*
Anyway, a little comment explaining that we don't actually *expect* that
callback to actually get called would probably answer a question or two
before they arise.
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/ide/core.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index c4710a6f55..447d9624df 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -553,10 +553,9 @@ static void ide_cmd_done(IDEState *s)
> }
> }
>
> -static void ide_transfer_halt(IDEState *s,
> - void(*end_transfer_func)(IDEState *))
> +static void ide_transfer_halt(IDEState *s)
> {
> - s->end_transfer_func = end_transfer_func;
> + s->end_transfer_func = ide_transfer_stop;
> s->data_ptr = s->io_buffer;
> s->data_end = s->io_buffer;
> s->status &= ~DRQ_STAT;
> @@ -564,7 +563,7 @@ static void ide_transfer_halt(IDEState *s,
>
> void ide_transfer_stop(IDEState *s)
> {
> - ide_transfer_halt(s, ide_transfer_stop);
> + ide_transfer_halt(s);
> if (s->bus->dma->ops->end_transfer) {
> s->bus->dma->ops->end_transfer(s->bus->dma);
> }
> @@ -573,7 +572,7 @@ void ide_transfer_stop(IDEState *s)
>
> static void ide_transfer_cancel(IDEState *s)
> {
> - ide_transfer_halt(s, ide_transfer_cancel);
> + ide_transfer_halt(s);
> }
>
> int64_t ide_get_sector(IDEState *s)
>
"LGTM"
next prev parent reply other threads:[~2018-03-20 22:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 15:26 [Qemu-devel] [RFC PATCH 0/5] atapi: change unlimited recursion to while loop Paolo Bonzini
2018-02-23 15:26 ` [Qemu-devel] [PATCH 1/5] ide: push call to end_transfer_func out of start_transfer callback Paolo Bonzini
2018-03-20 21:46 ` John Snow
2018-03-21 5:37 ` Paolo Bonzini
2018-02-23 15:26 ` [Qemu-devel] [PATCH 2/5] ide: push end_transfer callback to ide_transfer_halt Paolo Bonzini
2018-03-20 22:11 ` John Snow
2018-03-21 5:39 ` Paolo Bonzini
2018-03-21 18:05 ` John Snow
2018-02-23 15:26 ` [Qemu-devel] [PATCH 3/5] ide: do not set s->end_transfer_func to ide_transfer_cancel Paolo Bonzini
2018-03-20 22:19 ` John Snow [this message]
2018-02-23 15:26 ` [Qemu-devel] [PATCH 4/5] atapi: call ide_set_irq before ide_transfer_start Paolo Bonzini
2018-03-21 0:35 ` John Snow
2018-03-21 5:44 ` Paolo Bonzini
2018-02-23 15:26 ` [Qemu-devel] [PATCH 5/5] ide: introduce ide_transfer_start_norecurse Paolo Bonzini
2018-02-28 4:21 ` [Qemu-devel] [RFC PATCH 0/5] atapi: change unlimited recursion to while loop John Snow
2018-03-23 20:08 ` John Snow
2018-03-23 20:17 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2018-03-23 20:28 ` John Snow
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=5e659013-eb37-219b-d5e3-c4c93548a368@redhat.com \
--to=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.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 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).