
On 09/15/2014 04:09 AM, Peter Krempa wrote:
On 09/13/14 15:27, John Ferlan wrote:
Coverity complains about the calculation of the buf & len within the PROBE macro. So to quiet things down, do the calculation prior to usage in either write() or qemuMonitorIOWriteWithFD() calls and then have the PROBE use the calculated values - which works.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_monitor.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
A build failure on a local jenkins server resulted in the following being pushed : commit c29cad67328bb8845c4396b85884211124ea1e2d Author: John Ferlan <jferlan@redhat.com> Date: Mon Sep 15 11:37:20 2014 -0400 qemu: Fix build breaker on printf directive %zu for size_t not %lu diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 89446d7..3a32a4f 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -499,7 +499,7 @@ qemuMonitorIOWrite(qemuMonitorPtr mon) done = qemuMonitorIOWriteWithFD(mon, buf, len, mon->msg->txFD); PROBE(QEMU_MONITOR_IO_WRITE, - "mon=%p buf=%s len=%lu ret=%d errno=%d", + "mon=%p buf=%s len=%zu ret=%d errno=%d", mon, buf, len, done, errno); if (mon->msg->txFD != -1) {
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6059133..80c6ef8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -478,6 +478,8 @@ static int qemuMonitorIOWrite(qemuMonitorPtr mon) { int done; + char *buf; + int len;
len should be "size_t"
/* If no active message, or fully transmitted, the no-op */ if (!mon->msg || mon->msg->txOffset == mon->msg->txLength) @@ -489,22 +491,16 @@ qemuMonitorIOWrite(qemuMonitorPtr mon) return -1; }
+ buf = mon->msg->txBuffer + mon->msg->txOffset; + len = mon->msg->txLength - mon->msg->txOffset; if (mon->msg->txFD == -1) - done = write(mon->fd, - mon->msg->txBuffer + mon->msg->txOffset, - mon->msg->txLength - mon->msg->txOffset); + done = write(mon->fd, buf, len); else - done = qemuMonitorIOWriteWithFD(mon, - mon->msg->txBuffer + mon->msg->txOffset, - mon->msg->txLength - mon->msg->txOffset, - mon->msg->txFD); + done = qemuMonitorIOWriteWithFD(mon, buf, len, mon->msg->txFD);
PROBE(QEMU_MONITOR_IO_WRITE, "mon=%p buf=%s len=%d ret=%d errno=%d", - mon, - mon->msg->txBuffer + mon->msg->txOffset, - mon->msg->txLength - mon->msg->txOffset, - done, errno); + mon, buf, len, done, errno);
if (mon->msg->txFD != -1) { PROBE(QEMU_MONITOR_IO_SEND_FD,
ACK with the type corrected.
Peter