[Spice-devel] [PATCH 4/4] vdagent: Use glib's commandline parser

Victor Toso victortoso at redhat.com
Tue May 16 16:07:00 UTC 2017


Hi,

On Tue, May 16, 2017 at 05:29:57PM +0200, Christophe Fergeau wrote:
> On Fri, May 12, 2017 at 01:19:40PM +0200, Victor Toso wrote:
> > From: Victor Toso <me at victortoso.com>
> > 
> > As we already depend on glib, let's remove code that glib can take
> > care. In this case, we don't need to handle commandline parsing
> > ourselves.
> > 
> > In regard the global variables:
> > 
> > * static const char * -> static char * [only paths]
>
> Ideally, they would need to be g_free'd at some point, dunno if you
> have looked at doing that, but it was inconvenient, or if this was
> forgotten?

tbh, I thought GOptionEntry wouldn't take a const gchar *. I'll move it
to const again.

>
> >   path variables: portdev, fx_dir, vdagentd_socket
> > 
> > * static int -> static gboolean
> >   flags: debug, do_daemonize, x11_sync, fx_open_dir
> > 
> > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > ---
> >  src/vdagent/vdagent.c | 107 +++++++++++++++++++++++---------------------------
> >  1 file changed, 49 insertions(+), 58 deletions(-)
> > 
> > diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> > index 4f8079f..2c4ec3f 100644
> > --- a/src/vdagent/vdagent.c
> > +++ b/src/vdagent/vdagent.c
> > @@ -45,17 +45,45 @@
> >  #include "x11.h"
> >  #include "file-xfers.h"
> >
> > -static const char *portdev = DEFAULT_VIRTIO_PORT_PATH;
> > -static const char *vdagentd_socket = VDAGENTD_SOCKET;
> > -static int debug = 0;
> > -static const char *fx_dir = NULL;
> > -static int fx_open_dir = -1;
> >  static struct vdagent_x11 *x11 = NULL;
> >  static struct vdagent_file_xfers *vdagent_file_xfers = NULL;
> >  static struct udscs_connection *client = NULL;
> >  static int quit = 0;
> >  static int version_mismatch = 0;
> >  
> > +/* Command line options */
> > +static gboolean debug = FALSE;
> > +static gboolean x11_sync = FALSE;
> > +static gboolean fx_open_dir = FALSE;
> > +static gboolean do_daemonize = TRUE;
> > +static char *fx_dir;
>
> No longer set to NULL?

That's a mistake, I'll fix

>
> > +static char *portdev = DEFAULT_VIRTIO_PORT_PATH;
> > +static char *vdagentd_socket = VDAGENTD_SOCKET;
> > +
> > +static GOptionEntry entries[] ={
> > +    { "debug", 'd', 0,
> > +       G_OPTION_ARG_NONE, &debug,
> > +       "Enable debug", NULL },
> > +    { "foreground", 'x', G_OPTION_FLAG_REVERSE,
> > +       G_OPTION_ARG_NONE, &do_daemonize,
> > +       "Do not daemonize the agent", NULL },
> > +    { "x11-abort-on-error", 'y', 0,
> > +      G_OPTION_ARG_NONE, &x11_sync,
> > +      "Aborts on errors from X11", NULL },
> > +    { "file-xfer-open-dir", 'o', 0,
> > +       G_OPTION_ARG_NONE, &fx_open_dir,
> > +       "Open directory after completing file transfer", NULL },
> > +    { "virtio-serial-port-path", 's', 0,
> > +      G_OPTION_ARG_STRING, &portdev,
> > +      "Set virtio-serial path ("  DEFAULT_VIRTIO_PORT_PATH ")", NULL },
> > +    { "file-xfer-save-dir", 'f', 0,
> > +      G_OPTION_ARG_STRING, &fx_dir,
> > +      "Set directory to file transfers files", NULL},
> > +    { "vdagentd-socket", 'S', 0, G_OPTION_ARG_STRING,
> > +       &vdagentd_socket,
> > +       "Set spice-vdagentd socket (" VDAGENTD_SOCKET ")", NULL },
> > +};
>
> Maybe I'd keep an order similar to the one which was previously used
> for the option. Or did you pick that order on purpose?
>
> Christophe

I put in this order with no real rationale behind it. I'll make the
order closer to what it was before.

Thanks for the review!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170516/9e342fdb/attachment.sig>


More information about the Spice-devel mailing list