View Issue Details

IDProjectCategoryView StatusLast Update
0002566SOGoSOPEpublic2014-02-04 14:01
Reporterbuzzdee Assigned Toludovic  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformamd64OSOpenBSDOS Version5.4-current
Product Version2.1.1b 
Target Version2.2.0Fixed in Version2.2.0 
Summary0002566: fixes compilation warnings in sope-core/NGExtensions
Description

compiling with clang, the following compilation warnings are fixed with the attached patch:

NGLoggerManager.m:127:49: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
debugAll ? @"YES" : @"NO", [self->loggerMap count]];
^~~~~~~
1 warning generated.

NGLogEventDetailedFormatter.m:89:5: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date dayOfMonth],
^~~~~
NGLogEventDetailedFormatter.m:90:5: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute],
^~~~
NGLogEventDetailedFormatter.m:90:23: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute],
^~~~~~~
NGLogEventDetailedFormatter.m:90:44: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
[date hourOfDay], [date minuteOfHour], [date secondOfMinute],
^~~~~
4 warnings generated.

NGBitSet.m:227:48: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
for (element = (self->universe - 1); element >= 0; element--) {


1 warning generated.

NGBundleManager.m:905:20: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
                v, [clazz version],
                   ^~~~~~~~~~~~~~~
NGBundleManager.m:921:20: warning: format specifies type 'int' but the argument has type 'NSInteger' (aka 'long') [-Wformat]
                v, [clazz version],
                   ^~~~~~~~~~~~~~~
NGBundleManager.m:1143:11: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
          NSCountMapTable(self->loadedBundles), _resourceName, _type);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NGBundleManager.m:1319:11: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
          NSCountMapTable(self->loadedBundles), _resourceName, _type);

NGHashMap.m:413:20: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                   _index, _key, list->count];
                   ^~~~~~
NGHashMap.m:726:21: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                    _index, self];
                    ^~~~~~
NGHashMap.m:738:21: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                    _index, self, root->count];
                    ^~~~~~
3 warnings generated.

NGStack.m:225:22: warning: format specifies type 'unsigned int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                     [self capacity], [self stackPointer], [self count],
                     ^~~~~~~~~~~~~~~
NGStack.m:225:39: warning: format specifies type 'unsigned int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                     [self capacity], [self stackPointer], [self count],
                                      ^~~~~~~~~~~~~~~~~~~
NGStack.m:225:60: warning: format specifies type 'unsigned int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
                     [self capacity], [self stackPointer], [self count],
                                                           ^~~~~~~~~~~~
NGStack.m:303:15: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
  if (lastIdx >= 0) {
      ~~~~~~~ ^  ~
4 warnings generated.

NGCalendarDateRange.m:197:41: warning: format specifies type 'unsigned int' but the argument has type 'NGCalendarDateRange *' [-Wformat]
                 NSStringFromClass(self->isa), self, self->startDate];
                                               ^~~~
