[libvirt] [PATCH] virtlogd: cast maxlen to size_t
Guido Günther
agx at sigxcpu.org
Thu Nov 26 17:45:38 UTC 2015
On Thu, Nov 26, 2015 at 05:19:30PM +0000, Daniel P. Berrange wrote:
> On Thu, Nov 26, 2015 at 06:12:38PM +0100, Guido Günther wrote:
> > Otherwise we fail on 32bit with:
> >
> > CC logging/virtlogd-log_daemon_dispatch.o
> > logging/log_daemon_dispatch.c: In function 'virLogManagerProtocolDispatchDomainReadLogFile':
> > logging/log_daemon_dispatch.c:120:9: error: format '%zu' expects argument of type 'size_t', but argument 7 has type 'uint64_t' [-Werror=format]
> > ---
> > src/logging/log_daemon_dispatch.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/logging/log_daemon_dispatch.c b/src/logging/log_daemon_dispatch.c
> > index 269255a..70b5f1d 100644
> > --- a/src/logging/log_daemon_dispatch.c
> > +++ b/src/logging/log_daemon_dispatch.c
> > @@ -119,7 +119,7 @@ virLogManagerProtocolDispatchDomainReadLogFile(virNetServerPtr server ATTRIBUTE_
> > if (args->maxlen > VIR_LOG_MANAGER_PROTOCOL_STRING_MAX) {
> > virReportError(VIR_ERR_INTERNAL_ERROR,
> > _("Requested data len %zu is larger than maximum %d"),
> > - args->maxlen, VIR_LOG_MANAGER_PROTOCOL_STRING_MAX);
> > + (size_t)args->maxlen, VIR_LOG_MANAGER_PROTOCOL_STRING_MAX);
>
> Casting will truncate - since maxlen is a uint64, we should change the
> format specifier to %llu instead of casting.
That would then in turn break 64bit so I went for PRIu64.
Cheers,
-- Guido
More information about the libvir-list
mailing list