Skip to contentSkip to conversation

libxen compilation fixes

PATCH In review Ian Jackson 3 participants 4 messages Jan 15, 2008 – Jan 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxen compilation fixes

xen_common.h has the following function declaration:
extern xen_version *xen_get_client_side_version(void);

This is not a prototype and should be. Compilers invoked with sensible warning options barf on declarations which do not specify the argument types, even for function pointers.

Also, libxen should be compiled with -Wno-declaration-after-statement since it uses that programming style.

Ian.

tools/libxen/include/xen/api/xen_common.h +1 -1
Index: xen-unstable.hg/tools/libxen/include/xen/api/xen_common.h
===================================================================
@@ -107,7 +107,7 @@
  * minor, and extraversion of the Xen release with which it was released,
  * plus the library's own version as the patch.
  */
-extern xen_version *xen_get_client_side_version();
+extern xen_version *xen_get_client_side_version(void);
 
 
 extern bool
tools/libxen/Makefile +2 -1
Index: xen-unstable.hg/tools/libxen/Makefile
===================================================================
@@ -24,7 +24,8 @@
 CFLAGS = -Iinclude                     \
          $(shell xml2-config --cflags) \
          $(shell curl-config --cflags) \
-         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC
+         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC \
+         -Wno-declaration-after-statement
 
 LDFLAGS = $(shell xml2-config --libs) \
           $(shell curl-config --libs)
tools/libxen/Makefile.dist +2 -1
Index: xen-unstable.hg/tools/libxen/Makefile.dist
===================================================================
@@ -22,7 +22,8 @@
 CFLAGS = -Iinclude                     \
          $(shell xml2-config --cflags) \
          $(shell curl-config --cflags) \
-         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC
+         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC \
+         -Wno-declaration-after-statement
 
 LDFLAGS = $(shell xml2-config --libs) \
           $(shell curl-config --libs)

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

#1 lore raw

-Wno-declaration-after-statement is not supported by gcc older than 3.4. Also it should be the default behaviour anyway, even with -Wall, and libxen throws away the passed-in CFLAGS so it will never see -Wdeclaration-after-statement.

What would be nice would be to make libxen not throw away provided CFLAGS and, if it's not too far gone down the declaration-after-statement route, fix it to put its declarations at the top of blocks like a good C program. If that's a big job though it's probably not worth the bother.

-- Keir

Quoted 64 lines · Ian Jackson

xen_common.h has the following function declaration:
extern xen_version *xen_get_client_side_version(void);

This is not a prototype and should be. Compilers invoked with sensible warning options barf on declarations which do not specify the argument types, even for function pointers.

Also, libxen should be compiled with -Wno-declaration-after-statement since it uses that programming style.

Ian.

Index: xen-unstable.hg/tools/libxen/include/xen/api/xen_common.h
===================================================================
--- xen-unstable.hg.orig/tools/libxen/include/xen/api/xen_common.h 2008-01-15 16:06:48.000000000 +0000
+++ xen-unstable.hg/tools/libxen/include/xen/api/xen_common.h 2008-01-15 16:06:50.000000000 +0000

tools/libxen/include/xen/api/xen_common.h +1 -1
@@ -107,7 +107,7 @@
  * minor, and extraversion of the Xen release with which it was released,
  * plus the library's own version as the patch.
  */
-extern xen_version *xen_get_client_side_version();
+extern xen_version *xen_get_client_side_version(void);
 
 
 extern bool

Index: xen-unstable.hg/tools/libxen/Makefile
===================================================================
--- xen-unstable.hg.orig/tools/libxen/Makefile 2008-01-15 16:06:48.000000000 +0000
+++ xen-unstable.hg/tools/libxen/Makefile 2008-01-15 16:06:50.000000000 +0000

tools/libxen/Makefile +2 -1
@@ -24,7 +24,8 @@
 CFLAGS = -Iinclude                     \
          $(shell xml2-config --cflags) \
          $(shell curl-config --cflags) \
-         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC
+         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC \
+         -Wno-declaration-after-statement
 
 LDFLAGS = $(shell xml2-config --libs) \
           $(shell curl-config --libs)

