All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andre Przywara" <andre.przywara@amd.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH] libxen compilation fixes
Date: Wed, 16 Jan 2008 13:41:46 +0100	[thread overview]
Message-ID: <478DFB8A.7070103@amd.com> (raw)
In-Reply-To: <18317.55590.199871.482060@mariner.uk.xensource.com>

[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]

Hi,
 >...
>> 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.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

Regards,
Andre.

-- 
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

[-- Attachment #2: libxen_decl_statement.patch --]
[-- Type: text/plain, Size: 12952 bytes --]

diff -r d13c4d2836a8 tools/libxen/include/xen/api/xen_common.h
--- a/tools/libxen/include/xen/api/xen_common.h	Tue Jan 15 14:39:23 2008 +0000
+++ b/tools/libxen/include/xen/api/xen_common.h	Wed Jan 16 13:38:04 2008 +0100
@@ -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
diff -r d13c4d2836a8 tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c	Tue Jan 15 14:39:23 2008 +0000
+++ b/tools/libxen/src/xen_common.c	Wed Jan 16 13:38:04 2008 +0100
@@ -416,13 +416,13 @@ xen_call_(xen_session *s, const char *me
           abstract_value params[], int param_count,
           const abstract_type *result_type, void *value)
 {
+    abstract_value *full_params;
     if (!s->ok)
     {
         return;
     }
 
-    abstract_value *full_params =
-        malloc(sizeof(abstract_value) * (param_count + 1));
+    full_params = malloc(sizeof(abstract_value) * (param_count + 1));
 
     full_params[0].type = &abstract_type_string;
     full_params[0].u.string_val = s->session_id;
@@ -475,13 +475,14 @@ call_raw(xen_session *s, const char *met
 
 static void server_error(xen_session *session, const char *error_string)
 {
+    char **strings;
     if (!session->ok)
     {
         /* Don't wipe out the earlier error message with this one. */
         return;
     }
 
-    char **strings = malloc(2 * sizeof(char *));
+    strings = malloc(2 * sizeof(char *));
 
     strings[0] = xen_strdup_("SERVER_FAULT");
     strings[1] = xen_strdup_(error_string);
@@ -495,13 +496,14 @@ static void server_error_2(xen_session *
 static void server_error_2(xen_session *session, const char *error_string,
                            const char *param)
 {
+    char **strings;
     if (!session->ok)
     {
         /* Don't wipe out the earlier error message with this one. */
         return;
     }
 
-    char **strings = malloc(3 * sizeof(char *));
+    strings = malloc(3 * sizeof(char *));
 
     strings[0] = xen_strdup_("SERVER_FAULT_2");
     strings[1] = xen_strdup_(error_string);
@@ -791,17 +793,17 @@ static void parse_into(xen_session *s, x
         }
         else
         {
-            xmlNode *data_node = value_node->children->children;
-            int n = count_children(data_node, "value");
+            arbitrary_set *set;
+            xmlNode *cur, *data_node = value_node->children->children;
+            int i, n = count_children(data_node, "value");
 
             const abstract_type *member_type = result_type->child;
             size_t member_size = size_of_member(member_type);
 
-            arbitrary_set *set =
-                calloc(1, sizeof(arbitrary_set) + member_size * n);
+            set = calloc(1, sizeof(arbitrary_set) + member_size * n);
             set->size = n;
-            int i = 0;
-            xmlNode *cur = data_node->children;
+            i = 0;
+            cur = data_node->children;
 
             while (cur != NULL)
             {
@@ -829,24 +831,25 @@ static void parse_into(xen_session *s, x
         }
         else
         {
-            xmlNode *struct_node = value_node->children;
-            int n = count_children(struct_node, "member");
+            arbitrary_map *map;
+            xmlNode *cur, *struct_node = value_node->children;
+            int i, n = count_children(struct_node, "member");
 
             size_t struct_size = result_type->struct_size;
 
             const struct struct_member *key_member = result_type->members;
             const struct struct_member *val_member = result_type->members + 1;
 
-            arbitrary_map *map =
-                calloc(1, sizeof(arbitrary_map) + struct_size * n);
+            map = calloc(1, sizeof(arbitrary_map) + struct_size * n);
             map->size = n;
-            int i = 0;
-            xmlNode *cur = struct_node->children;
+            i = 0;
+            cur = struct_node->children;
 
             while (cur != NULL)
             {
                 if (0 == strcmp((char *)cur->name, "member"))
                 {
+                    xmlChar *name;
                     if (cur->children == NULL || cur->last == cur->children)
                     {
                         server_error(s, "Malformed Map");
@@ -854,7 +857,7 @@ static void parse_into(xen_session *s, x
                         return;
                     }
 
-                    xmlChar *name = string_from_name(cur);
+                    name = string_from_name(cur);
                     if (name == NULL)
                     {
                         server_error(s, "Malformed Map");
@@ -919,6 +922,7 @@ static void parse_into(xen_session *s, x
             {
                 if (0 == strcmp((char *)cur->name, "member"))
                 {
+                    xmlChar *name;
                     if (cur->children == NULL || cur->last == cur->children)
                     {
                         server_error(s, "Malformed Struct");
@@ -927,7 +931,7 @@ static void parse_into(xen_session *s, x
                         return;
                     }
 
-                    xmlChar *name = string_from_name(cur);
+                    name = string_from_name(cur);
                     if (name == NULL)
                     {
                         server_error(s, "Malformed Struct");
@@ -1075,6 +1079,10 @@ static void parse_structmap_value(xen_se
 
 static void parse_fault(xen_session *session, xmlXPathContextPtr xpathCtx)
 {
+    xmlNode *fault_node0, *fault_node1;
+    xmlChar *fault_code_str, *fault_string_str;
+    char **strings;
+
     xmlXPathObjectPtr xpathObj = xmlXPathCompiledEval(faultPath, xpathCtx);
     if (xpathObj == NULL)
     {
@@ -1090,10 +1098,10 @@ static void parse_fault(xen_session *ses
         return;
     }
 
-    xmlNode *fault_node0 = xpathObj->nodesetval->nodeTab[0];
-    xmlNode *fault_node1 = xpathObj->nodesetval->nodeTab[1];
-
-    xmlChar *fault_code_str = string_from_value(fault_node0, "int");
+    fault_node0 = xpathObj->nodesetval->nodeTab[0];
+    fault_node1 = xpathObj->nodesetval->nodeTab[1];
+
+    fault_code_str = string_from_value(fault_node0, "int");
     if (fault_code_str == NULL)
     {
         fault_code_str = string_from_value(fault_node0, "i4");
@@ -1105,7 +1113,7 @@ static void parse_fault(xen_session *ses
         return;
     }
 
-    xmlChar *fault_string_str = string_from_value(fault_node1, "string");
+    fault_string_str = string_from_value(fault_node1, "string");
     if (fault_string_str == NULL)
     {
         xmlFree(fault_code_str);
@@ -1114,7 +1122,7 @@ static void parse_fault(xen_session *ses
         return;
     }
 
-    char **strings = malloc(3 * sizeof(char *));
+    strings = malloc(3 * sizeof(char *));
 
     strings[0] = xen_strdup_("FAULT");
     strings[1] = xen_strdup_((char *)fault_code_str);
@@ -1142,12 +1150,15 @@ static void parse_failure(xen_session *s
 
     if (session->ok)
     {
+        char **c, **strings;
+        int n;
+
         session->ok = false;
 
-        char **c = (char **)error_descriptions->contents;
-        int n = error_descriptions->size;
-
-        char **strings = malloc(n * sizeof(char *));
+        c = (char **)error_descriptions->contents;
+        n = error_descriptions->size;
+
+        strings = malloc(n * sizeof(char *));
         for (int i = 0; i < n; i++)
         {
             strings[i] = c[i];
@@ -1169,6 +1180,10 @@ static void parse_result(xen_session *se
 {
     xmlDocPtr doc =
         xmlReadMemory(result, strlen(result), "", NULL, XML_PARSE_NONET);
+    xmlXPathContextPtr xpathCtx;
+    xmlXPathObjectPtr xpathObj;
+    xmlNode *node0, *node1;
+    xmlChar *status_code;
 
     if (doc == NULL)
     {
@@ -1176,7 +1191,7 @@ static void parse_result(xen_session *se
         return;
     }
 
-    xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
+    xpathCtx = xmlXPathNewContext(doc);
     if (xpathCtx == NULL)
     {
         xmlFreeDoc(doc);
@@ -1184,8 +1199,7 @@ static void parse_result(xen_session *se
         return;
     }
 
-    xmlXPathObjectPtr xpathObj =
-        xmlXPathCompiledEval(responsePath, xpathCtx);
+    xpathObj = xmlXPathCompiledEval(responsePath, xpathCtx);
     if (xpathObj == NULL)
     {
         parse_fault(session, xpathCtx);
@@ -1206,10 +1220,10 @@ static void parse_result(xen_session *se
         return;
     }
 
-    xmlNode *node0 = xpathObj->nodesetval->nodeTab[0];
-    xmlNode *node1 = xpathObj->nodesetval->nodeTab[1];
-
-    xmlChar *status_code = string_from_value(node0, "string");
+    node0 = xpathObj->nodesetval->nodeTab[0];
+    node1 = xpathObj->nodesetval->nodeTab[1];
+
+    status_code = string_from_value(node0, "string");
     if (status_code == NULL)
     {
         xmlXPathFreeObject(xpathObj);
@@ -1364,14 +1378,17 @@ make_body(const char *method_name, abstr
 make_body(const char *method_name, abstract_value params[], int param_count)
 {
     xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
-    xmlNode *methodCall = xmlNewNode(NULL, BAD_CAST "methodCall");
+    xmlNode *params_node, *methodCall = xmlNewNode(NULL, BAD_CAST "methodCall");
+    xmlBufferPtr buffer;
+    xmlSaveCtxtPtr save_ctxt;
+    xmlChar *content;
+
     xmlDocSetRootElement(doc, methodCall);
 
     xmlNewChild(methodCall, NULL, BAD_CAST "methodName",
                 BAD_CAST method_name);
 
-    xmlNode *params_node =
-        xmlNewChild(methodCall, NULL, BAD_CAST "params", NULL);
+    params_node = xmlNewChild(methodCall, NULL, BAD_CAST "params", NULL);
 
     for (int p = 0; p < param_count; p++)
     {
@@ -1379,9 +1396,8 @@ make_body(const char *method_name, abstr
         make_body_add_type(v->type->typename, v, params_node);
     }
 
-    xmlBufferPtr buffer = xmlBufferCreate();
-    xmlSaveCtxtPtr save_ctxt =
-        xmlSaveToBuffer(buffer, NULL, XML_SAVE_NO_XHTML);
+    buffer = xmlBufferCreate();
+    save_ctxt = xmlSaveToBuffer(buffer, NULL, XML_SAVE_NO_XHTML);
 
     if (xmlSaveDoc(save_ctxt, doc) == -1)
     {
@@ -1390,7 +1406,7 @@ make_body(const char *method_name, abstr
 
     xmlFreeDoc(doc);
     xmlSaveClose(save_ctxt);
-    xmlChar *content = xmlStrdup(xmlBufferContent(buffer));
+    content = xmlStrdup(xmlBufferContent(buffer));
     xmlBufferFree(buffer);
     return (char *)content;
 }
@@ -1611,11 +1627,12 @@ add_struct_array(xmlNode *struct_node, c
 add_struct_array(xmlNode *struct_node, const char *name)
 {
     xmlNode *member_node = add_container(struct_node, "member");
+    xmlNode *value_node, *array_node;
 
     xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name);
 
-    xmlNode *value_node = add_container(member_node, "value");
-    xmlNode *array_node = add_container(value_node,  "array");
+    value_node = add_container(member_node, "value");
+    array_node = add_container(value_node,  "array");
 
     return add_container(array_node,  "data");
 }
@@ -1625,10 +1642,11 @@ add_nested_struct(xmlNode *struct_node, 
 add_nested_struct(xmlNode *struct_node, const char *name)
 {
     xmlNode *member_node = add_container(struct_node, "member");
+    xmlNode *value_node;
 
     xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name);
 
-    xmlNode *value_node = add_container(member_node, "value");
+    value_node = add_container(member_node, "value");
 
     return add_container(value_node, "struct");
 }
diff -r d13c4d2836a8 tools/libxen/src/xen_int_string_set_map.c
--- a/tools/libxen/src/xen_int_string_set_map.c	Tue Jan 15 14:39:23 2008 +0000
+++ b/tools/libxen/src/xen_int_string_set_map.c	Wed Jan 16 13:38:04 2008 +0100
@@ -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++)
     {
         
diff -r d13c4d2836a8 tools/libxen/src/xen_string_set.c
--- a/tools/libxen/src/xen_string_set.c	Tue Jan 15 14:39:23 2008 +0000
+++ b/tools/libxen/src/xen_string_set.c	Wed Jan 16 13:38:04 2008 +0100
@@ -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]);
diff -r d13c4d2836a8 tools/libxen/src/xen_string_string_map.c
--- a/tools/libxen/src/xen_string_string_map.c	Tue Jan 15 14:39:23 2008 +0000
+++ b/tools/libxen/src/xen_string_string_map.c	Wed Jan 16 13:38:04 2008 +0100
@@ -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);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

      reply	other threads:[~2008-01-16 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15 17:04 [PATCH] libxen compilation fixes Ian Jackson
2008-01-15 18:38 ` Keir Fraser
2008-01-16 10:15   ` Ian Jackson
2008-01-16 12:41     ` Andre Przywara [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=478DFB8A.7070103@amd.com \
    --to=andre.przywara@amd.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.