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

Peter Krempa pkrempa at redhat.com
Thu Jul 20 07:57:37 UTC 2017


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 at 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170720/5688a9ee/attachment-0001.sig>


More information about the libvir-list mailing list