Index: xen-unstable.hg/tools/libxen/Makefile.dist
===================================================================
--- xen-unstable.hg.orig/tools/libxen/Makefile.dist 2008-01-15 16:06:48.000000000 +0000
+++ xen-unstable.hg/tools/libxen/Makefile.dist 2008-01-15 16:06:50.000000000 +0000

tools/libxen/Makefile +2 -1
@@ -22,7 +22,8 @@
 CFLAGS = -Iinclude                     \
          $(shell xml2-config --cflags) \
          $(shell curl-config --cflags) \
-         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC
+         -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC \
+         -Wno-declaration-after-statement
 
 LDFLAGS = $(shell xml2-config --libs) \
           $(shell curl-config --libs)

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

#2 lore raw

Keir Fraser writes ("Re: [Xen-devel] [PATCH] libxen compilation fixes"):

Quoted 4 lines

-Wno-declaration-after-statement is not supported by gcc older than 3.4. Also it should be the default behaviour anyway, even with -Wall, and libxen throws away the passed-in CFLAGS so it will never see -Wdeclaration-after-statement.

I must have missed an earlier -Wdeclaration-after-statement provided by some package build script, then. Sorry.

Quoted 4 lines

What would be nice would be to make libxen not throw away provided CFLAGS and, if it's not too far gone down the declaration-after-statement route, fix it to put its declarations at the top of blocks like a good C program. If that's a big job though it's probably not worth the bother.

I think libxen is too far gone.

Ian.

#3 lore raw

Hi,

Quoted 5 lines

...

Quoted 4 lines

What would be nice would be to make libxen not throw away provided CFLAGS and, if it's not too far gone down the declaration-after-statement route, fix it to put its declarations at the top of blocks like a good C program. If that's a big job though it's probably not worth the bother.

Attached the patch to fix this. I left out the changes to the Makefile, as Keir objected because of the missing gcc-3.3 compatibility (which I can confirm). When I inserted -Wdeclaration-after-statement into my Makefile, everything compiled smoothly without any warnings. I included Ian's prototype fix, too.

Regards,
Andre.

Signature · 9 lines
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 277-84917
----to satisfy European Law for business letters:
AMD Saxony Limited Liability Company & Co. KG,
Wilschdorfer Landstr. 101, 01109 Dresden, Germany
Register Court Dresden: HRA 4896, General Partner authorized
to represent: AMD Saxony LLC (Wilmington, Delaware, US)
General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
tools/libxen/include/xen/api/xen_common.h +1 -1
diff -r d13c4d2836a8 tools/libxen/include/xen/api/xen_common.h
@@ -107,7 +107,7 @@ extern void xen_version_free(xen_version
  * minor, and extraversion of the Xen release with which it was released,
  * plus the library's own version as the patch.
  */
-extern xen_version *xen_get_client_side_version();
+extern xen_version *xen_get_client_side_version(void);
 
 
 extern bool
tools/libxen/src/xen_common.c +63 -45

287 lines not on this page · raw message

tools/libxen/src/xen_int_string_set_map.c +3 -1
diff -r d13c4d2836a8 tools/libxen/src/xen_int_string_set_map.c
@@ -36,12 +36,14 @@ void
 void
 xen_int_string_set_map_free(xen_int_string_set_map *map)
 {
+	size_t n;
+
     if (map == NULL)
     {
         return;
     }
 
-    size_t n = map->size;
+    n = map->size;
     for (size_t i = 0; i < n; i++)
     {
         
tools/libxen/src/xen_string_set.c +2 -1
diff -r d13c4d2836a8 tools/libxen/src/xen_string_set.c
@@ -33,11 +33,12 @@ void
 void
 xen_string_set_free(xen_string_set *set)
 {
+    size_t n;
     if (set == NULL)
     {
         return;
     }
-    size_t n = set->size;
+    n = set->size;
     for (size_t i = 0; i < n; i++)
     {
        free(set->contents[i]);
tools/libxen/src/xen_string_string_map.c +2 -1
diff -r d13c4d2836a8 tools/libxen/src/xen_string_string_map.c
@@ -35,12 +35,13 @@ void
 void
 xen_string_string_map_free(xen_string_string_map *map)
 {
+    size_t n;
     if (map == NULL)
     {
         return;
     }
 
-    size_t n = map->size;
+    n = map->size;
     for (size_t i = 0; i < n; i++)
     {
         free(map->contents[i].key);

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