Add explicit casts for type conversions.

The +0 and >>0 in SUDSAVerifier are present for readability;
the compiler is more than capable of optimizing them into nothing.
This commit is contained in:
Jake Petroules committed 2014-06-28 21:10:53 -04:00
1 parent ef5a0a997d
commit e2854d3a29
3 files changed
+12 -12

No files matched your search

+5 -5
View File
@@ -54,9 +54,9 @@ NSString *temporaryFilename(NSString *base)
return stringWithFileSystemRepresentation(mktemp(buffer));
}
static void _hashOfBuffer(unsigned char *hash, const char* buffer, size_t bufferLength)
static void _hashOfBuffer(unsigned char *hash, const char* buffer, ssize_t bufferLength)
{
assert(bufferLength <= UINT32_MAX);
assert(bufferLength >= 0 && bufferLength <= UINT32_MAX);
CC_SHA1_CTX hashContext;
CC_SHA1_Init(&hashContext);
CC_SHA1_Update(&hashContext, buffer, (CC_LONG)bufferLength);
@@ -84,14 +84,14 @@ static void _hashOfFile(unsigned char* hash, FTSENT *ent)
return;
}
size_t fileSize = (size_t)ent->fts_statp->st_size;
ssize_t fileSize = ent->fts_statp->st_size;
if (fileSize == 0) {
_hashOfBuffer(hash, NULL, 0);
close(fileDescriptor);
return;
}
void *buffer = mmap(0, fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
void *buffer = mmap(0, (size_t)fileSize, PROT_READ, MAP_FILE | MAP_PRIVATE, fileDescriptor, 0);
if (buffer == (void*)-1) {
close(fileDescriptor);
perror("mmap");
@@ -99,7 +99,7 @@ static void _hashOfFile(unsigned char* hash, FTSENT *ent)
}
_hashOfBuffer(hash, buffer, fileSize);
munmap(buffer, fileSize);
munmap(buffer, (size_t)fileSize);
close(fileDescriptor);
return;
}
+5 -5
View File
@@ -111,9 +111,9 @@ static NSData *b64decode( NSString *str )
if ( ai == 4 ) break;
}
} while ( i < len );
if ( ai >= 2 ) buf[j] = (a[0] << 2) | (a[1] >> 4);
if ( ai >= 3 ) buf[j+1] = (a[1] << 4) | (a[2] >> 2);
if ( ai >= 4 ) buf[j+2] = (a[2] << 6) | a[3];
if ( ai >= 2 ) buf[j+0] = (UInt8)((a[0] << 2) | (a[1] >> 4));
if ( ai >= 3 ) buf[j+1] = (UInt8)((a[1] << 4) | (a[2] >> 2));
if ( ai >= 4 ) buf[j+2] = (UInt8)((a[2] << 6) | (a[3] >> 0));
j += ai-1;
} while ( i < len );
@@ -219,7 +219,7 @@ static CSSM_KEY_PTR cdsaCreateKey( CFDataRef rawKey )
if ( (retval = su_malloc(sizeof(CSSM_KEY), NULL)) == NULL ) return NULL;
if ( !su_copyBytesToData(&(retval->KeyData), CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
if ( !su_copyBytesToData(&(retval->KeyData), (CSSM_SIZE)CFDataGetLength(rawKey), CFDataGetBytePtr(rawKey)) ) {
su_free( retval, NULL );
return NULL;
}
@@ -329,7 +329,7 @@ static CSSM_DATA_PTR su_createData( CFDataRef bytes )
if ( !data ) return NULL;
data->Data = NULL;
data->Length = 0;
if ( bytes ) su_copyBytesToData( data, CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
if ( bytes ) su_copyBytesToData( data, (CSSM_SIZE)CFDataGetLength(bytes), CFDataGetBytePtr(bytes) );
return data;
}
+2 -2
View File
@@ -362,8 +362,8 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
- (void)registerAsObserver
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:0 context:SUUpdaterDefaultsObservationContext];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:0 context:SUUpdaterDefaultsObservationContext];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUScheduledCheckIntervalKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:[@"values." stringByAppendingString:SUEnableAutomaticChecksKey] options:(NSKeyValueObservingOptions)0 context:SUUpdaterDefaultsObservationContext];
}
- (void)unregisterAsObserver