Skip to contentSkip to conversation

introduce mechanism to check standard conformance of headers

PATCH New Jan Beulich 1 participant 1 message Jun 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 introduce mechanism to check standard conformance of headers

While pretty simplistic, it appears to serve the purpose at the moment (i.e. it spotted two places where a GNU extension was used withou proper preprocessor conditionals). The "simplistic" here includes that the checking gets only done for native builds, and ia64 gets excluded due to its arch-specific header intentionally (for whatever reason) checking that anonymous struct/unions can be used.

The two places needing adjustment were io/fsif.h's struct fsif_response and platform.h's struct xenpf_set_processor_pminfo. For the former, I tried adjusting minios sources, but stubdom fails to build in my environment (for other reasons), so I couldn't verify it really builds. For the latter, I'll try to put together a corresponding Linux side patch shortly.

extras/mini-os/fs-front.c +16 -16
@@ -218,7 +218,7 @@ int fs_open(struct fs_import *import, ch
     schedule();
     
     /* Read the response */
-    fd = (int)fsr->shadow_rsp.ret_val;
+    fd = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following FD returned: %d\n", fd);
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
@@ -256,7 +256,7 @@ int fs_close(struct fs_import *import, i
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("Close returned: %d\n", ret);
     add_id_to_freelist(priv_req_id, import->freelist);
 
@@ -313,7 +313,7 @@ ssize_t fs_read(struct fs_import *import
     schedule();
     
     /* Read the response */
-    ret = (ssize_t)fsr->shadow_rsp.ret_val;
+    ret = (ssize_t)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following ret value returned %d\n", ret);
     if(ret > 0)
     {
@@ -391,7 +391,7 @@ ssize_t fs_write(struct fs_import *impor
     schedule();
     
     /* Read the response */
-    ret = (ssize_t)fsr->shadow_rsp.ret_val;
+    ret = (ssize_t)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following ret value returned %d\n", ret);
     for(i=0; i<gnts.count; i++)
     {
@@ -435,10 +435,10 @@ int fs_stat(struct fs_import *import, 
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("Following ret from fstat: %d\n", ret);
     memcpy(stat, 
-           &fsr->shadow_rsp.fstat, 
+           &fsr->shadow_rsp.u.fstat,
            sizeof(struct fsif_stat_response));
     add_id_to_freelist(priv_req_id, import->freelist);
 
@@ -478,7 +478,7 @@ int fs_truncate(struct fs_import *import
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("Following ret from ftruncate: %d\n", ret);
     add_id_to_freelist(priv_req_id, import->freelist);
 
@@ -520,7 +520,7 @@ int fs_remove(struct fs_import *import, 
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following ret: %d\n", ret);
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
@@ -575,7 +575,7 @@ int fs_rename(struct fs_import *import, 
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following ret: %d\n", ret);
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
@@ -621,7 +621,7 @@ int fs_create(struct fs_import *import, 
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following ret: %d\n", ret);
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
@@ -670,7 +670,7 @@ char** fs_list(struct fs_import *import,
     schedule();
     
     /* Read the response */
-    *nr_files = (fsr->shadow_rsp.ret_val & NR_FILES_MASK) >> NR_FILES_SHIFT;
+    *nr_files = (fsr->shadow_rsp.u.ret_val & NR_FILES_MASK) >> NR_FILES_SHIFT;
     files = NULL;
     if(*nr_files <= 0) goto exit;
     files = malloc(sizeof(char*) * (*nr_files));
@@ -681,7 +681,7 @@ char** fs_list(struct fs_import *import,
         current_file += strlen(current_file) + 1;
     }
     if(has_more != NULL)
-        *has_more = fsr->shadow_rsp.ret_val & HAS_MORE_FLAG;
+        *has_more = fsr->shadow_rsp.u.ret_val & HAS_MORE_FLAG;
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
 exit:
@@ -719,7 +719,7 @@ int fs_chmod(struct fs_import *import, i
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following returned: %d\n", ret);
     add_id_to_freelist(priv_req_id, import->freelist);
 
@@ -761,7 +761,7 @@ int64_t fs_space(struct fs_import *impor
     schedule();
     
     /* Read the response */
-    ret = (int64_t)fsr->shadow_rsp.ret_val;
+    ret = (int64_t)fsr->shadow_rsp.u.ret_val;
     DEBUG("The following returned: %lld\n", ret);
     free_buffer_page(fsr);
     add_id_to_freelist(priv_req_id, import->freelist);
@@ -799,7 +799,7 @@ int fs_sync(struct fs_import *import, in
     schedule();
     
     /* Read the response */
-    ret = (int)fsr->shadow_rsp.ret_val;
+    ret = (int)fsr->shadow_rsp.u.ret_val;
     DEBUG("Close returned: %d\n", ret);
     add_id_to_freelist(priv_req_id, import->freelist);
 
@@ -852,7 +852,7 @@ moretodo:   
 
         rsp = RING_GET_RESPONSE(&import->ring, cons); 
         DEBUG("Response at idx=%d to request id=%d, ret_val=%lx\n", 
-            cons, rsp->id, rsp->ret_val);
+            cons, rsp->id, rsp->u.ret_val);
         req = &import->requests[rsp->id];
         memcpy(&req->shadow_rsp, rsp, sizeof(struct fsif_response));
         DEBUG("Waking up: %s\n", req->thread->name);
tools/fs-back/fs-ops.c +22 -22

130 lines not on this page · raw message

xen/arch/ia64/xen/platform_hypercall.c +1 -1
@@ -48,7 +48,7 @@ long do_platform_op(XEN_GUEST_HANDLE(xen
                 break;
             }
             ret = set_px_pminfo(op->u.set_pminfo.id,
-                    &op->u.set_pminfo.perf);
+                                &op->u.set_pminfo.u.perf);
             break;
 
         case XEN_PM_CX:
xen/arch/x86/platform_hypercall.c +2 -2
@@ -360,7 +360,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
                 ret = -ENOSYS;
                 break;
             }
-            ret = set_px_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.perf);
+            ret = set_px_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.u.perf);
             break;
  
         case XEN_PM_CX:
@@ -369,7 +369,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
                 ret = -ENOSYS;
                 break;
             }
-            ret = set_cx_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.power);
+            ret = set_cx_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.u.power);
             break;
 
         case XEN_PM_TX:
xen/include/Makefile +20 -0
@@ -1,3 +1,6 @@
+XEN_ROOT:=$(BASEDIR)/..
+include $(XEN_ROOT)/Config.mk
+
 ifneq ($(CONFIG_COMPAT),)
 
 compat-arch-$(CONFIG_X86) := x86_32
@@ -35,6 +38,9 @@ suffix-$(CONFIG_X86)      := \#pragma pa
 
 endif
 
+public-$(CONFIG_X86) := $(wildcard public/arch-x86/*.h public/arch-x86/*/*.h)
+public-$(CONFIG_IA64) := $(wildcard public/arch-ia64/*.h public/arch-ia64/*/*.h)
+
 .PHONY: all
 all: $(headers-y)
 
@@ -67,5 +73,19 @@ compat/xlat.h: xlat.lst $(filter-out com
 	done >[email protected]
 	mv -f [email protected] $@
 
+ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
+# public/arch-ia64.h explicitly bails on __STRICT_ANSI__
+ifeq ($(CONFIG_IA64),)
+
+all: headers.chk
+
+headers.chk: $(filter-out public/arch-% public/%ctl.h public/xsm/% public/%hvm/save.h, \
+			  $(wildcard public/*.h public/*/*.h) $(public-y)) Makefile
+	for i in $(filter %.h,$^); do $(CC) -ansi -include stdint.h -Wall -W -Werror -S -o /dev/null -xc $$i || exit 1; echo $$i; done >[email protected]
+	mv [email protected] $@
+
+endif
+endif
+
 clean::
 	rm -rf compat
xen/include/public/event_channel.h +2 -0
@@ -27,6 +27,8 @@
 #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
 
+#include "xen.h"
+
 /*
  * Prototype for this hypercall is:
  *  int event_channel_op(int cmd, void *args)
xen/include/public/grant_table.h +1 -0
@@ -28,6 +28,7 @@
 #ifndef __XEN_PUBLIC_GRANT_TABLE_H__
 #define __XEN_PUBLIC_GRANT_TABLE_H__
 
+#include "xen.h"
 
 /***********************************
  * GRANT TABLE REPRESENTATION
xen/include/public/hvm/hvm_op.h +2 -0
@@ -21,6 +21,8 @@
 #ifndef __XEN_PUBLIC_HVM_HVM_OP_H__
 #define __XEN_PUBLIC_HVM_HVM_OP_H__
 
+#include "../xen.h"
+
 /* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */
 #define HVMOP_set_param           0
 #define HVMOP_get_param           1
xen/include/public/io/fsif.h +1 -1
@@ -169,7 +169,7 @@ struct fsif_response {
     union {
         uint64_t ret_val;
         struct fsif_stat_response fstat;
-    };
+    } u;
 };
 
 typedef struct fsif_response fsif_response_t;
xen/include/public/io/xs_wire.h +2 -0
@@ -60,6 +60,7 @@ struct xsd_errors
     int errnum;
     const char *errstring;
 };
+#ifdef EINVAL
 #define XSD_ERROR(x) { x, #x }
 /* LINTED: static unused */
 static struct xsd_errors xsd_errors[]
@@ -82,6 +83,7 @@ __attribute__((unused))
     XSD_ERROR(EAGAIN),
     XSD_ERROR(EISCONN)
 };
+#endif
 
 struct xsd_sockmsg
 {
xen/include/public/memory.h +2 -0
@@ -27,6 +27,8 @@
 #ifndef __XEN_PUBLIC_MEMORY_H__
 #define __XEN_PUBLIC_MEMORY_H__
 
+#include "xen.h"
+
 /*
  * Increase or decrease the specified domain's memory reservation. Returns the
  * number of extents successfully allocated or freed.
xen/include/public/nmi.h +2 -0
@@ -27,6 +27,8 @@
 #ifndef __XEN_PUBLIC_NMI_H__
 #define __XEN_PUBLIC_NMI_H__
 
+#include "xen.h"
+
 /*
  * NMI reason codes:
  * Currently these are x86-specific, stored in arch_shared_info.nmi_reason.
xen/include/public/physdev.h +2 -0
@@ -21,6 +21,8 @@
 #ifndef __XEN_PUBLIC_PHYSDEV_H__
 #define __XEN_PUBLIC_PHYSDEV_H__
 
+#include "xen.h"
+
 /*
  * Prototype for this hypercall is:
  *  int physdev_op(int cmd, void *args)
xen/include/public/platform.h +1 -1
@@ -307,7 +307,7 @@ struct xenpf_set_processor_pminfo {
     union {
         struct xen_processor_power          power;/* Cx: _CST/_CSD */
         struct xen_processor_performance    perf; /* Px: _PPC/_PCT/_PSS/_PSD */
-    };
+    } u;
 };
 typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
 DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
xen/include/public/vcpu.h +2 -0
@@ -27,6 +27,8 @@
 #ifndef __XEN_PUBLIC_VCPU_H__
 #define __XEN_PUBLIC_VCPU_H__
 
+#include "xen.h"
+
 /*
  * Prototype for this hypercall is:
  *  int vcpu_op(int cmd, int vcpuid, void *extra_args)