vnc: pass bool parameter for some functions
PATCH v2 1/5 vnc: pass bool parameter for some functions
last parameters of vnc_listen_read,vnc_connect are bool, so pass 'false/true' instead of '0/1' for them.
--- ui/vnc.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
ui/vnc.c +4 -4
@@ -2889,13 +2889,13 @@ static void vnc_listen_read(void *opaque, bool websocket)static void vnc_listen_regular_read (void *opaque) { -vnc_listen_read (opaque,0 ); +vnc_listen_read (opaque, false); }#ifdef CONFIG_VNC_WS static void vnc_listen_websocket_read (void *opaque) { -vnc_listen_read (opaque,1 ); +vnc_listen_read (opaque, true); }#endif /* CONFIG_VNC_WS */
@@ -3283,7 +3283,7 @@ void vnc_display_open(DisplayState *ds, const char *display, Error **errp)if (csock <0 ) { goto fail; } -vnc_connect (vs, csock,0 ,0 ); +vnc_connect (vs, csock,0 , false); }else {/* listen for connects */ char *dpy;
@@ -3345,5 +3345,5 @@ void vnc_display_add_client(DisplayState *ds, int csock, int skipauth) {VncDisplay *vs = vnc_display; -vnc_connect (vs, csock, skipauth,0 ); +vnc_connect (vs, csock, skipauth, false); }
Signature · 1 line
1.7.2.5
PATCH v2 2/5 vnc: boolize 'skipauth'
suggested by Michael Tokarev <[email protected]>
--- include/ui/console.h | 2 +- ui/vnc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/ui/console.h +1 -1
@@ -314,7 +314,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen);/* vnc.c */ void vnc_display_init (DisplayState *ds);void vnc_display_open (DisplayState *ds,const char *display,Error **errp); -void vnc_display_add_client (DisplayState *ds,int csock,int skipauth); +void vnc_display_add_client (DisplayState *ds,int csock,bool skipauth);char *vnc_display_local_addr (DisplayState *ds);#ifdef CONFIG_VNC int vnc_display_password (DisplayState *ds,const char *password);
ui/vnc.c +2 -2
@@ -2771,7 +2771,7 @@ static void vnc_refresh(DisplayChangeListener *dcl) } } -static void vnc_connect (VncDisplay *vd,int csock,int skipauth,bool websocket) +static void vnc_connect (VncDisplay *vd,int csock,bool skipauth,bool websocket) {VncState *vs =g_malloc0 (sizeof (VncState));int i;
@@ -3341,7 +3341,7 @@ fail:#endif /* CONFIG_VNC_WS */ } -void vnc_display_add_client (DisplayState *ds,int csock,int skipauth) +void vnc_display_add_client (DisplayState *ds,int csock,bool skipauth) {VncDisplay *vs = vnc_display;
Signature · 1 line
1.7.2.5
PATCH v2 3/5 qemu-char: use bool in qemu_chr_open_socket
In reply to liguanglocal variables is_* should be bool by usage,
and last parameter of qemu_opt_get_bool is bool,
so pass true/false for it.
--- qemu-char.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
qemu-char.c +10 -10
@@ -2679,16 +2679,16 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)CharDriverState *chr =NULL ;Error *local_err =NULL ;int fd =-1 ; -int is_listen; -int is_waitconnect; -int do_nodelay; -int is_unix; -int is_telnet; - - is_listen =qemu_opt_get_bool (opts,"server" ,0 ); - is_waitconnect =qemu_opt_get_bool (opts,"wait" ,1 ); - is_telnet =qemu_opt_get_bool (opts,"telnet" ,0 ); - do_nodelay = !qemu_opt_get_bool (opts,"delay" ,1 ); +bool is_listen; +bool is_waitconnect; +bool do_nodelay; +bool is_unix; +bool is_telnet; + + is_listen =qemu_opt_get_bool (opts,"server" , false); + is_waitconnect =qemu_opt_get_bool (opts,"wait" , true); + is_telnet =qemu_opt_get_bool (opts,"telnet" , false); + do_nodelay = !qemu_opt_get_bool (opts,"delay" , true); is_unix =qemu_opt_get (opts,"path" ) !=NULL ;if (!is_listen) is_waitconnect =0 ;
Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qemu_chr_open_socket
Quoted 30 lines · liguang
local variables is_* should be bool by usage,
and last parameter ofqemu_opt_get_boolis bool,
so pass true/false for it.Signed-off-by liguang <[email protected]>--- qemu-char.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)qemu-char.c +3
-10@@ -2679,16 +2679,16 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)CharDriverState *chr =NULL ;Error *local_err =NULL ;int fd =-1 ; -int is_listen; -int is_waitconnect; -int do_nodelay; -int is_unix; -int is_telnet; - - is_listen =qemu_opt_get_bool (opts,"server" ,0 ); - is_waitconnect =qemu_opt_get_bool (opts,"wait" ,1 ); - is_telnet =qemu_opt_get_bool (opts,"telnet" ,0 ); - do_nodelay = !qemu_opt_get_bool (opts,"delay" ,1 ); +bool is_listen; +bool is_waitconnect; +bool do_nodelay;
qemu-char.c static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) · line 2694
Quoted 10 lines
qemu-char.c +7
-0+bool is_unix; +bool is_telnet; + + is_listen =qemu_opt_get_bool (opts,"server" , false); + is_waitconnect =qemu_opt_get_bool (opts,"wait" , true); + is_telnet =qemu_opt_get_bool (opts,"telnet" , false); + do_nodelay = !qemu_opt_get_bool (opts,"delay" , true); is_unix =qemu_opt_get (opts,"path" ) !=NULL ;if (!is_listen) is_waitconnect =0 ;
So is is_waitconnect a booleand or integer? :)
How about this (I'm unsure about the author anymore ):
commit c5b775f85f5049d7315b8f8643a65ea1cc7107eb
Author: liguang <[email protected]> Date: Tue Jun 18 11:45:35 2013 +0800
qemu-char: use bool in qemu_chr_open_socket and simplify code a bit
Local variables is_* should be bool by usage.
While at it, simplify the logic/code a bit.
qemu-char.c +6 -13
@@ -2679,19 +2679,12 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)CharDriverState *chr =NULL ;Error *local_err =NULL ;int fd =-1 ; -int is_listen; -int is_waitconnect; -int do_nodelay; -int is_unix; -int is_telnet; - - is_listen =qemu_opt_get_bool (opts,"server" ,0 ); - is_waitconnect =qemu_opt_get_bool (opts,"wait" ,1 ); - is_telnet =qemu_opt_get_bool (opts,"telnet" ,0 ); - do_nodelay = !qemu_opt_get_bool (opts,"delay" ,1 ); - is_unix =qemu_opt_get (opts,"path" ) !=NULL ; -if (!is_listen) - is_waitconnect =0 ; + +bool is_listen =qemu_opt_get_bool (opts,"server" , false); +bool is_waitconnect = is_listen &&qemu_opt_get_bool (opts,"wait" , true); +bool is_telnet =qemu_opt_get_bool (opts,"telnet" , false); +bool do_nodelay = !qemu_opt_get_bool (opts,"delay" , true); +bool is_unix =qemu_opt_get (opts,"path" ) !=NULL ;if (is_unix) {if (is_listen) {
Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qemu_chr_open_socket
Quoted 35 lines · 在 2013-06-19三的 12:28 +0400,Michael Tokarev写道:
Quoted 34 lines · liguang
local variables is_* should be bool by usage,
and last parameter ofqemu_opt_get_boolis bool,
so pass true/false for it.Signed-off-by liguang <[email protected]>--- qemu-char.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)qemu-char.c +7
-10@@ -2679,16 +2679,16 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)CharDriverState *chr =NULL ;Error *local_err =NULL ;int fd =-1 ; -int is_listen; -int is_waitconnect; -int do_nodelay; -int is_unix; -int is_telnet; - - is_listen =qemu_opt_get_bool (opts,"server" ,0 ); - is_waitconnect =qemu_opt_get_bool (opts,"wait" ,1 ); - is_telnet =qemu_opt_get_bool (opts,"telnet" ,0 ); - do_nodelay = !qemu_opt_get_bool (opts,"delay" ,1 ); +bool is_listen; +bool is_waitconnect; +bool do_nodelay; +bool is_unix; +bool is_telnet; + + is_listen =qemu_opt_get_bool (opts,"server" , false);
Quoted 8 lines
qemu-char.c static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) · line 2694
Quoted 6 lines
qemu-char.c +3
-0+ is_waitconnect =qemu_opt_get_bool (opts,"wait" , true); + is_telnet =qemu_opt_get_bool (opts,"telnet" , false); + do_nodelay = !qemu_opt_get_bool (opts,"delay" , true); is_unix =qemu_opt_get (opts,"path" ) !=NULL ;if (!is_listen) is_waitconnect =0 ;So is
is_waitconnecta booleand or integer? :)
Oh, I'm so lazy to find more...
following is fine for me.
Thanks!
Quoted 46 lines
How about this (I'm unsure about the author anymore ):
commit
c5b775f85f5049d7315b8f8643a65ea1cc7107ebAuthor: liguang <[email protected]> Date: Tue Jun 18 11:45:35 2013 +0800qemu-char: use bool in
qemu_chr_open_socketand simplify code a bitLocal variables is_* should be bool by usage.
While at it, simplify the logic/code a bit.Signed-off-by liguang <[email protected]>Signed-off-by Michael Tokarev <[email protected]>qemu-char.c +6
-13@@ -2679,19 +2679,12 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts)CharDriverState *chr =NULL ;Error *local_err =NULL ;int fd =-1 ; -int is_listen; -int is_waitconnect; -int do_nodelay; -int is_unix; -int is_telnet; - - is_listen =qemu_opt_get_bool (opts,"server" ,0 ); - is_waitconnect =qemu_opt_get_bool (opts,"wait" ,1 ); - is_telnet =qemu_opt_get_bool (opts,"telnet" ,0 ); - do_nodelay = !qemu_opt_get_bool (opts,"delay" ,1 ); - is_unix =qemu_opt_get (opts,"path" ) !=NULL ; -if (!is_listen) - is_waitconnect =0 ; + +bool is_listen =qemu_opt_get_bool (opts,"server" , false); +bool is_waitconnect = is_listen &&qemu_opt_get_bool (opts,"wait" , true); +bool is_telnet =qemu_opt_get_bool (opts,"telnet" , false); +bool do_nodelay = !qemu_opt_get_bool (opts,"delay" , true); +bool is_unix =qemu_opt_get (opts,"path" ) !=NULL ;if (is_unix) {if (is_listen) {
PATCH v2 4/5 sd: pass bool parameter for sd_init
In reply to liguang--- hw/sd/milkymist-memcard.c | 2 +- hw/sd/omap_mmc.c | 4 ++-- hw/sd/pl181.c | 2 +- hw/sd/pxa2xx_mmci.c | 2 +- hw/sd/sdhci.c | 2 +- hw/sd/ssi-sd.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-)
hw/sd/milkymist-memcard.c +1 -1
@@ -250,7 +250,7 @@ static int milkymist_memcard_init(SysBusDevice *dev)DriveInfo *dinfo; dinfo =drive_get_next (IF_SD ); - s->card =sd_init (dinfo ? dinfo->bdrv :NULL ,0 ); + s->card =sd_init (dinfo ? dinfo->bdrv :NULL , false); s->enabled = dinfo ?bdrv_is_inserted (dinfo->bdrv) :0 ; memory_region_init_io(&s->regs_region, &memcard_mmio_ops, s,
hw/sd/omap_mmc.c +2 -2
@@ -592,7 +592,7 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base,memory_region_add_subregion (sysmem, base, &s->iomem);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd, false);return s; }
@@ -617,7 +617,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,omap_l4_attach (ta,0 , &s->iomem);/* Instantiate the storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd, false); s->cdet =qemu_allocate_irqs (omap_mmc_cover_cb, s,1 )[0 ];sd_set_cb (s->card,NULL , s->cdet);
hw/sd/pl181.c +1 -1
@@ -485,7 +485,7 @@ static int pl181_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq[1 ]);qdev_init_gpio_out (&s->busdev.qdev, s->cardstatus,2 ); dinfo =drive_get_next (IF_SD ); - s->card =sd_init (dinfo ? dinfo->bdrv :NULL ,0 ); + s->card =sd_init (dinfo ? dinfo->bdrv :NULL , false);return 0 ; }
hw/sd/pxa2xx_mmci.c +1 -1
@@ -538,7 +538,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,memory_region_add_subregion (sysmem, base, &s->iomem);/* Instantiate the actual storage */ - s->card =sd_init (bd,0 ); + s->card =sd_init (bd, false);register_savevm (NULL ,"pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);
hw/sd/sdhci.c +1 -1
@@ -1165,7 +1165,7 @@ static void sdhci_initfn(Object *obj)DriveInfo *di; di =drive_get_next (IF_SD ); - s->card =sd_init (di ? di->bdrv :NULL ,0 ); + s->card =sd_init (di ? di->bdrv :NULL , false); s->eject_cb =qemu_allocate_irqs (sdhci_insert_eject_cb, s,1 )[0 ]; s->ro_cb =qemu_allocate_irqs (sdhci_card_readonly_cb, s,1 )[0 ];sd_set_cb (s->card, s->ro_cb, s->eject_cb);
hw/sd/ssi-sd.c +1 -1
@@ -245,7 +245,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; dinfo =drive_get_next (IF_SD ); - s->sd =sd_init (dinfo ? dinfo->bdrv :NULL ,1 ); + s->sd =sd_init (dinfo ? dinfo->bdrv :NULL , true);register_savevm (&dev->qdev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
Signature · 1 line
1.7.2.5
Michael Tokarev
AppliedRe: [Qemu-devel] [Qemu-trivial] [PATCH v2 4/5] sd: pass bool parameter for sd_init
Thanks, applied to the trivial patches queue.
/mjt
PATCH v2 5/5 ui: boolize 'full_screen'
In reply to liguangfull_screen parameter for functions sdl_display_init, cocoa_display_init, curses_display_init should be boolized by actual usage.
also boolize 'full_screen' in vl.c
it may be bold for cocoa, so if it hurts, these changes can be dropped.
--- include/ui/console.h | 6 +++--- ui/curses.c | 2 +- ui/sdl.c | 2 +- vl.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
include/ui/console.h +3 -3
@@ -306,10 +306,10 @@ CharDriverState *vc_init(ChardevVC *vc);void register_vc_handler (VcHandler *handler);/* sdl.c */ -void sdl_display_init (DisplayState *ds,int full_screen,int no_frame); +void sdl_display_init (DisplayState *ds,bool full_screen,int no_frame);/* cocoa.m */ -void cocoa_display_init (DisplayState *ds,int full_screen); +void cocoa_display_init (DisplayState *ds,bool full_screen);/* vnc.c */ void vnc_display_init (DisplayState *ds);
@@ -331,7 +331,7 @@ static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)#endif /* curses.c */ -void curses_display_init (DisplayState *ds,int full_screen); +void curses_display_init (DisplayState *ds,bool full_screen);/* input.c */ int index_from_key (const char *key);
ui/curses.c +1 -1
@@ -336,7 +336,7 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_text_cursor = curses_cursor_position, }; -void curses_display_init (DisplayState *ds,int full_screen) +void curses_display_init (DisplayState *ds,bool full_screen) {#ifndef _WIN32if (!isatty (1 )) {
ui/sdl.c +1 -1
@@ -868,7 +868,7 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_cursor_define = sdl_mouse_define, }; -void sdl_display_init (DisplayState *ds,int full_screen,int no_frame) +void sdl_display_init (DisplayState *ds,bool full_screen,int no_frame) {int flags;uint8_t data =0 ;
vl.c +2 -2
@@ -198,7 +198,7 @@ static int rtc_utc = 1;static int rtc_date_offset =-1 ;/* -1 means no change */ QEMUClock *rtc_clock;int vga_interface_type =VGA_NONE ; -static int full_screen =0 ; +static bool full_screen = false;static int no_frame =0 ;int no_quit =0 ;CharDriverState *serial_hds[MAX_SERIAL_PORTS ];
@@ -3520,7 +3520,7 @@ int main(int argc, char **argv, char **envp) loadvm = optarg;break ;case QEMU_OPTION_full_screen: - full_screen =1 ; + full_screen = true;break ;case QEMU_OPTION_no_frame: no_frame =1 ;
Signature · 1 line
1.7.2.5
Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 5/5] ui: boolize 'full_screen'
18.06.2013 07:45, liguang wrote:
[]
include/ui/console.h CharDriverState *vc_init(ChardevVC *vc); · line 309
Quoted 2 lines
include/ui/console.h +1
-1-void sdl_display_init (DisplayState *ds,int full_screen,int no_frame); +void sdl_display_init (DisplayState *ds,bool full_screen,int no_frame);
The same applies to no_frame, isn't it?
These conversions to bool are like this -- "thankless", because there are so many of them all around, you touch one place and it becomes obvious that nearby places should be touched too. Like this:
vl.c static int rtc_utc = 1; · line 203
Quoted 10 lines
vl.c +1
-1@@ -198,7 +198,7 @@ static int rtc_utc = 1;static int rtc_date_offset =-1 ;/* -1 means no change */ QEMUClock *rtc_clock;int vga_interface_type =VGA_NONE ; -static int full_screen =0 ; +static bool full_screen = false;static int no_frame =0 ;int no_quit =0 ;
This no_quit is bool too... :) But I think _this_ one might be in a separate patch. But it is also display-specific.
Besides, I think we should rewamp this display init thing entirely, making displays to be modules and implementing options parsing properly.
I think I'll do that today, and will convert these to bools while at it.
Thanks,
/mjt
Quoted 5 lines · liguang
last parameters of vnc_listen_read,vnc_connect are bool, so pass 'false/true' instead of '0/1' for them.
Reviewed-by Andreas Färber <[email protected]>Signed-off-by liguang <[email protected]>
I think I'll apply my version instead, -- which converts remaining arguments of functions your patch touches (so that we don't have this:
ui/vnc.c void vnc_display_open(DisplayState *ds, const char *display, Error **errp) · line 3286
Quoted 2 lines
ui/vnc.c +1
-1-vnc_connect (vs, csock,0 ,0 ); +vnc_connect (vs, csock,0 , false);
where 3rd argument is also a bool), and which combines your patches 1/5 and 2/5 into one.
I'll resend it again in a top-level message.
Thanks,
/mjt