[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] virStorageNetHostDef: Turn @port into integer



On Wed, Jul 19, 2017 at 17:58:15 +0200, Peter Krempa wrote:
> On Wed, Jul 19, 2017 at 17:26:27 +0200, Michal Privoznik wrote:
> > Currently, @port is type of string. Well, that's overkill and
> > waste of memory. Port is always an integer. Use it as such.
> > 
> > Signed-off-by: Michal Privoznik <mprivozn redhat com>
> > ---
> >  src/conf/domain_conf.c                |  25 ++++++--
> >  src/libxl/libxl_conf.c                |   2 +-
> >  src/qemu/qemu_block.c                 |   2 +-
> >  src/qemu/qemu_command.c               |  28 ++-------
> >  src/qemu/qemu_parse_command.c         |  33 +++++++---
> >  src/storage/storage_backend_gluster.c |  17 ++---
> >  src/storage/storage_driver.c          |   7 +--
> >  src/util/virstoragefile.c             | 113 +++++++++++++++++++++-------------
> >  src/util/virstoragefile.h             |   4 +-
> >  src/xenconfig/xen_xl.c                |   2 +-
> >  10 files changed, 130 insertions(+), 103 deletions(-)

[...]

> > diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
> > index 98992e04a..934504806 100644
> > --- a/src/util/virstoragefile.h
> > +++ b/src/util/virstoragefile.h
> > @@ -155,7 +155,7 @@ typedef struct _virStorageNetHostDef virStorageNetHostDef;
> >  typedef virStorageNetHostDef *virStorageNetHostDefPtr;
> >  struct _virStorageNetHostDef {
> >      char *name;
> > -    char *port;
> > +    int port;
> 
> If you want to be precise ... have you ever seen negative ports?
> 
> >      int transport; /* virStorageNetHostTransport */
> >      char *socket;  /* path to unix socket */
> >  };
> 
> This will require a lot of fixing since you blindly copied the check
> that also checks that the port is not less than 0.

I'll send two patches that I have on a branch that convert 'port' in
virURI to unsigned, which will possibly avoid you from typecasting.

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]