mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
char: change qemu_chr_fe_add_watch to return unsigned
g_source_attach can return any value between 1 and UINT_MAX if you let QEMU run long enough. However, qemu_chr_fe_add_watch can also return a negative errno value when the device is disconnected or does not support chr_add_watch. Change it to return zero to avoid overloading these values. Fix the cadence_uart which asserts in this case (easily obtained with "-serial pty"). Tested-by: Bret Ketchum <bcketchum@gmail.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b0585e7e07
commit
6f1de6b70d
4 changed files with 25 additions and 10 deletions
|
@ -3966,19 +3966,19 @@ void qemu_chr_fe_event(struct CharDriverState *chr, int event)
|
|||
}
|
||||
}
|
||||
|
||||
int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
|
||||
GIOFunc func, void *user_data)
|
||||
guint qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond,
|
||||
GIOFunc func, void *user_data)
|
||||
{
|
||||
GSource *src;
|
||||
guint tag;
|
||||
|
||||
if (s->chr_add_watch == NULL) {
|
||||
return -ENOSYS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
src = s->chr_add_watch(s, cond);
|
||||
if (!src) {
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_source_set_callback(src, (GSourceFunc)func, user_data, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue