Permalink
Browse files

Fixed a bunch of warnings that would come up with certain compiler op…

…tions.
  • Loading branch information...
1 parent 5d87488 commit 8fba9b8c86de67fd3319130e4f41a62e347d2fca @ccgus committed Jun 17, 2012
Showing with 82 additions and 70 deletions.
  1. +6 −0 fmdb.xcodeproj/project.pbxproj
  2. +20 −13 src/FMDatabase.m
  3. +3 −3 src/FMDatabasePool.m
  4. +4 −4 src/FMResultSet.m
  5. +49 −50 src/fmdb.m
@@ -274,12 +274,15 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_OBJCPP_ARC_ABI = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fmdb_Prefix.pch;
+ GCC_WARN_SHADOW = YES;
INSTALL_PATH = "$(HOME)/bin";
LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS)";
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -293,11 +296,14 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_OBJCPP_ARC_ABI = YES;
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = fmdb_Prefix.pch;
+ GCC_WARN_SHADOW = YES;
INSTALL_PATH = "$(HOME)/bin";
LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS)";
MACOSX_DEPLOYMENT_TARGET = 10.7;
View
@@ -26,7 +26,7 @@ + (NSString*)sqliteLibVersion {
+ (BOOL)isSQLiteThreadSafe {
// make sure to read the sqlite headers on this guy!
- return sqlite3_threadsafe();
+ return sqlite3_threadsafe() != 0;
}
- (id)initWithPath:(NSString*)aPath {
@@ -358,7 +358,7 @@ - (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
sqlite3_bind_int64(pStmt, idx, [obj longLongValue]);
}
else if (strcmp([obj objCType], @encode(unsigned long long)) == 0) {
- sqlite3_bind_int64(pStmt, idx, [obj unsignedLongLongValue]);
+ sqlite3_bind_int64(pStmt, idx, (long long)[obj unsignedLongLongValue]);
}
else if (strcmp([obj objCType], @encode(float)) == 0) {
sqlite3_bind_double(pStmt, idx, [obj floatValue]);
@@ -386,28 +386,33 @@ - (void)extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMut
if (last == '%') {
switch (current) {
case '@':
- arg = va_arg(args, id); break;
+ arg = va_arg(args, id);
+ break;
case 'c':
// warning: second argument to 'va_arg' is of promotable type 'char'; this va_arg has undefined behavior because arguments will be promoted to 'int'
- arg = [NSString stringWithFormat:@"%c", va_arg(args, int)]; break;
+ arg = [NSString stringWithFormat:@"%c", va_arg(args, int)];
+ break;
case 's':
- arg = [NSString stringWithUTF8String:va_arg(args, char*)]; break;
+ arg = [NSString stringWithUTF8String:va_arg(args, char*)];
+ break;
case 'd':
case 'D':
case 'i':
- arg = [NSNumber numberWithInt:va_arg(args, int)]; break;
+ arg = [NSNumber numberWithInt:va_arg(args, int)];
+ break;
case 'u':
case 'U':
- arg = [NSNumber numberWithUnsignedInt:va_arg(args, unsigned int)]; break;
+ arg = [NSNumber numberWithUnsignedInt:va_arg(args, unsigned int)];
+ break;
case 'h':
i++;
if (i < length && [sql characterAtIndex:i] == 'i') {
// warning: second argument to 'va_arg' is of promotable type 'short'; this va_arg has undefined behavior because arguments will be promoted to 'int'
- arg = [NSNumber numberWithShort:va_arg(args, int)];
+ arg = [NSNumber numberWithShort:(short)(va_arg(args, int))];
}
else if (i < length && [sql characterAtIndex:i] == 'u') {
// warning: second argument to 'va_arg' is of promotable type 'unsigned short'; this va_arg has undefined behavior because arguments will be promoted to 'int'
- arg = [NSNumber numberWithUnsignedShort:va_arg(args, uint)];
+ arg = [NSNumber numberWithUnsignedShort:(unsigned short)(va_arg(args, uint))];
}
else {
i--;
@@ -426,10 +431,12 @@ - (void)extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMut
}
break;
case 'f':
- arg = [NSNumber numberWithDouble:va_arg(args, double)]; break;
+ arg = [NSNumber numberWithDouble:va_arg(args, double)];
+ break;
case 'g':
// warning: second argument to 'va_arg' is of promotable type 'float'; this va_arg has undefined behavior because arguments will be promoted to 'double'
- arg = [NSNumber numberWithFloat:va_arg(args, double)]; break;
+ arg = [NSNumber numberWithFloat:(float)(va_arg(args, double))];
+ break;
case 'l':
i++;
if (i < length) {
@@ -592,7 +599,7 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr
while (idx < queryCount) {
if (arrayArgs) {
- obj = [arrayArgs objectAtIndex:idx];
+ obj = [arrayArgs objectAtIndex:(NSUInteger)idx];
}
else {
obj = va_arg(args, id);
@@ -776,7 +783,7 @@ - (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArra
while (idx < queryCount) {
if (arrayArgs) {
- obj = [arrayArgs objectAtIndex:idx];
+ obj = [arrayArgs objectAtIndex:(NSUInteger)idx];
}
else {
obj = va_arg(args, id);
View
@@ -129,7 +129,7 @@ - (FMDatabase*)db {
- (NSUInteger)countOfCheckedInDatabases {
- __block NSInteger count;
+ __block NSUInteger count;
[self executeLocked:^() {
count = [_databaseInPool count];
@@ -140,7 +140,7 @@ - (NSUInteger)countOfCheckedInDatabases {
- (NSUInteger)countOfCheckedOutDatabases {
- __block NSInteger count;
+ __block NSUInteger count;
[self executeLocked:^() {
count = [_databaseOutPool count];
@@ -150,7 +150,7 @@ - (NSUInteger)countOfCheckedOutDatabases {
}
- (NSUInteger)countOfOpenDatabases {
- __block NSInteger count;
+ __block NSUInteger count;
[self executeLocked:^() {
count = [_databaseOutPool count] + [_databaseInPool count];
View
@@ -100,7 +100,7 @@ - (void)kvcMagic:(id)object {
- (NSDictionary*)resultDict {
- int num_cols = sqlite3_data_count([_statement statement]);
+ NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
if (num_cols > 0) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
@@ -129,7 +129,7 @@ - (NSDictionary*)resultDict {
- (NSDictionary*)resultDictionary {
- int num_cols = sqlite3_data_count([_statement statement]);
+ NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
if (num_cols > 0) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
@@ -333,7 +333,7 @@ - (NSData*)dataForColumnIndex:(int)columnIdx {
int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
- NSMutableData *data = [NSMutableData dataWithLength:dataSize];
+ NSMutableData *data = [NSMutableData dataWithLength:(NSUInteger)dataSize];
memcpy([data mutableBytes], sqlite3_column_blob([_statement statement], columnIdx), dataSize);
@@ -353,7 +353,7 @@ - (NSData*)dataNoCopyForColumnIndex:(int)columnIdx {
int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
- NSData *data = [NSData dataWithBytesNoCopy:(void *)sqlite3_column_blob([_statement statement], columnIdx) length:dataSize freeWhenDone:NO];
+ NSData *data = [NSData dataWithBytesNoCopy:(void *)sqlite3_column_blob([_statement statement], columnIdx) length:(NSUInteger)dataSize freeWhenDone:NO];
return data;
}
Oops, something went wrong.

0 comments on commit 8fba9b8

Please sign in to comment.