Skip to contentSkip to conversation

More tools build fixes with clang

PATCH In review Andrew Cooper 3 participants 23 messages Apr 27, 2016

lore
Share & tools
lore
#0 lore raw

cover More tools build fixes with clang

With these fixes, tools/ can be built with clang, so enable it in the travis configurion.

The travis results can be viewed here:
https://travis-ci.org/andyhhp/xen/builds/126153860

Andrew Cooper (7):
tools/xenstat: Avoid comparing '0 <= unsigned integer' tools/blktap2: Use abort() instead of custom crash tools/blktap2: Fix array initialisers for tapdisk_disk_{types,drivers}[] tools/blktap2: Fix use of uninitialised variable in _tap_list_join3() tools/kdd: Fix uninitialised variable warning
travis: Remove clang-3.8 build
travis: Enable tools when building with clang

 .travis.yml                              |  4 ----
 scripts/travis-build                     |  8 ++------
 tools/blktap2/control/tap-ctl-list.c     |  4 ++--
 tools/blktap2/drivers/block-vhd.c        |  2 +-
 tools/blktap2/drivers/tapdisk-disktype.c | 20 ++++++++------------
 tools/debugger/kdd/kdd.c                 |  2 +-
 tools/xenstat/libxenstat/src/xenstat.c   |  8 ++++----
 7 files changed, 18 insertions(+), 30 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH 1/7 tools/xenstat: Avoid comparing '0 <= unsigned integer'

Clang points out that this is tautological.

src/xenstat.c:325:8: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]

          if (0 <= index && index < node->num_domains)
              ~ ^  ~~~~~

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/xenstat/libxenstat/src/xenstat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/xenstat/libxenstat/src/xenstat.c +4 -4
index 3495f3f..fbe44f3 100644
@@ -322,7 +322,7 @@ xenstat_domain *xenstat_node_domain(xenstat_node * node, unsigned int domid)
 xenstat_domain *xenstat_node_domain_by_index(xenstat_node * node,
 					     unsigned int index)
 {
-	if (0 <= index && index < node->num_domains)
+	if (index < node->num_domains)
 		return &(node->domains[index]);
 	return NULL;
 }
@@ -389,7 +389,7 @@ unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain)
 
 xenstat_vcpu *xenstat_domain_vcpu(xenstat_domain * domain, unsigned int vcpu)
 {
-	if (0 <= vcpu && vcpu < domain->num_vcpus)
+	if (vcpu < domain->num_vcpus)
 		return &(domain->vcpus[vcpu]);
 	return NULL;
 }
@@ -457,7 +457,7 @@ unsigned int xenstat_domain_num_networks(xenstat_domain * domain)
 xenstat_network *xenstat_domain_network(xenstat_domain * domain,
 					unsigned int network)
 {
-	if (domain->networks && 0 <= network && network < domain->num_networks)
+	if (domain->networks && network < domain->num_networks)
 		return &(domain->networks[network]);
 	return NULL;
 }
@@ -472,7 +472,7 @@ unsigned int xenstat_domain_num_vbds(xenstat_domain * domain)
 xenstat_vbd *xenstat_domain_vbd(xenstat_domain * domain,
 				unsigned int vbd)
 {
-	if (domain->vbds && 0 <= vbd && vbd < domain->num_vbds)
+	if (domain->vbds && vbd < domain->num_vbds)
 		return &(domain->vbds[vbd]);
 	return NULL;
 }
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 1/7
#2 lore raw

Re: [PATCH for-4.7 1/7] tools/xenstat: Avoid comparing '0 <= unsigned integer'

Quoted 8 lines · Andrew Cooper

Clang points out that this is tautological.

src/xenstat.c:325:8: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]

          if (0 <= index && index < node->num_domains)
              ~ ^  ~~~~~

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/7
#3 lore raw

Re: [PATCH for-4.7 1/7] tools/xenstat: Avoid comparing '0 <= unsigned integer'

In reply to Andrew Cooper
Quoted 9 lines · Andrew Cooper

Clang points out that this is tautological.

src/xenstat.c:325:8: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]

          if (0 <= index && index < node->num_domains)
              ~ ^  ~~~~~

---

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

PATCH 2/7 tools/blktap2: Use abort() instead of custom crash

In reply to Andrew Cooper

Like c/s 4d98d3ebf - there is a second instance.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/blktap2/drivers/block-vhd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/blktap2/drivers/block-vhd.c +1 -1
index 76ea5bd..f7853f9 100644
@@ -85,7 +85,7 @@ unsigned int SPB;
 		DBG(TLOG_WARN, "%s:%d: FAILED ASSERTION: '%s'\n",	\
 		    __FILE__, __LINE__, #_p);				\
 		tlog_flush();						\
-		*(int*)0 = 0;						\
+		abort();                                                \
 	}
 
 #if (DEBUGGING == 1)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#7 lore raw

PATCH 3/7 tools/blktap2: Fix array initialisers for tapdisk_disk_{types, drivers}[]

In reply to Andrew Cooper

Clang points out:

tapdisk-disktype.c:117:2: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]

          0,
          ^

tapdisk-disktype.c:115:23: note: previous initialization is here
[DISK_TYPE_VINDEX] = &vhd_index_disk,
^~~~~~~~~~~~~~~

Mixing different initialiser styles should be avoided; The actual behaviour is different to the expected behaviour. This specific example has been broken since its introduction in c/s 7b4dea554 "blktap2: Fix tapdisk disktype issues" in 2010, and is caused by the '#if 0' block removing &tapdisk_{sync,vmdk}.

First of all, remove what were intended to be trailing NULL entries in tapdisk_disk_{types,drivers}[], making consistent use of Designated Initialisers for the initialisation.

This requires changing the loop in tapdisk_disktype_find() to be based on the number of elements in tapdisk_disk_types[], rather than looking for the first NULL. This fixes a latent bug, as the use of Designated Initializers causes to intermediate zero entries if not all indices are explicitly specified.

There is a second latent bug where tapdisk_disktype_find() assumes that tapdisk_disk_drivers[] has at least as many entries as tapdisk_disk_types[]. This is not the case and tapdisk_disk_drivers[] had one entry fewer than tapdisk_disk_types[], but the NULL loop bound prevented an out-of-bounds read of tapdisk_disk_drivers[]. Fix the issue by explicitly declaring tapdisk_disk_drivers[] to have the same number of entries as tapdisk_disk_types[].

Finally, this leads to a linker error. It turns out that tapdisk_vhd_index doesn't exist, and I can't find any evidence in the source history to suggest that it ever did. I can only presume that it would have been #if 0'd out like tapdisk_sync and tapdisk_vmdk had it not been for this bug preventing a build failure. Drop all three.

No functional change, but only because of the specific layout of tapdisk_disk_types[].

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

Please can someone carefully check my "No functional change" assertion? I am fairly sure it is correct, but this is a gnarly.

---
 tools/blktap2/drivers/tapdisk-disktype.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
