Re: [PATCH] virtlogd: cast maxlen to size_t

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]