NGCalendarDateRange.m:174:1: warning: conflicting return type in implementation of 'hash': 'NSUInteger' (aka 'unsigned long') vs 'unsigned int' [-Wmismatched-return-types]
- (unsigned)hash {
^  ~~~~~~~~
/usr/local/include/Foundation/NSObject.h:130:1: note: previous definition is here
- (NSUInteger) hash;
^

NGResourceLocator.m:266:29: warning: format specifies type 'int' but the argument has type 'NSUInteger' (aka 'unsigned long') [-Wformat]
  [ms appendFormat:@":#%d", [self->nameToPathCache count]];
                       ~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       %lu
1 warning generated.
Steps To Reproduce

compile with clang on 64 Bit architecture

Additional Information

attached patch fixes the problems that the warnings are pointing to.

TagsNo tags attached.

Activities

buzzdee

buzzdee

2013-12-25 22:37

reporter  

sope-warning-fixes-NGExtensions.diff (7,744 bytes)   
$OpenBSD$
--- sope-core/NGExtensions/NGStack.m.orig	Thu Dec 19 07:19:14 2013
+++ sope-core/NGExtensions/NGStack.m	Thu Dec 19 07:23:53 2013
@@ -220,7 +220,7 @@
 
 - (NSString *)description {
   return [NSString stringWithFormat:
-                     @"<%@[0x%p] capacity=%u SP=%u count=%u content=%s>",
+    @"<%@[0x%p] capacity=%"PRIuPTR" SP=%"PRIuPTR" count=%"PRIuPTR" content=%s>",
                      NSStringFromClass([self class]), self,
                      [self capacity], [self stackPointer], [self count],
                      [[[self toArray] description] cString]];
@@ -298,19 +298,11 @@
   [self addObject:_obj];
 }
 - (id)pop {
-  unsigned lastIdx = ([self count] - 1);
+  NSUInteger lastIdx = ([self count] - 1);
 
-  if (lastIdx >= 0) {
-    id element = [self objectAtIndex:lastIdx];
-    [self removeObjectAtIndex:lastIdx];
-    return element;
-  }
-  else {
-    [[[NGStackException alloc] initWithName:@"StackException"
-        reason:@"tried to pop an object from an empty stack !"
-        userInfo:nil] raise];
-    return nil;
-  }
+  id element = [self objectAtIndex:lastIdx];
+  [self removeObjectAtIndex:lastIdx];
+  return element;
 }
 
 - (void)clear {
$OpenBSD$
--- sope-core/NGExtensions/NGLogging.subproj/NGLogEventDetailedFormatter.m.orig	Thu Dec 19 07:07:01 2013
+++ sope-core/NGExtensions/NGLogging.subproj/NGLogEventDetailedFormatter.m	Thu Dec 19 07:09:16 2013
@@ -84,7 +84,7 @@ static __inline__ unsigned char *levelPrefixForEvent(N
   fe = [NSMutableString stringWithCapacity:160];
   /* timestamp, process name, process id, level prefix */
   date = [_event date];
-  [fe appendFormat:@"%s %02i %02i:%02i:%02i %s [%d]: %s",
+  [fe appendFormat:@"%s %02"PRIiPTR" %02"PRIiPTR":%02"PRIiPTR":%02"PRIiPTR" %s [%d]: %s",
     monthNames[[date monthOfYear]],
     [date dayOfMonth],
     [date hourOfDay], [date minuteOfHour], [date secondOfMinute],
$OpenBSD$
--- sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m.orig	Thu Dec 19 07:05:35 2013
+++ sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m	Thu Dec 19 07:06:30 2013
@@ -122,7 +122,8 @@ static BOOL            debugAll        = NO;
 /* description */
 
 - (NSString *)description {
-  return [NSString stringWithFormat:@"<%@[0x%p] debugAll=%@ #loggers=%d>",
+  return [NSString stringWithFormat:
+		@"<%@[0x%p] debugAll=%@ #loggers=%"PRIuPTR">",
                      NSStringFromClass([self class]), self,
                      debugAll ? @"YES" : @"NO", [self->loggerMap count]];
 }
$OpenBSD$
--- sope-core/NGExtensions/NGBitSet.m.orig	Thu Dec 19 07:09:27 2013
+++ sope-core/NGExtensions/NGBitSet.m	Thu Dec 19 07:11:31 2013
@@ -222,9 +222,9 @@
 }
 
 - (NSUInteger)lastMember {
-  register unsigned int element;
+  register NSUInteger element;
 
-  for (element = (self->universe - 1); element >= 0; element--) {
+  for (element = (self->universe - 1); element > 0; element--) {
     if (NGTestBit(element))
       return element;
   }
$OpenBSD$
--- sope-core/NGExtensions/NGBundleManager.m.orig	Thu Dec 19 07:11:56 2013
+++ sope-core/NGExtensions/NGBundleManager.m	Thu Dec 19 07:15:39 2013
@@ -891,15 +891,15 @@ static NSString *NGEnvVarPathSeparator = @":";
         continue;
       
       if ([i objectForKey:@"exact-version"]) {
-        int v;
+        NSInteger v;
 
-        v = [[i objectForKey:@"exact-version"] intValue];
+        v = [[i objectForKey:@"exact-version"] integerValue];
 	
         if (v != [clazz version]) {
           NSLog(@"ERROR: required exact class match failed:\n"
                 @"  class:            %@\n"
-                @"  required version: %i\n"
-                @"  loaded version:   %i\n"
+                @"  required version: %"PRIiPTR"\n"
+                @"  loaded version:   %"PRIiPTR"\n"
                 @"  bundle:           %@",
                 className,
                 v, [clazz version],
@@ -907,15 +907,15 @@ static NSString *NGEnvVarPathSeparator = @":";
         }
       }
       else if ([i objectForKey:@"version"]) {
-        int v;
+        NSInteger v;
         
         v = [[i objectForKey:@"version"] intValue];
         
         if (v > [clazz version]) {
           NSLog(@"ERROR: provided class does not match required version:\n"
                 @"  class:                  %@\n"
-                @"  least required version: %i\n"
-                @"  loaded version:         %i\n"
+                @"  least required version: %"PRIiPTR"\n"
+                @"  loaded version:         %"PRIiPTR"\n"
                 @"  bundle:                 %@",
                 className,
                 v, [clazz version],
@@ -1139,7 +1139,7 @@ static BOOL _doesInfoMatch(NSArray *keys, NSDictionary
   NSString       *path;
 
   if (debugOn) {
-    NSLog(@"BM LOOKUP pathes (%d bundles loaded): %@ / %@", 
+    NSLog(@"BM LOOKUP pathes (%"PRIuPTR" bundles loaded): %@ / %@", 
           NSCountMapTable(self->loadedBundles), _resourceName, _type);
   }
   
@@ -1315,7 +1315,7 @@ static BOOL _doesInfoMatch(NSArray *keys, NSDictionary
   NSArray       *rnKeys = nil;
   
   if (debugOn) {
-    NSLog(@"BM LOOKUP path (%d bundles loaded): %@ / %@", 
+    NSLog(@"BM LOOKUP path (%"PRIuPTR" bundles loaded): %@ / %@", 
           NSCountMapTable(self->loadedBundles), _resourceName, _type);
   }
   
$OpenBSD$
--- sope-core/NGExtensions/NGHashMap.m.orig	Thu Dec 19 07:15:51 2013
+++ sope-core/NGExtensions/NGHashMap.m	Thu Dec 19 07:19:02 2013
@@ -409,7 +409,7 @@ static inline unsigned __countObjectsForKey(NGHashMap 
   
   if ((_index < list->count) == 0) {
     [NSException raise:NSRangeException
-                 format:@"index %d out of range for key %@ of length %d",
+                format:@"index %"PRIuPTR" out of range for key %@ of length %d",
                    _index, _key, list->count];
     return nil;
   }
@@ -722,7 +722,7 @@ static inline unsigned __countObjectsForKey(NGHashMap 
   if ((root = [self __structForKey:_key]) == NULL) {
     if (_index > 0) {
       [NSException raise:NSRangeException
-                   format:@"index %d out of range in map 0x%p", 
+                   format:@"index %"PRIuPTR" out of range in map 0x%p", 
                     _index, self];
       return;
     }
@@ -734,7 +734,7 @@ static inline unsigned __countObjectsForKey(NGHashMap 
   else {
     if (!(_index < root->count)) {
       [NSException raise:NSRangeException
-                   format:@"index %d out of range in map 0x%p length %d", 
+                  format:@"index %"PRIuPTR" out of range in map 0x%p length %d",
                     _index, self, root->count];
       return;
     }
$OpenBSD$
--- sope-core/NGExtensions/NGCalendarDateRange.m.orig	Thu Dec 19 07:24:03 2013
+++ sope-core/NGExtensions/NGCalendarDateRange.m	Thu Dec 19 07:25:38 2013
@@ -171,7 +171,7 @@
 	  [self->endDate isEqual:[other endDate]]) ? YES : NO;
 }
 
-- (unsigned)hash {
+- (NSUInteger)hash {
   return [self->startDate hash] ^ [self->endDate hash];
 }
 
@@ -193,7 +193,7 @@
     
   description = [NSMutableString stringWithCapacity:64];
 
-  [description appendFormat:@"<%@[0x%x]: startDate:%@ endDate: ", 
+  [description appendFormat:@"<%@[0x%p]: startDate:%@ endDate: ", 
 	         NSStringFromClass(self->isa), self, self->startDate];
   
   if ([self->startDate isEqual:self->endDate])
$OpenBSD$
--- sope-core/NGExtensions/NGResourceLocator.m.orig	Thu Dec 19 07:26:12 2013
+++ sope-core/NGExtensions/NGResourceLocator.m	Thu Dec 19 07:26:27 2013
@@ -263,7 +263,7 @@
     [ms appendString:@":hits"];
   if (self->flags.cachePathMisses)
     [ms appendString:@":misses"];
-  [ms appendFormat:@":#%d", [self->nameToPathCache count]];
+  [ms appendFormat:@":#%"PRIuPTR, [self->nameToPathCache count]];
   
   [ms appendString:@">"];
   return ms;
buzzdee

buzzdee

2014-01-15 18:29

reporter   ~0006395

ping

ludovic

ludovic

2014-02-04 14:01

administrator   ~0006485

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

Issue History

Date Modified Username Field Change
2013-12-25 22:37 buzzdee New Issue
2013-12-25 22:37 buzzdee File Added: sope-warning-fixes-NGExtensions.diff
2014-01-15 18:29 buzzdee Note Added: 0006395
2014-02-04 00:06 ludovic Target Version => 2.2.0
2014-02-04 14:01 ludovic Note Added: 0006485
2014-02-04 14:01 ludovic Status new => closed
2014-02-04 14:01 ludovic Assigned To => ludovic
2014-02-04 14:01 ludovic Resolution open => fixed
2014-02-04 14:01 ludovic Fixed in Version => 2.2.0