qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spice-char: fix wrong assert condition
@ 2015-01-17  6:48 Zhang Haoyu
  2015-01-17 11:52 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Haoyu @ 2015-01-17  6:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini

G_IO_OUT|G_IO_HUP are passed from all of the callers
of chr_add_watch hooker, the assert condition MUST be
changed.

Signed-off-by: Zhang Haoyu <zhanghy@sangfor.com.cn>
---
 spice-qemu-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 7e0d300..b81a9db 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -169,7 +169,7 @@ static GSource *spice_chr_add_watch(CharDriverState *chr, GIOCondition cond)
     SpiceCharDriver *scd = chr->opaque;
     SpiceCharSource *src;
 
-    assert(cond == G_IO_OUT);
+    assert(cond == (G_IO_OUT|G_IO_HUP));
 
     src = (SpiceCharSource *)g_source_new(&SpiceCharSourceFuncs,
                                           sizeof(SpiceCharSource));
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] spice-char: fix wrong assert condition
  2015-01-17  6:48 [Qemu-devel] [PATCH] spice-char: fix wrong assert condition Zhang Haoyu
@ 2015-01-17 11:52 ` Peter Maydell
  2015-01-17 11:54   ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2015-01-17 11:52 UTC (permalink / raw)
  To: Zhang Haoyu; +Cc: Paolo Bonzini, qemu-devel

On 17 January 2015 at 06:48, Zhang Haoyu <zhanghy@sangfor.com.cn> wrote:
> G_IO_OUT|G_IO_HUP are passed from all of the callers
> of chr_add_watch hooker, the assert condition MUST be
> changed.

"All the callers do this currently" isn't a reason to
change an assert. Possible reasons to change it include:
 * "X is required because if we don't then things break because Y"
 * "it is meaningless (a programming error) to do X, because Y"

Can you give the reasoning for changing this assert?
Does it apply also to other add_watch hook functions?
Would the assert be better at a higher level in the callstack?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] spice-char: fix wrong assert condition
  2015-01-17 11:52 ` Peter Maydell
@ 2015-01-17 11:54   ` Peter Maydell
  2015-01-19  6:15     ` Zhang Haoyu
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2015-01-17 11:54 UTC (permalink / raw)
  To: Zhang Haoyu; +Cc: Paolo Bonzini, qemu-devel

On 17 January 2015 at 11:52, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 17 January 2015 at 06:48, Zhang Haoyu <zhanghy@sangfor.com.cn> wrote:
>> G_IO_OUT|G_IO_HUP are passed from all of the callers
>> of chr_add_watch hooker, the assert condition MUST be
>> changed.
>
> "All the callers do this currently" isn't a reason to
> change an assert. Possible reasons to change it include:
>  * "X is required because if we don't then things break because Y"
>  * "it is meaningless (a programming error) to do X, because Y"
>
> Can you give the reasoning for changing this assert?
> Does it apply also to other add_watch hook functions?
> Would the assert be better at a higher level in the callstack?

...that said, I've just figured out what your patch is trying
to fix. I think that kind of makes the point about the commit
message not really being very clear about why the change is
being made, though. (Should we be checking
'(cond & G_IO_OUT) != 0'? Is this a bandaid over missing
functionality in the spice chardriver?)

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] spice-char: fix wrong assert condition
  2015-01-17 11:54   ` Peter Maydell
@ 2015-01-19  6:15     ` Zhang Haoyu
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang Haoyu @ 2015-01-19  6:15 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel


On 2015-01-17 19:55:16, Peter Maydell wrote:
>On 17 January 2015 at 11:52, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 17 January 2015 at 06:48, Zhang Haoyu <zhanghy@sangfor.com.cn> wrote:
> >> G_IO_OUT|G_IO_HUP are passed from all of the callers
> >> of chr_add_watch hooker, the assert condition MUST be
> >> changed.
>>
> > "All the callers do this currently" isn't a reason to
> > change an assert. Possible reasons to change it include:
> >  * "X is required because if we don't then things break because Y"
>>  * "it is meaningless (a programming error) to do X, because Y"
> >
> > Can you give the reasoning for changing this assert?
> > Does it apply also to other add_watch hook functions?
> > Would the assert be better at a higher level in the callstack?
>
> ...that said, I've just figured out what your patch is trying
> to fix. I think that kind of makes the point about the commit
> message not really being very clear about why the change is
>being made, though. (Should we be checking
> '(cond & G_IO_OUT) != 0'? 
I think '(cond & G_IO_OUT) != 0' is better, v2 will be posted.

> Is this a bandaid over missing
> functionality in the spice chardriver?)
I really don't know about this.
> 
> -- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-19  6:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-17  6:48 [Qemu-devel] [PATCH] spice-char: fix wrong assert condition Zhang Haoyu
2015-01-17 11:52 ` Peter Maydell
2015-01-17 11:54   ` Peter Maydell
2015-01-19  6:15     ` Zhang Haoyu

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).