tools/blktap2/drivers/tapdisk-disktype.c +8 -12
index e9a6890..e89d364 100644
@@ -33,6 +33,8 @@
 #include "tapdisk-disktype.h"
 #include "tapdisk-message.h"
 
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
+
 static const disk_info_t aio_disk = {
        "aio",
        "raw image (aio)",
@@ -112,35 +114,25 @@ const disk_info_t *tapdisk_disk_types[] = {
 	[DISK_TYPE_LOG]	= &log_disk,
 	[DISK_TYPE_VINDEX]	= &vhd_index_disk,
 	[DISK_TYPE_REMUS]	= &remus_disk,
-	0,
 };
 
 extern struct tap_disk tapdisk_aio;
-extern struct tap_disk tapdisk_sync;
-extern struct tap_disk tapdisk_vmdk;
 extern struct tap_disk tapdisk_vhdsync;
 extern struct tap_disk tapdisk_vhd;
 extern struct tap_disk tapdisk_ram;
 extern struct tap_disk tapdisk_qcow;
 extern struct tap_disk tapdisk_block_cache;
-extern struct tap_disk tapdisk_vhd_index;
 extern struct tap_disk tapdisk_log;
 extern struct tap_disk tapdisk_remus;
 
-const struct tap_disk *tapdisk_disk_drivers[] = {
+const struct tap_disk *tapdisk_disk_drivers[ARRAY_SIZE(tapdisk_disk_types)] = {
 	[DISK_TYPE_AIO]         = &tapdisk_aio,
-#if 0
-	[DISK_TYPE_SYNC]        = &tapdisk_sync,
-	[DISK_TYPE_VMDK]        = &tapdisk_vmdk,
-#endif
 	[DISK_TYPE_VHD]         = &tapdisk_vhd,
 	[DISK_TYPE_RAM]         = &tapdisk_ram,
 	[DISK_TYPE_QCOW]        = &tapdisk_qcow,
 	[DISK_TYPE_BLOCK_CACHE] = &tapdisk_block_cache,
-	[DISK_TYPE_VINDEX]      = &tapdisk_vhd_index,
 	[DISK_TYPE_LOG]         = &tapdisk_log,
 	[DISK_TYPE_REMUS]       = &tapdisk_remus,
-	0,
 };
 
 int
@@ -149,7 +141,11 @@ tapdisk_disktype_find(const char *name)
 	const disk_info_t *info;
 	int i;
 
-	for (i = 0; info = tapdisk_disk_types[i], info != NULL; ++i) {
+	for (i = 0; i < ARRAY_SIZE(tapdisk_disk_types); ++i) {
+		info = tapdisk_disk_types[i];
+		if (!info)
+			continue;
+
 		if (strcmp(name, info->name))
 			continue;
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 3/7
#8 lore raw

Re: [PATCH for-4.7 3/7] tools/blktap2: Fix array initialisers for tapdisk_disk_{types, drivers}[]

Quoted 38 lines · Andrew Cooper

Clang points out:

tapdisk-disktype.c:117:2: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]

          0,
          ^

tapdisk-disktype.c:115:23: note: previous initialization is here
[DISK_TYPE_VINDEX] = &vhd_index_disk,
^~~~~~~~~~~~~~~

Mixing different initialiser styles should be avoided; The actual behaviour is different to the expected behaviour. This specific example has been broken since its introduction in c/s 7b4dea554 "blktap2: Fix tapdisk disktype issues" in 2010, and is caused by the '#if 0' block removing &tapdisk_{sync,vmdk}.

First of all, remove what were intended to be trailing NULL entries in tapdisk_disk_{types,drivers}[], making consistent use of Designated Initialisers for the initialisation.

This requires changing the loop in tapdisk_disktype_find() to be based on the number of elements in tapdisk_disk_types[], rather than looking for the first NULL. This fixes a latent bug, as the use of Designated Initializers causes to intermediate zero entries if not all indices are explicitly specified.

There is a second latent bug where tapdisk_disktype_find() assumes that tapdisk_disk_drivers[] has at least as many entries as tapdisk_disk_types[]. This is not the case and tapdisk_disk_drivers[] had one entry fewer than tapdisk_disk_types[], but the NULL loop bound prevented an out-of-bounds read of tapdisk_disk_drivers[]. Fix the issue by explicitly declaring tapdisk_disk_drivers[] to have the same number of entries as tapdisk_disk_types[].

Finally, this leads to a linker error. It turns out that tapdisk_vhd_index doesn't exist, and I can't find any evidence in the source history to suggest that it ever did. I can only presume that it would have been #if 0'd out like tapdisk_sync and tapdisk_vmdk had it not been for this bug preventing a build failure. Drop all three.

Quoted 4 lines

No functional change, but only because of the specific layout of tapdisk_disk_types[].

Quoted 6 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

Please can someone carefully check my "No functional change" assertion? I am fairly sure it is correct, but this is a gnarly.

You assertion should be correct.

Quoted 70 lines
---
 tools/blktap2/drivers/tapdisk-disktype.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
tools/blktap2/drivers/tapdisk-disktype.c +8 -12
index e9a6890..e89d364 100644
@@ -33,6 +33,8 @@
 #include "tapdisk-disktype.h"
 #include "tapdisk-message.h"
 
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
+
 static const disk_info_t aio_disk = {
        "aio",
        "raw image (aio)",
@@ -112,35 +114,25 @@ const disk_info_t *tapdisk_disk_types[] = {
 	[DISK_TYPE_LOG]	= &log_disk,
 	[DISK_TYPE_VINDEX]	= &vhd_index_disk,
 	[DISK_TYPE_REMUS]	= &remus_disk,
-	0,
 };
 
 extern struct tap_disk tapdisk_aio;
-extern struct tap_disk tapdisk_sync;
-extern struct tap_disk tapdisk_vmdk;
 extern struct tap_disk tapdisk_vhdsync;
 extern struct tap_disk tapdisk_vhd;
 extern struct tap_disk tapdisk_ram;
 extern struct tap_disk tapdisk_qcow;
 extern struct tap_disk tapdisk_block_cache;
-extern struct tap_disk tapdisk_vhd_index;
 extern struct tap_disk tapdisk_log;
 extern struct tap_disk tapdisk_remus;
 
-const struct tap_disk *tapdisk_disk_drivers[] = {
+const struct tap_disk *tapdisk_disk_drivers[ARRAY_SIZE(tapdisk_disk_types)] = {
 	[DISK_TYPE_AIO]         = &tapdisk_aio,
-#if 0
-	[DISK_TYPE_SYNC]        = &tapdisk_sync,
-	[DISK_TYPE_VMDK]        = &tapdisk_vmdk,
-#endif
 	[DISK_TYPE_VHD]         = &tapdisk_vhd,
 	[DISK_TYPE_RAM]         = &tapdisk_ram,
 	[DISK_TYPE_QCOW]        = &tapdisk_qcow,
 	[DISK_TYPE_BLOCK_CACHE] = &tapdisk_block_cache,
-	[DISK_TYPE_VINDEX]      = &tapdisk_vhd_index,
 	[DISK_TYPE_LOG]         = &tapdisk_log,
 	[DISK_TYPE_REMUS]       = &tapdisk_remus,
-	0,
 };
 
 int
@@ -149,7 +141,11 @@ tapdisk_disktype_find(const char *name)
 	const disk_info_t *info;
 	int i;
 
-	for (i = 0; info = tapdisk_disk_types[i], info != NULL; ++i) {
+	for (i = 0; i < ARRAY_SIZE(tapdisk_disk_types); ++i) {
+		info = tapdisk_disk_types[i];
+		if (!info)
+			continue;
+
 		if (strcmp(name, info->name))
 			continue;
 
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 3/7
#9 lore raw

Re: [PATCH for-4.7 3/7] tools/blktap2: Fix array initialisers for tapdisk_disk_{types, drivers}[]

In reply to Andrew Cooper
Quoted 38 lines · Andrew Cooper

Clang points out:

tapdisk-disktype.c:117:2: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]

          0,
          ^

tapdisk-disktype.c:115:23: note: previous initialization is here
[DISK_TYPE_VINDEX] = &vhd_index_disk,
^~~~~~~~~~~~~~~

Mixing different initialiser styles should be avoided; The actual behaviour is different to the expected behaviour. This specific example has been broken since its introduction in c/s 7b4dea554 "blktap2: Fix tapdisk disktype issues" in 2010, and is caused by the '#if 0' block removing &tapdisk_{sync,vmdk}.

First of all, remove what were intended to be trailing NULL entries in tapdisk_disk_{types,drivers}[], making consistent use of Designated Initialisers for the initialisation.

This requires changing the loop in tapdisk_disktype_find() to be based on the number of elements in tapdisk_disk_types[], rather than looking for the first NULL. This fixes a latent bug, as the use of Designated Initializers causes to intermediate zero entries if not all indices are explicitly specified.

There is a second latent bug where tapdisk_disktype_find() assumes that tapdisk_disk_drivers[] has at least as many entries as tapdisk_disk_types[]. This is not the case and tapdisk_disk_drivers[] had one entry fewer than tapdisk_disk_types[], but the NULL loop bound prevented an out-of-bounds read of tapdisk_disk_drivers[]. Fix the issue by explicitly declaring tapdisk_disk_drivers[] to have the same number of entries as tapdisk_disk_types[].

Finally, this leads to a linker error. It turns out that tapdisk_vhd_index doesn't exist, and I can't find any evidence in the source history to suggest that it ever did. I can only presume that it would have been #if 0'd out like tapdisk_sync and tapdisk_vmdk had it not been for this bug preventing a build failure. Drop all three.

Quoted 5 lines

No functional change, but only because of the specific layout of tapdisk_disk_types[].

---

Your assertion appears correct to me. Its the same conclusion I came to and same solution I came to independently.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw

PATCH 4/7 tools/blktap2: Fix use of uninitialised variable in _tap_list_join3()

In reply to Andrew Cooper

Clang points out:

tap-ctl-list.c:457:28: error: variable 'entry' is uninitialized when used here [-Werror,-Wuninitialized]

          for (; *_entry != NULL; ++entry) {
                                    ^~~~~

The content of that loop clearly was meant to iterate over _entry rather than entry, so is fixed to do so. This presumably fixes a memory leak when tapdisks get orphed, as only the first item on the list got freed.

There is no use of entry at all. It is referenced in a list_for_each_entry(tl, &tap->list, entry) construct, but this is just a member name, and not a reference to local scope variable of the same name.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/blktap2/control/tap-ctl-list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/blktap2/control/tap-ctl-list.c +2 -2
index c91f6f4..f8d49c3 100644
@@ -400,7 +400,7 @@ int
 _tap_list_join3(int n_minors, int *minorv, int n_taps, struct tapdisk *tapv,
 		tap_list_t ***_list)
 {
-	tap_list_t **list, **_entry, *entry;
+	tap_list_t **list, **_entry;
 	int i, _m, err;
 
 	list = tap_ctl_alloc_list(n_minors + n_taps);
@@ -454,7 +454,7 @@ _tap_list_join3(int n_minors, int *minorv, int n_taps, struct tapdisk *tapv,
 	}
 
 	/* free extraneous list entries */
-	for (; *_entry != NULL; ++entry) {
+	for (; *_entry != NULL; ++_entry) {
 		free_list(*_entry);
 		*_entry = NULL;
 	}
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 4/7
#11 lore raw

Re: [PATCH for-4.7 4/7] tools/blktap2: Fix use of uninitialised variable in _tap_list_join3()

Quoted 11 lines · Andrew Cooper

Clang points out:

tap-ctl-list.c:457:28: error: variable 'entry' is uninitialized when used here [-Werror,-Wuninitialized]

          for (; *_entry != NULL; ++entry) {
                                    ^~~~~

The content of that loop clearly was meant to iterate over _entry rather than entry, so is fixed to do so. This presumably fixes a memory leak when tapdisks get orphed, as only the first item on the list got freed.

Quoted 5 lines

There is no use of entry at all. It is referenced in a list_for_each_entry(tl, &tap->list, entry) construct, but this is just a member name, and not a reference to local scope variable of the same name.

Quoted 32 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/blktap2/control/tap-ctl-list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/blktap2/control/tap-ctl-list.c +2 -2
index c91f6f4..f8d49c3 100644
@@ -400,7 +400,7 @@ int
 _tap_list_join3(int n_minors, int *minorv, int n_taps, struct tapdisk *tapv,
 		tap_list_t ***_list)
 {
-	tap_list_t **list, **_entry, *entry;
+	tap_list_t **list, **_entry;
 	int i, _m, err;
 
 	list = tap_ctl_alloc_list(n_minors + n_taps);
@@ -454,7 +454,7 @@ _tap_list_join3(int n_minors, int *minorv, int n_taps, struct tapdisk *tapv,
 	}
 
 	/* free extraneous list entries */
-	for (; *_entry != NULL; ++entry) {
+	for (; *_entry != NULL; ++_entry) {
 		free_list(*_entry);
 		*_entry = NULL;
 	}
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 4/7
#12 lore raw

Re: [PATCH for-4.7 4/7] tools/blktap2: Fix use of uninitialised variable in _tap_list_join3()

In reply to Andrew Cooper
Quoted 11 lines · Andrew Cooper

Clang points out:

tap-ctl-list.c:457:28: error: variable 'entry' is uninitialized when used here [-Werror,-Wuninitialized]

          for (; *_entry != NULL; ++entry) {
                                    ^~~~~

The content of that loop clearly was meant to iterate over _entry rather than entry, so is fixed to do so. This presumably fixes a memory leak when tapdisks get orphed, as only the first item on the list got freed.

Quoted 6 lines

There is no use of entry at all. It is referenced in a list_for_each_entry(tl, &tap->list, entry) construct, but this is just a member name, and not a reference to local scope variable of the same name.

---

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

PATCH 5/7 tools/kdd: Fix uninitialised variable warning

In reply to Andrew Cooper

Clang warns:

kdd.c:1031:9: error: variable 'fd' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]

      if (argc != 4
          ^~~~~~~~~
  kdd.c:1040:20: note: uninitialized use occurs here
      if (select(fd + 1, &fds, NULL, NULL, NULL) > 0)
                 ^~

This situation can't actually happen, as usage() is a terminal path. Annotate it appropriately.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/debugger/kdd/kdd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/debugger/kdd/kdd.c +1 -1
index 9a0225b..70f007e 100644
@@ -998,7 +998,7 @@ void kdd_select_callback(kdd_state *s)
 }
 
 
-static void usage(void)
+static void __attribute__((noreturn)) usage(void)
 {
     fprintf(stderr, 
 " usage: kdd [-v] <domid> <address> <port>\n"
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 5/7
#14 lore raw

Re: [PATCH for-4.7 5/7] tools/kdd: Fix uninitialised variable warning

Quoted 10 lines · Andrew Cooper

Clang warns:

kdd.c:1031:9: error: variable 'fd' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]

      if (argc != 4
          ^~~~~~~~~
  kdd.c:1040:20: note: uninitialized use occurs here
      if (select(fd + 1, &fds, NULL, NULL, NULL) > 0)
                 ^~
Quoted 4 lines

This situation can't actually happen, as usage() is a terminal path. Annotate it appropriately.

Quoted 23 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>

---
 tools/debugger/kdd/kdd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/debugger/kdd/kdd.c +1 -1
index 9a0225b..70f007e 100644
@@ -998,7 +998,7 @@ void kdd_select_callback(kdd_state *s)
 }
 
 
-static void usage(void)
+static void __attribute__((noreturn)) usage(void)
 {
     fprintf(stderr, 
 " usage: kdd [-v] <domid> <address> <port>\n"
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 5/7
#15 lore raw

Re: [PATCH for-4.7 5/7] tools/kdd: Fix uninitialised variable warning

In reply to Andrew Cooper
Quoted 10 lines · Andrew Cooper

Clang warns:

kdd.c:1031:9: error: variable 'fd' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]

      if (argc != 4
          ^~~~~~~~~
  kdd.c:1040:20: note: uninitialized use occurs here
      if (select(fd + 1, &fds, NULL, NULL, NULL) > 0)
                 ^~
Quoted 5 lines

This situation can't actually happen, as usage() is a terminal path. Annotate it appropriately.

---

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#16 lore raw

PATCH 6/7 travis: Remove clang-3.8 build

In reply to Andrew Cooper

The package appears to have been renamed in Ubuntu. The only reason this test is currently passing is because the hypervisor build falls back to clang, at version 3.5

Add an explicit test in the build script that out desired compiler is available. Note that travis already performs this step, but in a way which isn't fatal to the build.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Doug Goldstein <[email protected]>

---
 .travis.yml          | 4 ----
 scripts/travis-build | 2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)
.travis.yml +0 -4
index 0eea94e..d2e1bec 100644
@@ -22,12 +22,8 @@ matrix:
           env: XEN_TARGET_ARCH=x86_64 debug=y
         - compiler: clang
           env: XEN_TARGET_ARCH=x86_64 clang=y debug=n
-        - compiler: clang-3.8
-          env: XEN_TARGET_ARCH=x86_64 clang=y debug=n
         - compiler: clang
           env: XEN_TARGET_ARCH=x86_64 clang=y debug=y
-        - compiler: clang-3.8
-          env: XEN_TARGET_ARCH=x86_64 clang=y debug=y
         - compiler: gcc
           env: XEN_TARGET_ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabihf- debug=n
         - compiler: gcc
scripts/travis-build +2 -0
index b553f20..9a5c1c8 100755
@@ -1,5 +1,7 @@
 #!/bin/bash -ex
 
+$CC --version
+
 # random config or default config
 if [[ "${RANDCONFIG}" == "y" ]]; then
     make -C xen randconfig
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 6/7
#17 lore raw

Re: [PATCH for-4.7 6/7] travis: Remove clang-3.8 build

Quoted 9 lines · Andrew Cooper

The package appears to have been renamed in Ubuntu. The only reason this test is currently passing is because the hypervisor build falls back to clang, at version 3.5

Add an explicit test in the build script that out desired compiler is available. Note that travis already performs this step, but in a way which isn't fatal to the build.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 6/7
#18 lore raw

Re: [PATCH for-4.7 6/7] travis: Remove clang-3.8 build

In reply to Andrew Cooper
Quoted 9 lines · Andrew Cooper

The package appears to have been renamed in Ubuntu. The only reason this test is currently passing is because the hypervisor build falls back to clang, at version 3.5

Add an explicit test in the build script that out desired compiler is available. Note that travis already performs this step, but in a way which isn't fatal to the build.

Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#19 lore raw

PATCH 7/7 travis: Enable tools when building with clang

In reply to Andrew Cooper

tools now build under clang, so let them be tested.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Doug Goldstein <[email protected]>

---
 scripts/travis-build | 6 ------
 1 file changed, 6 deletions(-)
scripts/travis-build +0 -6
index 9a5c1c8..584d008 100755
@@ -22,12 +22,6 @@ else
     cfgargs+=("--disable-tools") # we don't have the cross depends installed
 fi
 
-# Due to multiple build failures and the desire to get more
-# build testing (GCC only) enabled this is disabled
-if [[ "${clang}" == "y" ]]; then
-    cfgargs+=("--disable-tools")
-fi
-
 ./configure "${cfgargs[@]}"
 
 make dist
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v1 7/7
#20 lore raw

Re: [PATCH for-4.7 7/7] travis: Enable tools when building with clang

Quoted 3 lines · Andrew Cooper

tools now build under clang, so let them be tested.

Quoted 28 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Doug Goldstein <[email protected]>

---
 scripts/travis-build | 6 ------
 1 file changed, 6 deletions(-)
scripts/travis-build +0 -6
index 9a5c1c8..584d008 100755
@@ -22,12 +22,6 @@ else
     cfgargs+=("--disable-tools") # we don't have the cross depends installed
 fi
 
-# Due to multiple build failures and the desire to get more
-# build testing (GCC only) enabled this is disabled
-if [[ "${clang}" == "y" ]]; then
-    cfgargs+=("--disable-tools")
-fi
-
 ./configure "${cfgargs[@]}"
 
 make dist
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#22 lore raw
In reply to Andrew Cooper
Quoted 6 lines · Andrew Cooper

With these fixes, tools/ can be built with clang, so enable it in the travis configurion.

The travis results can be viewed here:
https://travis-ci.org/andyhhp/xen/builds/126153860

Quoted 9 lines

Andrew Cooper (7):
tools/xenstat: Avoid comparing '0 <= unsigned integer' tools/blktap2: Use abort() instead of custom crash tools/blktap2: Fix array initialisers for tapdisk_disk_{types,drivers}[] tools/blktap2: Fix use of uninitialised variable in _tap_list_join3() tools/kdd: Fix uninitialised variable warning
travis: Remove clang-3.8 build
travis: Enable tools when building with clang

Whole series:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel