View Issue Details

IDProjectCategoryView StatusLast Update
0002550SOGoSOPEpublic2014-02-04 13:55
Reporterbuzzdee Assigned Toludovic  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSOpenBSDOS Version5.4-current
Product Version2.1.1b 
Target Version2.2.0Fixed in Version2.2.0 
Summary0002550: more format string fixes for sax-xml
Description

the patch attached fixes more format string fixes, mostly (u)int -> NS(U)Integer fixing the format string. I used the PRI(u/i)PTR types from inttypes.h.
Other possibility would be to use %l and cast everything to long.

Fixing the following warnings:
DOMElement.m:514:22: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[self _numberOfAttributes],
^~~~~~
DOMElement.m:515:22: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[self hasChildNodes] ? [[self childNodes] length] : 0];
^~~~~~~~~~~~~
2 warnings generated.

DOMNode.m:217:22: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[self hasChildNodes] ? [[self childNodes] length] : 0];
^~~~~~~~~~~~~
1 warning generated.

XmlRpcEncoder.m:368:18: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date yearOfCommonEra], [date monthOfYear], [date dayOfMonth],
^~~~~~
XmlRpcEncoder.m:368:42: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date yearOfCommonEra], [date monthOfYear], [date dayOfMonth],
^~~~~~
XmlRpcEncoder.m:368:62: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date yearOfCommonEra], [date monthOfYear], [date dayOfMonth],
^~~~~
XmlRpcEncoder.m:369:18: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute]];
^~~~
XmlRpcEncoder.m:369:36: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute]];
^~~~~~~
XmlRpcEncoder.m:369:57: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute]];
^~~~~
6 warnings generated.

XmlRpcDecoder.m:275:11: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[self->data length], self->nesting);
^~~~~~~
1 warning generated.

XmlRpcMethodCall.m:139:34: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[s appendFormat:@" #paras=%d", [self->parameters count]];
~~ ^~~~~~~~
%lu
1 warning generated.

XmlRpcSaxHandler.m:430:7: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[self->params count]);
^~~~~~~~
XmlRpcSaxHandler.m:609:57: warning: conflicting parameter types in implementation of 'characters:length:': 'int' vs 'NSUInteger' (aka 'unsigned long') [-Wmismatched-parameter-types]

  • (void)characters:(unichar *)_chars length:(NSUInteger)_len {
    
    ../SaxObjC/SaxContentHandler.h:53:59: note: previous definition is here
  • (void)characters:(unichar *)_chars length:(int)_len;
    
    2 warnings generated.

StructuredText.m:516:54: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
if (self->_text) [ms appendFormat:@" text-len=%d", [self->_text length]];
~~ ^~~~~~~~
%lu
1 warning generated.

StructuredTextBodyElement.m:413:57: warning: format specifies type 'char ' but the argument has type 'NSString ' [-Wformat]
if (debugOn) NSLog(@" find link block target: '%s'", _str);
~~ ^~~~
%@
StructuredTextBodyElement.m:463:44: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
if (debugOn) NSLog(@" range(0,%d)", range.length);
~~ ^~~~
%lu
StructuredTextBodyElement.m:968:40: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[ms appendFormat:@" #elements=%d", [self->_elements count]];
~~ ^~~~~~~
%lu
3 warnings generated.

StructuredTextHeader.m:69:54: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
if (self->_text) [ms appendFormat:@" text-len=%d", [self->_text length]];
~~ ^~~~~~~~
%lu
StructuredTextHeader.m:75:40: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
[ms appendFormat:@" #elements=%d", [self->_elements count]];
~~ ^~~~~~~
%lu
2 warnings generated.

STXSaxDriver.m:356:48: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
if (debugOn) NSLog(@" chars: %d", [s length]);
~~ ^~~~~~
%lu
STXSaxDriver.m:360:48: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
if (debugOn) NSLog(@" elems: %d", [[_item elements] count]);
~~ ^~~~~~~~
%lu
STXSaxDriver.m:395:53: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
NSLog(@" produce SAX events for elements: %d", [_elems count]);
~~ ^~~~~~
%lu
3 warnings generated.

Steps To Reproduce

compile with clang on x86_64

TagsNo tags attached.

Activities

buzzdee

buzzdee

2013-12-15 18:14

reporter  

sope-xml-NSUInteger.diff (13,141 bytes)   
$OpenBSD$
--- sope-xml/XmlRpc/XmlRpcDecoder.m.orig	Sun Dec 15 13:38:29 2013
+++ sope-xml/XmlRpc/XmlRpcDecoder.m	Sun Dec 15 13:39:06 2013
@@ -271,7 +271,7 @@ static BOOL  doDebug         = NO;
   id tmp = nil;
   
   if (doDebug) {
-    NSLog(@"%s: begin (data: %i bytes, nesting: %i)", __PRETTY_FUNCTION__, 
+    NSLog(@"%s: begin (data: %"PRIuPTR" bytes, nesting: %i)", __PRETTY_FUNCTION__, 
           [self->data length], self->nesting);
   }
   if ([self->data length] == 0) return nil;
$OpenBSD$
--- sope-xml/XmlRpc/XmlRpcEncoder.m.orig	Sun Dec 15 13:36:30 2013
+++ sope-xml/XmlRpc/XmlRpcEncoder.m	Sun Dec 15 13:38:19 2013
@@ -364,9 +364,10 @@ static Class NSNumberClass = Nil;
 
   /* format in XML-RPC date format */
   
-  s = [[NSString alloc] initWithFormat:@"%04i%02i%02iT%02i:%02i:%02i",
-                 [date yearOfCommonEra], [date monthOfYear], [date dayOfMonth],
-                 [date hourOfDay], [date minuteOfHour], [date secondOfMinute]];
+  s = [[NSString alloc] initWithFormat:
+		@"%04"PRIiPTR"%02"PRIiPTR"%02"PRIiPTR"T%02"PRIiPTR":%02"PRIiPTR":%02"PRIiPTR,
+                [date yearOfCommonEra], [date monthOfYear], [date dayOfMonth],
+                [date hourOfDay], [date minuteOfHour], [date secondOfMinute]];
   
   [date release]; date = nil;
   
$OpenBSD$
--- sope-xml/XmlRpc/XmlRpcMethodCall.m.orig	Sun Dec 15 13:39:19 2013
+++ sope-xml/XmlRpc/XmlRpcMethodCall.m	Sun Dec 15 13:39:56 2013
@@ -136,7 +136,7 @@
   s = [NSMutableString stringWithFormat:@"<0x%p[%@]: ",
                          self, NSStringFromClass([self class])];
   [s appendFormat:@"method=%@", [self methodName]];
-  [s appendFormat:@" #paras=%d", [self->parameters count]];
+  [s appendFormat:@" #paras=%"PRIuPTR, [self->parameters count]];
   [s appendString:@">"];
   return s;
 }
$OpenBSD$
--- sope-xml/XmlRpc/XmlRpcSaxHandler.m.orig	Sun Dec 15 13:40:05 2013
+++ sope-xml/XmlRpc/XmlRpcSaxHandler.m	Sun Dec 15 13:41:01 2013
@@ -426,7 +426,7 @@ static BOOL  doDebug         = NO;
 
   if ([self->params count] > 1) {
     if (doDebug) {
-      NSLog(@"%s:   has more than one params (%i)!", __PRETTY_FUNCTION__, 
+      NSLog(@"%s:   has more than one params (%"PRIuPTR")!", __PRETTY_FUNCTION__, 
       [self->params count]);
     }
     self->invalidCall = YES;
$OpenBSD$
--- sope-xml/STXSaxDriver/ExtraSTX/StructuredText.m.orig	Sun Dec 15 13:44:28 2013
+++ sope-xml/STXSaxDriver/ExtraSTX/StructuredText.m	Sun Dec 15 13:45:11 2013
@@ -513,7 +513,7 @@
   ms = [NSMutableString stringWithCapacity:128];
   [ms appendFormat:@"<0x%p[%@]:", self, NSStringFromClass([self class])];
   
-  if (self->_text) [ms appendFormat:@" text-len=%d", [self->_text length]];
+  if (self->_text) [ms appendFormat:@" text-len=%"PRIuPTR, [self->_text length]];
   if (self->_document)
     [ms appendFormat:@" document=%@", self->_document];
 
$OpenBSD$
--- sope-xml/STXSaxDriver/Model/StructuredTextBodyElement.m.orig	Sun Dec 15 13:45:22 2013
+++ sope-xml/STXSaxDriver/Model/StructuredTextBodyElement.m	Sun Dec 15 13:46:47 2013
@@ -410,7 +410,7 @@ static BOOL debugOn = NO;
   unichar c;
   
   length = [_str length];
-  if (debugOn) NSLog(@"  find link block target: '%s'", _str);
+  if (debugOn) NSLog(@"  find link block target: '%@'", _str);
 
   c = [_str characterAtIndex:0];
   
@@ -460,7 +460,7 @@ static BOOL debugOn = NO;
     
     range.location = 0;
 
-    if (debugOn) NSLog(@"    range(0,%d)", range.length);
+    if (debugOn) NSLog(@"    range(0,%"PRIuPTR")", range.length);
     return range;
   }
   
@@ -965,7 +965,7 @@ static BOOL debugOn = NO;
   [ms appendFormat:@"<0x%p[%@]:", self, NSStringFromClass([self class])];
   
   if (self->_elements) 
-    [ms appendFormat:@" #elements=%d", [self->_elements count]];
+    [ms appendFormat:@" #elements=%"PRIuPTR, [self->_elements count]];
 
   if (self->_delegate) {
     [ms appendFormat:@" delegate=0x%p<%@>", 
$OpenBSD$
--- sope-xml/STXSaxDriver/Model/StructuredTextHeader.m.orig	Sun Dec 15 13:46:55 2013
+++ sope-xml/STXSaxDriver/Model/StructuredTextHeader.m	Sun Dec 15 13:47:46 2013
@@ -66,13 +66,13 @@
 
   /* header specific */
 
-  if (self->_text) [ms appendFormat:@" text-len=%d", [self->_text length]];
+  if (self->_text) [ms appendFormat:@" text-len=%"PRIuPTR, [self->_text length]];
   if (self->level) [ms appendFormat:@" level=%i",    self->level];
   
   /* common stuff */
   
   if (self->_elements) 
-    [ms appendFormat:@" #elements=%d", [self->_elements count]];
+    [ms appendFormat:@" #elements=%"PRIuPTR, [self->_elements count]];
 
   if (self->_delegate) {
     [ms appendFormat:@" delegate=0x%p<%@>", 
$OpenBSD$
--- sope-xml/STXSaxDriver/STXSaxDriver.m.orig	Sun Dec 15 13:48:01 2013
+++ sope-xml/STXSaxDriver/STXSaxDriver.m	Sun Dec 15 13:48:55 2013
@@ -353,11 +353,11 @@ static BOOL debugOn = NO;
   }
   
   if ((s = [_item textParsedWithDelegate:(id)self inContext:self->context])) {
-    if (debugOn) NSLog(@"          chars: %d", [s length]);
+    if (debugOn) NSLog(@"          chars: %"PRIuPTR, [s length]);
     [self _characters:s];
   }
   
-    if (debugOn) NSLog(@"          elems: %d", [[_item elements] count]);
+    if (debugOn) NSLog(@"          elems: %"PRIuPTR, [[_item elements] count]);
   [self produceSaxEventsForElements:[_item elements]];
   
   switch (typology) {
@@ -392,7 +392,7 @@ static BOOL debugOn = NO;
   unsigned int i, c;
   
   if (debugOn)
-    NSLog(@"  produce SAX events for elements: %d", [_elems count]);
+    NSLog(@"  produce SAX events for elements: %"PRIuPTR, [_elems count]);
   for (i = 0, c = [_elems count]; i < c; i++) {
     id currentObject;
     
$OpenBSD$
--- sope-xml/DOM/DOMElement.m.orig	Wed Dec  4 17:51:26 2013
+++ sope-xml/DOM/DOMElement.m	Sun Dec 15 13:59:37 2013
@@ -507,7 +507,7 @@ static NSNull *null = nil;
 
 - (NSString *)description {
   return [NSString stringWithFormat:
-                     @"<0x%p[%@]: name=%@ parent=%@ #attrs=%i #children=%i>",
+                     @"<0x%p[%@]: name=%@ parent=%@ #attrs=%"PRIuPTR" #children=%"PRIuPTR">",
                      self, NSStringFromClass([self class]),
                      [self nodeName],
                      [[self parentNode] nodeName],
$OpenBSD$
--- sope-xml/DOM/DOMNode.m.orig	Sun Dec 15 13:35:30 2013
+++ sope-xml/DOM/DOMNode.m	Sun Dec 15 13:36:21 2013
@@ -209,7 +209,7 @@ NSString *DOMNodeValue(id _node) {
 
 - (NSString *)description {
   return [NSString stringWithFormat:
-                     @"<0x%p[%@]: name=%@ parent=%@ type=%i #children=%i>",
+                     @"<0x%p[%@]: name=%@ parent=%@ type=%i #children=%"PRIuPTR">",
                      self, NSStringFromClass([self class]),
                      [self nodeName],
                      [[self parentNode] nodeName],
$OpenBSD$
--- sope-xml/DOM/DOMSaxHandler.m.orig	Sun Dec 15 14:15:53 2013
+++ sope-xml/DOM/DOMSaxHandler.m	Sun Dec 15 14:16:52 2013
@@ -255,7 +255,7 @@ static BOOL printErrors = NO;
   self->tagDepth--;
 }
 
-- (void)characters:(unichar *)_chars length:(int)_len {
+- (void)characters:(unichar *)_chars length:(NSUInteger)_len {
   id       charNode;
   NSString *data;
   
@@ -265,7 +265,7 @@ static BOOL printErrors = NO;
   
   [self->currentElement appendChild:charNode];
 }
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len {
 }
 
 - (void)processingInstruction:(NSString *)_pi data:(NSString *)_data {
$OpenBSD$
--- sope-xml/SaxObjC/SaxDefaultHandler.m.orig	Wed Dec  4 17:51:26 2013
+++ sope-xml/SaxObjC/SaxDefaultHandler.m	Sun Dec 15 14:22:42 2013
@@ -48,9 +48,9 @@
 {
 }
 
-- (void)characters:(unichar *)_chars length:(int)_len {
+- (void)characters:(unichar *)_chars length:(NSUInteger)_len {
 }
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len {
 }
 
 - (void)processingInstruction:(NSString *)_pi data:(NSString *)_data {
$OpenBSD$
--- sope-xml/SaxObjC/SaxDocumentHandler.h.orig	Sun Dec 15 17:42:05 2013
+++ sope-xml/SaxObjC/SaxDocumentHandler.h	Sun Dec 15 17:42:25 2013
@@ -39,8 +39,8 @@
 
 /* CDATA */
 
-- (void)characters:(unichar *)_chars          length:(int)_len;
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len;
+- (void)characters:(unichar *)_chars          length:(NSUInteger)_len;
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len;
 
 /* PIs */
 
$OpenBSD$
--- sope-xml/SaxObjC/SaxObjectDecoder.m.orig	Wed Dec  4 17:51:26 2013
+++ sope-xml/SaxObjC/SaxObjectDecoder.m	Sun Dec 15 14:23:11 2013
@@ -266,7 +266,7 @@ static NSNull *null = nil;
 
 /* CDATA */
 
-- (void)characters:(unichar *)_chars length:(int)_len {
+- (void)characters:(unichar *)_chars length:(NSUInteger)_len {
   _SaxObjTagInfo *info;
   
   if (_len == 0) return;
@@ -278,7 +278,7 @@ static NSNull *null = nil;
   return NO;
 }
 
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len {
   if ([self processIgnorableWhitespace])
     [self characters:_chars length:_len];
 }
$OpenBSD$
--- sope-xml/SaxObjC/SaxXMLFilter.m.orig	Wed Dec  4 17:51:26 2013
+++ sope-xml/SaxObjC/SaxXMLFilter.m	Sun Dec 15 14:23:43 2013
@@ -155,10 +155,10 @@
   [self->contentHandler endElement:_localName namespace:_ns rawName:_rawName];
 }
 
-- (void)characters:(unichar *)_chars length:(int)_len {
+- (void)characters:(unichar *)_chars length:(NSUInteger)_len {
   [self->contentHandler characters:_chars length:_len];
 }
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len {
   [self->contentHandler ignorableWhitespace:_chars length:_len];
 }
 - (void)processingInstruction:(NSString *)_pi data:(NSString *)_data {
$OpenBSD$
--- sope-xml/SaxObjC/SaxHandlerBase.m.orig	Sun Dec 15 17:42:39 2013
+++ sope-xml/SaxObjC/SaxHandlerBase.m	Sun Dec 15 17:43:03 2013
@@ -38,9 +38,9 @@
 - (void)endElement:(NSString *)_tagName {
 }
 
-- (void)characters:(unichar *)_chars length:(int)_len {
+- (void)characters:(unichar *)_chars length:(NSUInteger)_len {
 }
-- (void)ignorableWhitespace:(unichar *)_chars length:(int)_len {
+- (void)ignorableWhitespace:(unichar *)_chars length:(NSUInteger)_len {
 }
 
 - (void)processingInstruction:(NSString *)_pi data:(NSString *)_data {
$OpenBSD$
--- sope-xml/libxmlSAXDriver/libxmlSAXDriver.m.orig	Sun Dec 15 17:44:07 2013
+++ sope-xml/libxmlSAXDriver/libxmlSAXDriver.m	Sun Dec 15 17:48:10 2013
@@ -223,9 +223,9 @@ _startElement(libxmlSAXDriver *self, const xmlChar *na
 static void _endElement(libxmlSAXDriver *self, const xmlChar *name);
 static void _startDocument(libxmlSAXDriver *self);
 static void _endDocument(libxmlSAXDriver *self);
-static void _characters(libxmlSAXDriver *self, const xmlChar *chars, int len);
+static void _characters(libxmlSAXDriver *self, const xmlChar *chars, NSUInteger len);
 static void
-_ignorableWhiteSpace(libxmlSAXDriver *self, const xmlChar *chars, int len);
+_ignorableWhiteSpace(libxmlSAXDriver *self, const xmlChar *chars, NSUInteger len);
 static void __pi(libxmlSAXDriver *self, const xmlChar *target, const xmlChar *data);
 static void _comment(libxmlSAXDriver *self, const xmlChar *value);
 static xmlParserInputPtr
@@ -237,7 +237,7 @@ static void _warning(libxmlSAXDriver *self, const char
 static void _error(libxmlSAXDriver *self, const char *msg, ...);
 static void _fatalError(libxmlSAXDriver *self, const char *msg, ...);
 static void _setLocator(void *udata, xmlSAXLocatorPtr _locator);
-static void _cdataBlock(libxmlSAXDriver *self, const xmlChar *value, int len);
+static void _cdataBlock(libxmlSAXDriver *self, const xmlChar *value, NSUInteger len);
 static void _entityDecl(libxmlSAXDriver *self, const xmlChar *name, int type,
                        const xmlChar *publicId, const xmlChar *systemId,
                        xmlChar *content)
@@ -1038,7 +1038,7 @@ static void _endDocument(libxmlSAXDriver *self) {
   }
 }
 
-static void _characters(libxmlSAXDriver *self, const xmlChar *chars, int len) {
+static void _characters(libxmlSAXDriver *self, const xmlChar *chars, NSUInteger len) {
   /* need to transform UTF8 to UTF16 */
   unichar *data, *ts;
   
@@ -1062,13 +1062,13 @@ static void _characters(libxmlSAXDriver *self, const x
           __PRETTY_FUNCTION__, __LINE__);
   }
   else {
-    [self->contentHandler characters:data length:((unsigned)(ts - data))];
+    [self->contentHandler characters:data length:((NSUInteger)(ts - data))];
     free(data);
   }
 }
 
 static void
-_ignorableWhiteSpace(libxmlSAXDriver *self, const xmlChar *chars, int len)
+_ignorableWhiteSpace(libxmlSAXDriver *self, const xmlChar *chars, NSUInteger len)
 {
   /* need to transform UTF8 to UTF16 */
   unichar *data, *ts;
@@ -1196,7 +1196,7 @@ static xmlEntityPtr _getEntity(libxmlSAXDriver *self, 
   return p;
 }
 
-static void _cdataBlock(libxmlSAXDriver *self, const xmlChar *value, int len) {
+static void _cdataBlock(libxmlSAXDriver *self, const xmlChar *value, NSUInteger len) {
   [self->lexicalHandler startCDATA];
   _characters(self, value, len);
   [self->lexicalHandler endCDATA];
sope-xml-NSUInteger.diff (13,141 bytes)   
buzzdee

buzzdee

2014-01-15 18:30

reporter   ~0006399

ping

ludovic

ludovic

2014-02-04 13:55

administrator   ~0006481

https://github.com/inverse-inc/sope/commit/a98ec9011ef0d8864b3b83e3574144c828bb5e12

Issue History

Date Modified Username Field Change
2013-12-15 18:14 buzzdee New Issue
2013-12-15 18:14 buzzdee File Added: sope-xml-NSUInteger.diff
2014-01-15 18:30 buzzdee Note Added: 0006399
2014-02-04 00:06 ludovic Target Version => 2.2.0
2014-02-04 13:55 ludovic Note Added: 0006481
2014-02-04 13:55 ludovic Status new => closed
2014-02-04 13:55 ludovic Assigned To => ludovic
2014-02-04 13:55 ludovic Resolution open => fixed
2014-02-04 13:55 ludovic Fixed in Version => 2.2.0