# [PATCH] libxmlrpc warning fixes

- Thread: https://externals.io/message/5037
- Original archive: https://news-web.php.net/php.internals/5037
- Started by Joe Orton on 2003-10-27T12:31:47+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #5037 — Joe Orton — 2003-10-27T12:31:47+00:00

URL: https://externals.io/message/5037#5037

Hi, this patch fixes compiler warnings in the version of libxmlrpc
included in the PHP 4.3 branch.  (unspecified return value, format
string bugs, missing includes, unused function/variables)

Index: ext/xmlrpc/libxmlrpc/simplestring.c
===================================================================
RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/simplestring.c,v
retrieving revision 1.3
diff -u -r1.3 simplestring.c
--- ext/xmlrpc/libxmlrpc/simplestring.c	22 Aug 2002 01:25:50 -0000	1.3
+++ ext/xmlrpc/libxmlrpc/simplestring.c	27 Oct 2003 12:27:21 -0000
@@ -79,6 +79,7 @@
  ******/
 
 #include <stdlib.h>
+#include <string.h>
 #include "simplestring.h"
 
 #define my_free(thing)  if(thing) {free(thing); thing = 0;}
Index: ext/xmlrpc/libxmlrpc/xml_element.c
===================================================================
RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xml_element.c,v
retrieving revision 1.3.4.1
diff -u -r1.3.4.1 xml_element.c
--- ext/xmlrpc/libxmlrpc/xml_element.c	27 Nov 2002 04:07:00 -0000	1.3.4.1
+++ ext/xmlrpc/libxmlrpc/xml_element.c	27 Oct 2003 12:27:21 -0000
@@ -471,18 +471,20 @@
 }
 
 /* print buf to file */
-static file_out_fptr(void *f, const char *text, int size)
+static int file_out_fptr(void *f, const char *text, int size)
 {
    fputs(text, (FILE *)f);
+   return 0;
 }
 
 /* print buf to simplestring */
-static simplestring_out_fptr(void *f, const char *text, int size)
+static int simplestring_out_fptr(void *f, const char *text, int size)
 {
    simplestring* buf = (simplestring*)f;
    if(buf) {
       simplestring_addn(buf, text, size);
    }
+   return 0;
 }
 
 /****f* xml_element/xml_elem_serialize_to_string
@@ -696,7 +698,7 @@
          if(byte_idx >= 0) {
              snprintf(buf, 
                       sizeof(buf),
-                      "\n\tdata beginning %i before byte index: %s\n",
+                      "\n\tdata beginning %ld before byte index: %s\n",
                       byte_idx > 10  ? 10 : byte_idx,
                       in_buf + (byte_idx > 10 ? byte_idx - 10 : byte_idx));
          }
@@ -705,7 +707,7 @@
                 "\tdescription: %s\n"
                 "\tline: %i\n"
                 "\tcolumn: %i\n"
-                "\tbyte index: %i\n"
+                "\tbyte index: %ld\n"
                 "\ttotal bytes: %i\n%s ",
                 err_code, error_str, line_num, 
                 col_num, byte_idx, byte_total, buf);
Index: ext/xmlrpc/libxmlrpc/xmlrpc.c
===================================================================
RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c,v
retrieving revision 1.4
diff -u -r1.4 xmlrpc.c
--- ext/xmlrpc/libxmlrpc/xmlrpc.c	5 Jul 2002 04:43:53 -0000	1.4
+++ ext/xmlrpc/libxmlrpc/xmlrpc.c	27 Oct 2003 12:27:22 -0000
@@ -122,6 +122,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <time.h>
+#include <ctype.h>
 
 #include "queue.h"
 #include "xmlrpc.h"
@@ -704,7 +705,7 @@
       XMLRPC_ERROR_CODE code;
       char buf[1024];
       snprintf(buf, sizeof(buf), 
-               "error occurred at line %i, column %i, byte index %i", 
+               "error occurred at line %ld, column %ld, byte index %ld", 
 					 error->line, error->column, error->byte_index);
 
       /* expat specific errors */
