SOURCES: xmlrpc-c-fixed-broken-format-string-modifiers-for-size_t-type.patc...

areq areq at pld-linux.org
Sun May 11 18:31:51 CEST 2008


Author: areq                         Date: Sun May 11 16:31:51 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- 1.14.2 (from fedora)

---- Files affected:
SOURCES:
   xmlrpc-c-fixed-broken-format-string-modifiers-for-size_t-type.patch (NONE -> 1.1)  (NEW), xmlrpc-c-use-proper-datatypes.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/xmlrpc-c-fixed-broken-format-string-modifiers-for-size_t-type.patch
diff -u /dev/null SOURCES/xmlrpc-c-fixed-broken-format-string-modifiers-for-size_t-type.patch:1.1
--- /dev/null	Sun May 11 18:31:51 2008
+++ SOURCES/xmlrpc-c-fixed-broken-format-string-modifiers-for-size_t-type.patch	Sun May 11 18:31:46 2008
@@ -0,0 +1,228 @@
+From b4884128c52b27015020148b698ef2e9907ff2fa Mon Sep 17 00:00:00 2001
+From: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
+Date: Mon, 25 Feb 2008 17:48:25 +0100
+Subject: [PATCH] fixed broken format string modifiers for size_t typed arguments
+
+---
+ lib/abyss/src/socket_unix.c |    4 ++--
+ lib/libutil/memblock.c      |    2 +-
+ src/xmlrpc_data.c           |    2 +-
+ src/xmlrpc_datetime.c       |    2 +-
+ src/xmlrpc_decompose.c      |    4 ++--
+ src/xmlrpc_parse.c          |   16 ++++++++--------
+ src/xmlrpc_server_abyss.c   |    2 +-
+ src/xmlrpc_string.c         |    8 ++++----
+ tools/xmlrpc/xmlrpc.c       |    2 +-
+ 9 files changed, 21 insertions(+), 21 deletions(-)
+
+diff --git a/lib/abyss/src/socket_unix.c b/lib/abyss/src/socket_unix.c
+index fd39276..afe2be7 100644
+--- a/lib/abyss/src/socket_unix.c
++++ b/lib/abyss/src/socket_unix.c
+@@ -193,8 +193,8 @@ channelWrite(TChannel *            const channelP,
+                 fprintf(stderr, "Abyss channel: send() failed.  "
+                         "Socket closed.\n");
+             else
+-                fprintf(stderr, "Abyss channel: sent %u bytes: '%.*s'\n",
+-                        rc, rc, &buffer[len-bytesLeft]);
++                fprintf(stderr, "Abyss channel: sent %zu bytes: '%.*s'\n",
++                        rc, (int)rc, &buffer[len-bytesLeft]);
+         }
+         if (rc <= 0)
+             /* 0 means connection closed; < 0 means severe error */
+diff --git a/lib/libutil/memblock.c b/lib/libutil/memblock.c
+index d79d4ca..25992e8 100644
+--- a/lib/libutil/memblock.c
++++ b/lib/libutil/memblock.c
+@@ -73,7 +73,7 @@ xmlrpc_mem_block_init(xmlrpc_env *       const envP,
+ 
+     blockP->_block = (void*) malloc(blockP->_allocated);
+     if (!blockP->_block)
+-        xmlrpc_faultf(envP, "Can't allocate %u-byte memory block",
++        xmlrpc_faultf(envP, "Can't allocate %zu-byte memory block",
+                       blockP->_allocated);
+ }
+ 
+diff --git a/src/xmlrpc_data.c b/src/xmlrpc_data.c
+index 28827fe..415dd6d 100644
+--- a/src/xmlrpc_data.c
++++ b/src/xmlrpc_data.c
+@@ -221,7 +221,7 @@ xmlrpc_read_base64(xmlrpc_env *           const envP,
+         byteStringValue = malloc(size);
+         if (byteStringValue == NULL)
+             xmlrpc_env_set_fault_formatted(
+-                envP, XMLRPC_INTERNAL_ERROR, "Unable to allocate %u bytes "
++                envP, XMLRPC_INTERNAL_ERROR, "Unable to allocate %zu bytes "
+                 "for byte string.", size);
+         else {
+             memcpy(byteStringValue, contents, size);
+diff --git a/src/xmlrpc_datetime.c b/src/xmlrpc_datetime.c
+index c4cc938..17fa328 100644
+--- a/src/xmlrpc_datetime.c
++++ b/src/xmlrpc_datetime.c
+@@ -208,7 +208,7 @@ validateFormat(xmlrpc_env * const envP,
+                const char * const t) {
+ 
+     if (strlen(t) != 17)
+-        xmlrpc_faultf(envP, "%u characters instead of 15.", strlen(t));
++        xmlrpc_faultf(envP, "%zu characters instead of 15.", strlen(t));
+     else if (t[8] != 'T')
+         xmlrpc_faultf(envP, "9th character is '%c', not 'T'", t[8]);
+     else {
+diff --git a/src/xmlrpc_decompose.c b/src/xmlrpc_decompose.c
+index eeb3414..36e62f6 100644
+--- a/src/xmlrpc_decompose.c
++++ b/src/xmlrpc_decompose.c
+@@ -712,7 +712,7 @@ buildArrayDecompBranch(xmlrpc_env *            const envP,
+         if (itemCnt >= ARRAY_SIZE(decompNodeP->store.Tarray.itemArray))
+             xmlrpc_faultf(envP, "Too many array items in format string.  "
+                           "The most items you can have for an array in "
+-                          "a format string is %u.",
++                          "a format string is %zu.",
+                           ARRAY_SIZE(decompNodeP->store.Tarray.itemArray));
+         else {
+             struct decompTreeNode * itemNodeP;
+@@ -850,7 +850,7 @@ buildStructDecompBranch(xmlrpc_env *            const envP,
+             xmlrpc_faultf(envP,
+                           "Too many structure members in format string.  "
+                           "The most members you can specify in "
+-                          "a format string is %u.",
++                          "a format string is %zu.",
+                           ARRAY_SIZE(decompNodeP->store.Tstruct.mbrArray));
+         else {
+             struct mbrDecomp * const mbrP =
+diff --git a/src/xmlrpc_parse.c b/src/xmlrpc_parse.c
+index 77b649d..dfcc29b 100644
+--- a/src/xmlrpc_parse.c
++++ b/src/xmlrpc_parse.c
+@@ -43,7 +43,7 @@
+     do \
+         if (xml_element_children_size(elem) != (count)) \
+             XMLRPC_FAIL3(env, XMLRPC_PARSE_ERROR, \
+-             "Expected <%s> to have %d children, found %d", \
++             "Expected <%s> to have %d children, found %zd", \
+                          xml_element_name(elem), (count), \
+                          xml_element_children_size(elem)); \
+     while (0)
+@@ -675,7 +675,7 @@ parseMethodNameElement(xmlrpc_env *  const envP,
+         xmlrpc_env_set_fault_formatted(
+             envP, XMLRPC_PARSE_ERROR,
+             "A <methodName> element should not have children.  "
+-            "This one has %u of them.", xml_element_children_size(nameElemP));
++            "This one has %zu of them.", xml_element_children_size(nameElemP));
+     else {
+         const char * const cdata = xml_element_cdata(nameElemP);
+ 
+@@ -734,7 +734,7 @@ parseCallChildren(xmlrpc_env *    const envP,
+                     xmlrpc_env_set_fault_formatted(
+                         envP, XMLRPC_PARSE_ERROR,
+                         "<methodCall> has extraneous children, other than "
+-                        "<methodName> and <params>.  Total child count = %u",
++                        "<methodName> and <params>.  Total child count = %zu",
+                         callChildCount);
+                     
+                 if (envP->fault_occurred)
+@@ -772,7 +772,7 @@ xmlrpc_parse_call(xmlrpc_env *    const envP,
+     if (xmlLen > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))
+         xmlrpc_env_set_fault_formatted(
+             envP, XMLRPC_LIMIT_EXCEEDED_ERROR,
+-            "XML-RPC request too large.  Max allowed is %u bytes",
++            "XML-RPC request too large.  Max allowed is %zu bytes",
+             xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID));
+     else {
+         xml_element * callElemP;
+@@ -849,7 +849,7 @@ parseFaultElement(xmlrpc_env *        const envP,
+     if (xml_element_children_size(faultElement) != 1)
+         xmlrpc_env_set_fault_formatted(
+             envP, XMLRPC_PARSE_ERROR,
+-            "<fault> element should have 1 child, but it has %u.",
++            "<fault> element should have 1 child, but it has %zu.",
+             xml_element_children_size(faultElement));
+     else {
+         xml_element * const faultValueP =
+@@ -945,7 +945,7 @@ parseMethodResponseElt(xmlrpc_env *        const envP,
+     } else
+         xmlrpc_env_set_fault_formatted(
+             envP, XMLRPC_PARSE_ERROR,
+-            "<methodResponse> has %u children, should have 1.",
++            "<methodResponse> has %zu children, should have 1.",
+             xml_element_children_size(methodResponseEltP));
+ }
+ 
+@@ -984,8 +984,8 @@ xmlrpc_parse_response2(xmlrpc_env *    const envP,
+     if (xmlDataLen > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))
+         xmlrpc_env_set_fault_formatted(
+             envP, XMLRPC_LIMIT_EXCEEDED_ERROR,
+-            "XML-RPC response too large.  Our limit is %u characters.  "
+-            "We got %u characters",
++            "XML-RPC response too large.  Our limit is %zu characters.  "
++            "We got %zu characters",
+             xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID), xmlDataLen);
+     else {
+         xmlrpc_env env;
+diff --git a/src/xmlrpc_server_abyss.c b/src/xmlrpc_server_abyss.c
+index 15c37d6..1a6ea47 100644
+--- a/src/xmlrpc_server_abyss.c
++++ b/src/xmlrpc_server_abyss.c
+@@ -459,7 +459,7 @@ processCall(TSession *        const abyssSessionP,
+     if (contentSize > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))
+         xmlrpc_env_set_fault_formatted(
+             &env, XMLRPC_LIMIT_EXCEEDED_ERROR,
+-            "XML-RPC request too large (%d bytes)", contentSize);
++            "XML-RPC request too large (%zd bytes)", contentSize);
+     else {
+         xmlrpc_mem_block * body;
+         /* Read XML data off the wire. */
+diff --git a/src/xmlrpc_string.c b/src/xmlrpc_string.c
+index 8bf299d..a2a4bf4 100644
+--- a/src/xmlrpc_string.c
++++ b/src/xmlrpc_string.c
+@@ -141,7 +141,7 @@ xmlrpc_read_string(xmlrpc_env *         const envP,
+         MALLOCARRAY(stringValue, length + 1);
+         if (stringValue == NULL)
+             xmlrpc_faultf(envP, "Unable to allocate space "
+-                          "for %u-character string", length);
++                          "for %zu-character string", length);
+         else {
+             memcpy(stringValue, contents, length);
+             stringValue[length] = '\0';
+@@ -189,7 +189,7 @@ copyAndConvertLfToCrlf(xmlrpc_env *  const envP,
+     MALLOCARRAY(dst, dstLen + 1);
+     if (dst == NULL)
+         xmlrpc_faultf(envP, "Unable to allocate space "
+-                      "for %u-character string", dstLen + 1);
++                      "for %zu-character string", dstLen + 1);
+     else {
+         const char * p;  /* source pointer */
+         char * q;        /* destination pointer */
+@@ -370,7 +370,7 @@ xmlrpc_read_string_w(xmlrpc_env *     const envP,
+         wchar_t * stringValue;
+         MALLOCARRAY(stringValue, length + 1);
+         if (stringValue == NULL)
+-            xmlrpc_faultf(envP, "Unable to allocate space for %u-byte string", 
++            xmlrpc_faultf(envP, "Unable to allocate space for %zu-byte string", 
+                           length);
+         else {
+             memcpy(stringValue, wcontents, length * sizeof(wchar_t));
+@@ -422,7 +422,7 @@ wCopyAndConvertLfToCrlf(xmlrpc_env *     const envP,
+     MALLOCARRAY(dst, dstLen + 1);
+     if (dst == NULL)
+         xmlrpc_faultf(envP, "Unable to allocate space "
+-                      "for %u-character string", dstLen + 1);
++                      "for %zu-character string", dstLen + 1);
+     else {
+         const wchar_t * p;  /* source pointer */
+         wchar_t * q;        /* destination pointer */
+diff --git a/tools/xmlrpc/xmlrpc.c b/tools/xmlrpc/xmlrpc.c
+index 1bdc44c..c4e0618 100644
+--- a/tools/xmlrpc/xmlrpc.c
++++ b/tools/xmlrpc/xmlrpc.c
+@@ -268,7 +268,7 @@ buildBytestring(xmlrpc_env *    const envP,
+ 
+     if (valueStringSize / 2 * 2 != valueStringSize)
+         xmlrpc_faultf(envP, "Hexadecimal text is not an even "
+-                      "number of characters (it is %u characters)",
++                      "number of characters (it is %zu characters)",
+                       strlen(valueString));
+     else {
+         size_t const byteStringSize = strlen(valueString)/2;

================================================================
Index: SOURCES/xmlrpc-c-use-proper-datatypes.patch
diff -u /dev/null SOURCES/xmlrpc-c-use-proper-datatypes.patch:1.1
--- /dev/null	Sun May 11 18:31:51 2008
+++ SOURCES/xmlrpc-c-use-proper-datatypes.patch	Sun May 11 18:31:46 2008
@@ -0,0 +1,196 @@
+From 1823bda8047c3d7113e86f7550cbf3df8d105e67 Mon Sep 17 00:00:00 2001
+From: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
+Date: Sat, 5 Apr 2008 11:41:34 +0200
+Subject: [PATCH] Use proper datatypes for 'long long'
+
+xmlrpc-c uses 'long long' at some places (e.g. in printf
+statements with PRId64) under the assumption that it has a
+width of exactly 64 bits.
+
+On 64 bit machines 'long long' has a width of 128 bit and
+will cause overhead both in memory and cpu usage there. As
+'long long' is used only to handle <i8> datatypes, the patch
+uses a plain 64 integer type there.
+
+It is arguable whether 'int_least64_t' (and 'int_least32_t')
+would be a better choice for 'int64_t' (and 'int32_t'), but
+for now, the patch uses datatypes with exact widths.
+---
+ include/xmlrpc-c/base.h     |    5 +++--
+ include/xmlrpc-c/base.hpp   |   10 +++++-----
+ src/cpp/param_list.cpp      |    8 ++++----
+ src/cpp/test/test.cpp       |   12 ++++++------
+ src/cpp/test/testclient.cpp |    2 +-
+ src/cpp/value.cpp           |    8 ++++----
+ 6 files changed, 23 insertions(+), 22 deletions(-)
+
+diff --git a/include/xmlrpc-c/base.h b/include/xmlrpc-c/base.h
+index 712691c..9ce0cd2 100644
+--- a/include/xmlrpc-c/base.h
++++ b/include/xmlrpc-c/base.h
+@@ -6,6 +6,7 @@
+ #include <stddef.h>
+ #include <stdarg.h>
+ #include <time.h>
++#include <stdint.h>
+ #include <xmlrpc-c/util.h>
+ #include <xmlrpc-c/config.h>
+   /* Defines XMLRPC_HAVE_WCHAR, XMLRPC_LONG_LONG */
+@@ -36,9 +37,9 @@ extern unsigned int const xmlrpc_version_point;
+ 
+ typedef signed int xmlrpc_int;  
+     /* An integer of the type defined by XML-RPC <int>; i.e. 32 bit */
+-typedef signed int xmlrpc_int32;
++typedef int32_t xmlrpc_int32;
+     /* An integer of the type defined by XML-RPC <i4>; i.e. 32 bit */
+-typedef XMLRPC_LONG_LONG xmlrpc_int64;
++typedef int64_t xmlrpc_int64;
+     /* An integer of the type defined by "XML-RPC" <i8>; i.e. 64 bit */
+ typedef int xmlrpc_bool;
+     /* A boolean (of the type defined by XML-RPC <boolean>, but there's
+diff --git a/include/xmlrpc-c/base.hpp b/include/xmlrpc-c/base.hpp
+index 5634b34..ab6fe3e 100644
+--- a/include/xmlrpc-c/base.hpp
++++ b/include/xmlrpc-c/base.hpp
+@@ -200,11 +200,11 @@ public:
+ 
+ class value_i8 : public value {
+ public:
+-    value_i8(long long const cvalue);
++    value_i8(xmlrpc_int64 const cvalue);
+ 
+     value_i8(xmlrpc_c::value const baseValue);
+ 
+-    operator long long() const;
++    operator xmlrpc_int64() const;
+ };
+ 
+ 
+@@ -330,10 +330,10 @@ public:
+     void
+     getNil(unsigned int const paramNumber) const;
+ 
+-    long long
++    xmlrpc_int64
+     getI8(unsigned int const paramNumber,
+-          long long    const minimum = XMLRPC_INT64_MIN,
+-          long long    const maximum = XMLRPC_INT64_MAX) const;
++          xmlrpc_int64 const minimum = XMLRPC_INT64_MIN,
++          xmlrpc_int64 const maximum = XMLRPC_INT64_MAX) const;
+ 
+     void
+     verifyEnd(unsigned int const paramNumber) const;
+diff --git a/src/cpp/param_list.cpp b/src/cpp/param_list.cpp
+index 67c636b..60f7df9 100644
+--- a/src/cpp/param_list.cpp
++++ b/src/cpp/param_list.cpp
+@@ -265,10 +265,10 @@ paramList::getNil(unsigned int const paramNumber) const {
+ 
+ 
+ 
+-long long
++xmlrpc_int64
+ paramList::getI8(unsigned int const paramNumber,
+-                 long long    const minimum,
+-                 long long    const maximum) const {
++                 xmlrpc_int64 const minimum,
++                 xmlrpc_int64 const maximum) const {
+ 
+     if (paramNumber >= this->paramVector.size())
+         throw(fault("Not enough parameters", fault::CODE_TYPE));
+@@ -277,7 +277,7 @@ paramList::getI8(unsigned int const paramNumber,
+         throw(fault("Parameter that is supposed to be 64-bit integer is not", 
+                     fault::CODE_TYPE));
+ 
+-    long long const longlongvalue(static_cast<long long>(
++    xmlrpc_int64 const longlongvalue(static_cast<xmlrpc_int64>(
+         value_i8(this->paramVector[paramNumber])));
+ 
+     if (longlongvalue < minimum)
+diff --git a/src/cpp/test/test.cpp b/src/cpp/test/test.cpp
+index b3c2caf..c92653f 100644
+--- a/src/cpp/test/test.cpp
++++ b/src/cpp/test/test.cpp
+@@ -418,15 +418,15 @@ public:
+     }
+     virtual void runtests(unsigned int const) {
+         value_i8 int1(7);
+-        TEST(static_cast<long long>(int1) == 7);
++        TEST(static_cast<xmlrpc_int64>(int1) == 7);
+         value_i8 int2(-7);
+-        TEST(static_cast<long long>(int2) == -7);
++        TEST(static_cast<xmlrpc_int64>(int2) == -7);
+         value_i8 int5(1ull << 40);
+-        TEST(static_cast<long long>(int5) == (1ull << 40));
++        TEST(static_cast<xmlrpc_int64>(int5) == (1ull << 40));
+         value val1(int1);
+         TEST(val1.type() == value::TYPE_I8);
+         value_i8 int3(val1);
+-        TEST(static_cast<long long>(int3) == 7);
++        TEST(static_cast<xmlrpc_int64>(int3) == 7);
+         try {
+             value_i8 int4(value_double(3.7));
+             TEST_FAILED("invalid cast double-i8 suceeded");
+@@ -554,7 +554,7 @@ public:
+         structData.insert(member);
+         paramList1.add(value_struct(structData));
+         paramList1.add(value_nil());
+-        paramList1.add(value_i8((long long)UINT_MAX + 1));
++        paramList1.add(value_i8((xmlrpc_int64)UINT_MAX + 1));
+ 
+         TEST(paramList1.size() == 11);
+ 
+@@ -578,7 +578,7 @@ public:
+         TEST(paramList1.getArray(7, 1, 3).size() == 3);
+         paramList1.getStruct(8)["the_integer"];
+         paramList1.getNil(9);
+-        TEST(paramList1.getI8(10) == (long long)UINT_MAX + 1);
++        TEST(paramList1.getI8(10) == (xmlrpc_int64)UINT_MAX + 1);
+         paramList1.verifyEnd(11);
+ 
+         paramList paramList2(5);
+diff --git a/src/cpp/test/testclient.cpp b/src/cpp/test/testclient.cpp
+index cb7f86a..e3c23a8 100644
+--- a/src/cpp/test/testclient.cpp
++++ b/src/cpp/test/testclient.cpp
+@@ -783,7 +783,7 @@ public:
+             TEST(rpcApacheP->isFinished());
+             TEST(rpcApacheP->isSuccessful());
+             value_i8 const result(rpcApacheP->getResult());
+-            TEST(static_cast<long long>(result) == 7ll);
++            TEST(static_cast<xmlrpc_int64>(result) == 7ll);
+         }
+     }
+ };
+diff --git a/src/cpp/value.cpp b/src/cpp/value.cpp
+index 588b91f..6dcba93 100644
+--- a/src/cpp/value.cpp
++++ b/src/cpp/value.cpp
+@@ -831,13 +831,13 @@ value_nil::value_nil(xmlrpc_c::value const baseValue) {
+ 
+ 
+ 
+-value_i8::value_i8(long long const cppvalue) {
++value_i8::value_i8(xmlrpc_int64 const cppvalue) {
+ 
+     class cWrapper {
+     public:
+         xmlrpc_value * valueP;
+         
+-        cWrapper(long long const cppvalue) {
++        cWrapper(xmlrpc_int64 const cppvalue) {
+             env_wrap env;
+             
+             this->valueP = xmlrpc_i8_new(&env.env_c, cppvalue);
+@@ -866,9 +866,9 @@ value_i8::value_i8(xmlrpc_c::value const baseValue) {
+ 
+ 
+ 
+-value_i8::operator long long() const {
++value_i8::operator xmlrpc_int64() const {
+ 
+-    long long retval;
++    xmlrpc_int64 retval;
+     env_wrap env;
+ 
+     xmlrpc_read_i8(&env.env_c, this->cValueP, &retval);
================================================================


More information about the pld-cvs-commit mailing list