Skip to contentSkip to conversation

vhost_net.c: v2 Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

PATCH In review [email protected] 2 participants 7 messages May 27, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost_net.c: v2 Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

---
 hw/vhost_net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/vhost_net.c +1 -1
index 26dae79..606aa0c 100644
@@ -100,7 +100,7 @@ struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd)
     }
     if (~net->dev.features & net->dev.backend_features) {
         fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",
-                ~net->dev.features & net->dev.backend_features);
+                (uint64_t)(~net->dev.features & net->dev.backend_features));
         vhost_dev_cleanup(&net->dev);
         goto fail;
     }
Signature · 1 line
1.6.5.2
#1 lore raw
Quoted 8 lines · On Thu, May 27, 2010 at 12:22:29PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

Quoted 9 lines
---
 hw/vhost_net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/vhost_net.c +0 -0
index 26dae79..606aa0c 100644

hw/vhost_net.c struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd) · line 106

Quoted 8 lines
hw/vhost_net.c +1 -1
@@ -100,7 +100,7 @@ struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd)
     }
     if (~net->dev.features & net->dev.backend_features) {
         fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",
-                ~net->dev.features & net->dev.backend_features);
+                (uint64_t)(~net->dev.features & net->dev.backend_features));
         vhost_dev_cleanup(&net->dev);
         goto fail;
     }

How about just (untested):

vhost: fix build broken by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

revert over-zealous PRIu64 conversion from
0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

---

Does this help?

hw/vhost_net.c +1 -1
index 26dae79..2e292ee 100644
@@ -99,7 +99,7 @@ struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd)
         goto fail;
     }
     if (~net->dev.features & net->dev.backend_features) {
-        fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",
+        fprintf(stderr, "vhost lacks feature mask %llu for backend\n",
                 ~net->dev.features & net->dev.backend_features);
         vhost_dev_cleanup(&net->dev);
         goto fail;
#2 lore raw
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · On Thu, May 27, 2010 at 12:22:29PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

Quoted 8 lines
Quoted 4 lines

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

That is an option too. Problem is just that unsigned long is 32 bit on 32 bit systems and Windows (even for 64 bit) so if we need more flags we need to be careful with it.

Cheers,
Jes

#3 lore raw
Quoted 15 lines · Jes Sorensen
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · On Thu, May 27, 2010 at 12:22:29PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

Quoted 8 lines
Quoted 4 lines

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

Quoted 6 lines

That is an option too. Problem is just that unsigned long is 32 bit on 32 bit systems and Windows (even for 64 bit) so if we need more flags we need to be careful with it.

Cheers,
Jes

I don't understand, sorry.
This field is unsigned long long, not unsigned long. %ll will print unsigned long long
for any standard printf, whatever its length.

Signature · 1 line
MST
#4 lore raw
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Jes Sorensen
Quoted 3 lines · Michael S. Tsirkin

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

That is an option too. Problem is just that unsigned long is 32 bit on 32 bit systems and Windows (even for 64 bit) so if we need more flags we need to be careful with it.

Quoted 7 lines
Quoted 2 lines

Cheers,
Jes

I don't understand, sorry.
This field is unsigned long long, not unsigned long. %ll will print unsigned long long
for any standard printf, whatever its length.

Ah ok, if the field is long long, then your patch should be just fine. I hadn't checked that was the case.

Cheers,
Jes

#5 lore raw
In reply to Jes Sorensen
Quoted 9 lines · Jes Sorensen
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · On Thu, May 27, 2010 at 12:22:29PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

That is an option too.

More importantly does this fix the problem for you?

Quoted 6 lines

Problem is just that unsigned long is 32 bit on
32 bit systems and Windows (even for 64 bit) so if we need more flags we need to be careful with it.

Cheers,
Jes

author Acked-by
#6 lore raw
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Jes Sorensen
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · On Thu, May 27, 2010 at 12:22:29PM +0200, [email protected] wrote:

From: Jes Sorensen <[email protected]>

Fix build failure introduced by 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2

The format statement expects unsigned long on x86_64, but receives unsigned long long, so gcc exits with an error.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I think this part of 0bfcd599e3f5c5679cc7d0165a0a1822e2f60de2 should just be reverted. We have unsigned long, it should be printed woith %ll. Casting to uint64_t just so we can print with PRIu64 seems silly.

That is an option too.

More importantly does this fix the problem for you?

Yes it works fine.