@@ -815,13 +816,6 @@
    return v;
 }
 
-static const char* get_string(const char* buf, int bDup) {
-   if(bDup) {
-      return strdup(buf);
-   }
-   return buf;
-}
-
 /*******/
 
 /****f* VALUE/XMLRPC_SetValueID_Case
@@ -1047,8 +1041,6 @@
 
    val = XMLRPC_CreateValueEmpty();
    if(val) {
-      XMLRPC_VECTOR *pSIV = NULL;
-
       if(XMLRPC_SetIsVector(val, type)) {
          if(id) {
             const char *pSVI = NULL;
@@ -1609,6 +1601,8 @@
 				}
 			}
 			break;
+		default:
+			break;
 		}
 	}
 	return xReturn;
@@ -2447,6 +2441,7 @@
                 return "struct";
           }
     }
+    return "unknown";
 }
 
 /****f* VALUE/XMLRPC_ServerFindMethod
Index: ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c
===================================================================
RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c,v
retrieving revision 1.3
diff -u -r1.3 xmlrpc_introspection.c
--- ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c	5 Jul 2002 04:43:53 -0000	1.3
+++ ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c	27 Oct 2003 12:27:22 -0000
@@ -346,7 +346,7 @@
          const char* ptype = !strcmp(el->name, "value") ? type : basetype;
          if(ptype) {
             if(Q_Size(&el->children) &&
-               !strcmp(ptype, "array") || !strcmp(ptype, "struct") || !strcmp(ptype, "mixed")) {
+               (!strcmp(ptype, "array") || !strcmp(ptype, "struct") || !strcmp(ptype, "mixed"))) {
                xSubList = XMLRPC_CreateVector("member", xmlrpc_vector_array);
 
                if(xSubList) {

---

## #6487 — Jani Taskinen — 2003-12-16T21:02:36+00:00

URL: https://externals.io/message/5037#6487 · In reply to: #5037

Committed with some missing ctype.h includes.
    
    --Jani
    



>Hi, this patch fixes compiler warnings in the version of libxmlrpc
>included in the PHP 4.3 branch.  (unspecified return value, format
>string bugs, missing includes, unused function/variables)
>
>Index: ext/xmlrpc/libxmlrpc/simplestring.c
>===================================================================
>RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/simplestring.c,v
>retrieving revision 1.3
>diff -u -r1.3 simplestring.c
>--- ext/xmlrpc/libxmlrpc/simplestring.c	22 Aug 2002 01:25:50 -0000	1.3
>+++ ext/xmlrpc/libxmlrpc/simplestring.c	27 Oct 2003 12:27:21 -0000
>@@ -79,6 +79,7 @@
>  ******/
> 
> #include <stdlib.h>
>+#include <string.h>
> #include "simplestring.h"
> 
> #define my_free(thing)  if(thing) {free(thing); thing = 0;}
>Index: ext/xmlrpc/libxmlrpc/xml_element.c
>===================================================================
>RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xml_element.c,v
>retrieving revision 1.3.4.1
>diff -u -r1.3.4.1 xml_element.c
>--- ext/xmlrpc/libxmlrpc/xml_element.c	27 Nov 2002 04:07:00 -0000	1.3.4.1
>+++ ext/xmlrpc/libxmlrpc/xml_element.c	27 Oct 2003 12:27:21 -0000
>@@ -471,18 +471,20 @@
> }
> 
> /* print buf to file */
>-static file_out_fptr(void *f, const char *text, int size)
>+static int file_out_fptr(void *f, const char *text, int size)
> {
>    fputs(text, (FILE *)f);
>+   return 0;
> }
> 
> /* print buf to simplestring */
>-static simplestring_out_fptr(void *f, const char *text, int size)
>+static int simplestring_out_fptr(void *f, const char *text, int size)
> {
>    simplestring* buf = (simplestring*)f;
>    if(buf) {
>       simplestring_addn(buf, text, size);
>    }
>+   return 0;
> }
> 
> /****f* xml_element/xml_elem_serialize_to_string
>@@ -696,7 +698,7 @@
>          if(byte_idx >= 0) {
>              snprintf(buf, 
>                       sizeof(buf),
>-                      "\n\tdata beginning %i before byte index: %s\n",
>+                      "\n\tdata beginning %ld before byte index: %s\n",
>                       byte_idx > 10  ? 10 : byte_idx,
>                       in_buf + (byte_idx > 10 ? byte_idx - 10 : byte_idx));
>          }
>@@ -705,7 +707,7 @@
>                 "\tdescription: %s\n"
>                 "\tline: %i\n"
>                 "\tcolumn: %i\n"
>-                "\tbyte index: %i\n"
>+                "\tbyte index: %ld\n"
>                 "\ttotal bytes: %i\n%s ",
>                 err_code, error_str, line_num, 
>                 col_num, byte_idx, byte_total, buf);
>Index: ext/xmlrpc/libxmlrpc/xmlrpc.c
>===================================================================
>RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c,v
>retrieving revision 1.4
>diff -u -r1.4 xmlrpc.c
>--- ext/xmlrpc/libxmlrpc/xmlrpc.c	5 Jul 2002 04:43:53 -0000	1.4
>+++ ext/xmlrpc/libxmlrpc/xmlrpc.c	27 Oct 2003 12:27:22 -0000
>@@ -122,6 +122,7 @@
> #include <string.h>
> #include <stdarg.h>
> #include <time.h>
>+#include <ctype.h>
> 
> #include "queue.h"
> #include "xmlrpc.h"
>@@ -704,7 +705,7 @@
>       XMLRPC_ERROR_CODE code;
>       char buf[1024];
>       snprintf(buf, sizeof(buf), 
>-               "error occurred at line %i, column %i, byte index %i", 
>+               "error occurred at line %ld, column %ld, byte index %ld", 
> 					 error->line, error->column, error->byte_index);
> 
>       /* expat specific errors */
>@@ -815,13 +816,6 @@
>    return v;
> }
> 
>-static const char* get_string(const char* buf, int bDup) {
>-   if(bDup) {
>-      return strdup(buf);
>-   }
>-   return buf;
>-}
>-
> /*******/
> 
> /****f* VALUE/XMLRPC_SetValueID_Case
>@@ -1047,8 +1041,6 @@
> 
>    val = XMLRPC_CreateValueEmpty();
>    if(val) {
>-      XMLRPC_VECTOR *pSIV = NULL;
>-
>       if(XMLRPC_SetIsVector(val, type)) {
>          if(id) {
>             const char *pSVI = NULL;
>@@ -1609,6 +1601,8 @@
> 				}
> 			}
> 			break;
>+		default:
>+			break;
> 		}
> 	}
> 	return xReturn;
>@@ -2447,6 +2441,7 @@
>                 return "struct";
>           }
>     }
>+    return "unknown";
> }
> 
> /****f* VALUE/XMLRPC_ServerFindMethod
>Index: ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c
>===================================================================
>RCS file: /repository/php-src/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c,v
>retrieving revision 1.3
>diff -u -r1.3 xmlrpc_introspection.c
>--- ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c	5 Jul 2002 04:43:53 -0000	1.3
>+++ ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c	27 Oct 2003 12:27:22 -0000
>@@ -346,7 +346,7 @@
>          const char* ptype = !strcmp(el->name, "value") ? type : basetype;
>          if(ptype) {
>             if(Q_Size(&el->children) &&
>-               !strcmp(ptype, "array") || !strcmp(ptype, "struct") || !strcmp(ptype, "mixed")) {
>+               (!strcmp(ptype, "array") || !strcmp(ptype, "struct") || !strcmp(ptype, "mixed"))) {
>                xSubList = XMLRPC_CreateVector("member", xmlrpc_vector_array);
> 
>                if(xSubList) {
