Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Commit

Permalink
Changed some int types and fixed casting
Browse files Browse the repository at this point in the history
  • Loading branch information
jarush committed Jan 19, 2014
1 parent f341984 commit c47f5e5
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion IOStream/AesOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

CCCryptorRef cryptorRef;

uint32_t bufferCapacity;
size_t bufferCapacity;
uint8_t *buffer;
}

Expand Down
4 changes: 2 additions & 2 deletions IOStream/AesOutputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "AesOutputStream.h"

@interface AesOutputStream (PrivateMethods)
- (void)ensureBufferCapacity:(uint32_t)capacity;
- (void)ensureBufferCapacity:(size_t)capacity;
@end

@implementation AesOutputStream
Expand Down Expand Up @@ -69,7 +69,7 @@ - (void)close {
[outputStream close];
}

- (void)ensureBufferCapacity:(uint32_t)capacity {
- (void)ensureBufferCapacity:(size_t)capacity {
// Check if we need to resize the internal buffer
if (capacity > bufferCapacity) {
free(buffer);
Expand Down
2 changes: 1 addition & 1 deletion IOStream/FileOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
int fd;
}

- (id)initWithFilename:(NSString*)filename flags:(NSUInteger)flags mode:(NSUInteger)mode;
- (id)initWithFilename:(NSString*)filename flags:(int)flags mode:(mode_t)mode;
- (NSInteger)seek:(NSUInteger)offset;

@end
2 changes: 1 addition & 1 deletion IOStream/FileOutputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@implementation FileOutputStream

- (id)initWithFilename:(NSString*)filename flags:(NSUInteger)flags mode:(NSUInteger)mode {
- (id)initWithFilename:(NSString*)filename flags:(int)flags mode:(mode_t)mode {
self = [super init];
if (self) {
fd = open([filename UTF8String], flags, mode);
Expand Down
4 changes: 2 additions & 2 deletions IOStream/GZipInputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (NSUInteger)read:(void*)bytes length:(NSUInteger)bytesLength {

- (BOOL)decompress {
int ret;
int n;
NSUInteger n;

if (eof) {
return NO;
Expand All @@ -86,7 +86,7 @@ - (BOOL)decompress {
@throw [NSException exceptionWithName:@"IOException" reason:@"Failed to read compressed data" userInfo:nil];
}

zstream.avail_in = n;
zstream.avail_in = (unsigned int)n;
zstream.next_in = inputBuffer;
}

Expand Down
2 changes: 1 addition & 1 deletion IOStream/GZipOutputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (id)initWithOutputStream:(OutputStream*)stream {
- (NSUInteger)write:(const void *)bytes length:(NSUInteger)bytesLength {
int n;

zstream.avail_in = bytesLength;
zstream.avail_in = (unsigned int)bytesLength;
zstream.next_in = (void*)bytes;

while (zstream.avail_in > 0) {
Expand Down
2 changes: 1 addition & 1 deletion IOStream/Sha256OutputStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (id)initWithOutputStream:(OutputStream *)stream {
}

- (NSUInteger)write:(const void *)bytes length:(NSUInteger)bytesLength {
CC_SHA256_Update(&shaCtx, bytes, bytesLength);
CC_SHA256_Update(&shaCtx, bytes, (CC_LONG)bytesLength);

return [outputStream write:bytes length:bytesLength];
}
Expand Down
26 changes: 14 additions & 12 deletions KeePassLib/Kdb3Writer.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (uint32_t)numOfGroups:(Kdb3Group *)root {
* Get the number of entries and meta entries in the KDB tree
*/
- (uint32_t)numOfEntries:(Kdb3Group *)root {
int num = [root.entries count] + [root.metaEntries count];
uint32_t num = (uint32_t)([root.entries count] + [root.metaEntries count]);
for (Kdb3Group *g in root.groups) {
num += [self numOfEntries:g];
}
Expand Down Expand Up @@ -187,7 +187,7 @@ - (void)writeGroup:(Kdb3Group *)group withOutputStream:(OutputStream *)outputStr
[dataOutputStream close];

// Write the extra data to a field with id 0
[self appendField:0 size:dataOutputStream.data.length bytes:dataOutputStream.data.bytes withOutputStream:outputStream];
[self appendField:0 size:(uint32_t)dataOutputStream.data.length bytes:dataOutputStream.data.bytes withOutputStream:outputStream];

firstGroup = NO;
}
Expand All @@ -197,7 +197,7 @@ - (void)writeGroup:(Kdb3Group *)group withOutputStream:(OutputStream *)outputStr

if (![Utils emptyString:group.name]){
const char * title = [group.name cStringUsingEncoding:NSUTF8StringEncoding];
[self appendField:2 size:strlen(title)+1 bytes:(void *)title withOutputStream:outputStream];
[self appendField:2 size:(uint32_t)(strlen(title) + 1) bytes:(void *)title withOutputStream:outputStream];
}

[Kdb3Date toPacked:group.creationTime bytes:packedDate];
Expand All @@ -212,7 +212,8 @@ - (void)writeGroup:(Kdb3Group *)group withOutputStream:(OutputStream *)outputStr
[Kdb3Date toPacked:group.expiryTime bytes:packedDate];
[self appendField:6 size:5 bytes:packedDate withOutputStream:outputStream];

tmp32 = CFSwapInt32HostToLittle(group.image);
tmp32 = (uint32_t)group.image;
tmp32 = CFSwapInt32HostToLittle(tmp32);
[self appendField:7 size:4 bytes:&tmp32 withOutputStream:outputStream];

// Get the level of the group
Expand Down Expand Up @@ -242,38 +243,39 @@ - (void)writeEntry:(Kdb3Entry *)entry withOutputStream:(OutputStream *)outputStr
tmp32 = CFSwapInt32HostToLittle(((Kdb3Group*)entry.parent).groupId);
[self appendField:2 size:4 bytes:&tmp32 withOutputStream:outputStream];

tmp32 = CFSwapInt32HostToLittle(entry.image);
tmp32 = (uint32_t)entry.image;
tmp32 = CFSwapInt32HostToLittle(tmp32);
[self appendField:3 size:4 bytes:&tmp32 withOutputStream:outputStream];

tmpStr = "";
if (![Utils emptyString:entry.title]) {
tmpStr = [entry.title cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:4 size:strlen(tmpStr) + 1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:4 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

tmpStr = "";
if (![Utils emptyString:entry.url]) {
tmpStr = [entry.url cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:5 size:strlen(tmpStr) + 1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:5 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

tmpStr = "";
if (![Utils emptyString:entry.username]) {
tmpStr = [entry.username cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:6 size:strlen(tmpStr) + 1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:6 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

tmpStr = "";
if (![Utils emptyString:entry.password]) {
tmpStr = [entry.password cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:7 size:strlen(tmpStr) + 1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:7 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

tmpStr = "";
if (![Utils emptyString:entry.notes]) {
tmpStr = [entry.notes cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:8 size:strlen(tmpStr) + 1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:8 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

[Kdb3Date toPacked:entry.creationTime bytes:buffer];
[self appendField:9 size:5 bytes:buffer withOutputStream:outputStream];
Expand All @@ -291,10 +293,10 @@ - (void)writeEntry:(Kdb3Entry *)entry withOutputStream:(OutputStream *)outputStr
if (![Utils emptyString:entry.binaryDesc]) {
tmpStr = [entry.binaryDesc cStringUsingEncoding:NSUTF8StringEncoding];
}
[self appendField:13 size:strlen(tmpStr)+1 bytes:tmpStr withOutputStream:outputStream];
[self appendField:13 size:(uint32_t)(strlen(tmpStr) + 1) bytes:tmpStr withOutputStream:outputStream];

if (entry.binary && entry.binary.length) {
[self appendField:14 size:entry.binary.length bytes:entry.binary.bytes withOutputStream:outputStream];
[self appendField:14 size:(uint32_t)entry.binary.length bytes:entry.binary.bytes withOutputStream:outputStream];
} else {
[self appendField:14 size:0 bytes:nil withOutputStream:outputStream];
}
Expand Down
2 changes: 1 addition & 1 deletion KeePassLib/Kdb4Parser.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (id)initWithRandomStream:(RandomStream *)cryptoRandomStream {

int readCallback(void *context, char *buffer, int len) {
InputStream *inputStream = (__bridge InputStream*)context;
return [inputStream read:buffer length:len];
return (int)[inputStream read:buffer length:len];
}

int closeCallback(void *context) {
Expand Down

0 comments on commit c47f5e5

Please sign in to comment.