diff mbox

[v2,29/30] trace: Fix parameter types in hw/virtio

Message ID 20170313195547.21466-30-eblake@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Blake March 13, 2017, 7:55 p.m. UTC
An upcoming patch will let the compiler warn us when we are silently
losing precision in traces; update the trace definitions to pass
through the full value at the callsite.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 hw/virtio/trace-events | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Hajnoczi March 16, 2017, 7:45 a.m. UTC | #1
On Mon, Mar 13, 2017 at 02:55:46PM -0500, Eric Blake wrote:
> An upcoming patch will let the compiler warn us when we are silently
> losing precision in traces; update the trace definitions to pass
> through the full value at the callsite.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  hw/virtio/trace-events | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
> index 6926eed..7b3743d 100644
> --- a/hw/virtio/trace-events
> +++ b/hw/virtio/trace-events
> @@ -4,7 +4,7 @@
>  virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) "vq %p elem %p len %u idx %u"
>  virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
>  virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) "vq %p elem %p in_num %u out_num %u"
> -virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p"
> +virtio_queue_notify(void *vdev, ptrdiff_t n, void *vq) "vdev %p n %td vq %p"

I'm not sure about this change.  Logically the virtqueue number, n, is
not a ptrdiff_t.  The type for n is always int in
include/hw/virtio/virtio.h and it should be the same for the trace
event.

It just happens to be that the caller calculates it using pointer
subtraction.  The trace event shouldn't reflect this.  One day the
caller might change the calculation and it would then be necessary to
change the type of the trace event.

Stefan
diff mbox

Patch

diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 6926eed..7b3743d 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -4,7 +4,7 @@ 
 virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) "vq %p elem %p len %u idx %u"
 virtqueue_flush(void *vq, unsigned int count) "vq %p count %u"
 virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) "vq %p elem %p in_num %u out_num %u"
-virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p"
+virtio_queue_notify(void *vdev, ptrdiff_t n, void *vq) "vdev %p n %td vq %p"
 virtio_notify_irqfd(void *vdev, void *vq) "vdev %p vq %p"
 virtio_notify(void *vdev, void *vq) "vdev %p vq %p"
 virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u"