kvmtool: avoid casts when initializing structures
PATCH 1/1 kvmtool: avoid casts when initializing structures
Due to our kernel heritage we have code in kvmtool that relies on the (still) implicit -std=gnu89 compiler switch.
It turns out that this just affects some structure initialization, where we currently provide a cast to the type, which upsets GCC for anything beyond -std=gnu89 (for instance gnu99 or gnu11). We do need the casts when initializing structures that are not assigned to the same type, so we put it there explicitly.
This allows us to compile with all the three standards GCC currently
supports: gnu89/90, gnu99 and gnu11.
GCC threatens people with moving to gnu11 as the new default standard, so lets fix this better sooner than later.
---
Hi,
TBH I don't know why we had those casts there in the first place, but it works without them, even for -std=gnu89.
If people agree with this, we can think about dropping the forced CFLAGS and LDFLAGS reset in the Makefile again, since this patch should fix compilation on Dave Jones' machine as well ;-)
Cheers,
Andre.
disk/qcow.c | 6 +++--- include/kvm/mutex.h | 2 +- include/linux/rbtree.h | 2 +- virtio/9p.c | 2 +- virtio/balloon.c | 2 +- virtio/blk.c | 2 +- virtio/console.c | 2 +- virtio/net.c | 2 +- virtio/rng.c | 2 +- virtio/scsi.c | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-)
disk/qcow.c +3 -3
@@ -1203,7 +1203,7 @@ static int qcow_read_refcount_table(struct qcow *q)if (!rft->rf_table)return -1 ; - rft->root =RB_ROOT ; + rft->root = (struct rb_root )RB_ROOT ;INIT_LIST_HEAD (&rft->lru_list);return pread_in_full (q->fd, rft->rf_table,sizeof (u64) * rft->rf_size, header->refcount_table_offset);
@@ -1289,7 +1289,7 @@ static struct disk_image *qcow2_probe(int fd, bool readonly) l1t = &q->table; - l1t->root =RB_ROOT ; + l1t->root = (struct rb_root )RB_ROOT ;INIT_LIST_HEAD (&l1t->lru_list); h = q->header =qcow2_read_header (fd);
@@ -1435,7 +1435,7 @@ static struct disk_image *qcow1_probe(int fd, bool readonly) l1t = &q->table; - l1t->root =RB_ROOT ; + l1t->root = (struct rb_root )RB_ROOT ;INIT_LIST_HEAD (&l1t->lru_list); h = q->header =qcow1_read_header (fd);
include/kvm/mutex.h +1 -1
@@ -13,7 +13,7 @@struct mutex {pthread_mutex_t mutex; }; -#define MUTEX_INITIALIZER (struct mutex) { .mutex = PTHREAD_MUTEX_INITIALIZER } +#define MUTEX_INITIALIZER { .mutex = PTHREAD_MUTEX_INITIALIZER }#define DEFINE_MUTEX (mtx) struct mutex mtx = MUTEX_INITIALIZER
include/linux/rbtree.h +1 -1
@@ -46,7 +46,7 @@ struct rb_root {#define rb_parent (r) ((struct rb_node *)((r)->__rb_parent_color & ~3)) -#define RB_ROOT (struct rb_root) { NULL, } +#define RB_ROOT { NULL, }#define rb_entry (ptr, type, member) container_of(ptr, type, member)#define RB_EMPTY_ROOT (root) ((root)->rb_node == NULL)
virtio/9p.c +1 -1
@@ -1320,7 +1320,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -struct virtio_ops p9_dev_virtio_ops = (struct virtio_ops ) { +struct virtio_ops p9_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/balloon.c +1 -1
@@ -239,7 +239,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -struct virtio_ops bln_dev_virtio_ops = (struct virtio_ops ) { +struct virtio_ops bln_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/blk.c +1 -1
@@ -244,7 +244,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -static struct virtio_ops blk_dev_virtio_ops = (struct virtio_ops ) { +static struct virtio_ops blk_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/console.c +1 -1
@@ -197,7 +197,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -static struct virtio_ops con_dev_virtio_ops = (struct virtio_ops ) { +static struct virtio_ops con_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/net.c +1 -1
@@ -624,7 +624,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -static struct virtio_ops net_dev_virtio_ops = (struct virtio_ops ) { +static struct virtio_ops net_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/rng.c +1 -1
@@ -141,7 +141,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -static struct virtio_ops rng_dev_virtio_ops = (struct virtio_ops ) { +static struct virtio_ops rng_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
virtio/scsi.c +1 -1
@@ -167,7 +167,7 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)return size; } -static struct virtio_ops scsi_dev_virtio_ops = (struct virtio_ops ) { +static struct virtio_ops scsi_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features,
Signature · 4 lines
2.3.5 -- To unsubscribe from this list: send the line "unsubscribe kvm" in