[libvirt] [PATCH 01/12] src: import gnulib's intprops.h header

Pavel Hrdina phrdina at redhat.com
Tue Jan 14 11:17:40 UTC 2020


On Fri, Jan 10, 2020 at 03:41:05PM +0000, Daniel P. Berrangé wrote:
> This copies intprops.h to virintprops.h. A couple of
> conditionals were cut out since we don't need to support
> OpenVMS or ancient GCC 2.x
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  build-aux/syntax-check.mk                 |   7 +-
>  src/hyperv/hyperv_driver.c                |   2 +-
>  src/libvirt-domain.c                      |   2 +-
>  src/nwfilter/nwfilter_ebiptables_driver.c |   2 +-
>  src/nwfilter/nwfilter_learnipaddr.c       |   2 +-
>  src/remote/remote_daemon_dispatch.c       |   2 +-
>  src/remote/remote_driver.c                |   2 +-
>  src/util/Makefile.inc.am                  |   1 +
>  src/util/virfile.c                        |   2 +-
>  src/util/virhostcpu.c                     |   2 +-
>  src/util/virintprops.h                    | 526 ++++++++++++++++++++++
>  src/util/virlog.c                         |   2 +-
>  src/util/virnetdevbridge.c                |   2 +-
>  src/util/virpidfile.c                     |   2 +-
>  tests/virsystemdtest.c                    |   2 +-
>  tools/virsh-domain-monitor.c              |   2 +-
>  tools/virt-login-shell.c                  |   7 +-
>  17 files changed, 548 insertions(+), 19 deletions(-)
>  create mode 100644 src/util/virintprops.h

From the intprops.h we use only these two macros, INT_MULTIPLY_OVERFLOW
and INT_BUFSIZE_BOUND.

The INT_MULTIPLY_OVERFLOW is used only for virDomainGetVcpuPinInfo and
virDomainGetVcpus APIs.  In both cases the multiplication result is used
to allocate some memory and stored as uint cpumap_len.

I guess that it should be safe to use g_uint_checked_mul() function.

For the INT_BUFSIZE_BOUND I was not able to find any replacement.
We can use the similar approach as you've did in virt-login-shell but
instead of magic number we can define a macro that would be large enough
to cover long long and unsigned long long variables.  Or we can use
dynamic allocation.

That way we wound not have to copy this code at all.

Pavel
-------------- 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/20200114/3d2b85e4/attachment-0001.sig>


More information about the libvir-list mailing list