On 06.06.2016 10:11, Fabrice Manfroi wrote:
> Hello,
> 
> I'm not sure to understand what you mean by "remove initializers you
> don't need", because it's the same kind of modification in the relaxng.c
> and xmlschemas.c source code.
> 
> I don't see how to make better.
> 
> Could you elaborate?

Sure, attached.

> 
> Best Regards.
> 
> On 06/05/2016 05:07 PM, Nikolay Sivov wrote:
>> This makes sense, I think this is worth fixing. I suggest to tweak a
>> patch a bit - remove initializers you don't need, and keep variable
>> scope as it is here:
> 

From 839de7582ad2fbfc46c63f9badbd8f81244bde33 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsi...@codeweavers.com>
Date: Mon, 6 Jun 2016 15:07:33 +0300
Subject: [PATCH] Fix a couple of compiler warnings with declarations after the
 code

---
 relaxng.c    | 3 ++-
 xmlschemas.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/relaxng.c b/relaxng.c
index 56a3344..93a0f0b 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -2087,6 +2087,7 @@ static xmlChar *
 xmlRelaxNGGetErrorString(xmlRelaxNGValidErr err, const xmlChar * arg1,
                          const xmlChar * arg2)
 {
+    xmlChar *result;
     char msg[1000];
 
     if (arg1 == NULL)
@@ -2215,7 +2216,7 @@ xmlRelaxNGGetErrorString(xmlRelaxNGValidErr err, const 
xmlChar * arg1,
         snprintf(msg, 1000, "Unknown error code %d\n", err);
     }
     msg[1000 - 1] = 0;
-    xmlChar *result = xmlCharStrdup(msg);
+    result = xmlCharStrdup(msg);
     return (xmlEscapeFormatString(&result));
 }
 
diff --git a/xmlschemas.c b/xmlschemas.c
index e1b3a4f..7afe2eb 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -3168,8 +3168,8 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
                "valid.");
        }
        if (expected) {
-           msg = xmlStrcat(msg, BAD_CAST " Expected is '");
            xmlChar *expectedEscaped = xmlCharStrdup(expected);
+           msg = xmlStrcat(msg, BAD_CAST " Expected is '");
            msg = xmlStrcat(msg, xmlEscapeFormatString(&expectedEscaped));
            FREE_AND_NULL(expectedEscaped);
            msg = xmlStrcat(msg, BAD_CAST "'.\n");
-- 
2.8.1

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@gnome.org
https://mail.gnome.org/mailman/listinfo/xml

Reply via email to