Skip to content

Commit

Permalink
Fix types for 32-bit systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
kstenerud committed Nov 22, 2016
1 parent 1200d92 commit 190c618
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Source/KSCrash/Recording/KSCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ - (void) setCatchZombies:(bool)catchZombies
- (void) setDoNotIntrospectClasses:(NSArray *)doNotIntrospectClasses
{
_doNotIntrospectClasses = doNotIntrospectClasses;
unsigned count = [doNotIntrospectClasses count];
NSUInteger count = [doNotIntrospectClasses count];
if(count == 0)
{
kscrash_setDoNotIntrospectClasses(nil, 0);
Expand Down
8 changes: 4 additions & 4 deletions Source/KSCrash/Recording/KSCrashReport.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ void kscrw_i_addTextFileElement(const KSCrashReportWriter* const writer,

char buffer[512];
int bytesRead;
for(bytesRead = read(fd, buffer, sizeof(buffer));
for(bytesRead = (int)read(fd, buffer, sizeof(buffer));
bytesRead > 0;
bytesRead = read(fd, buffer, sizeof(buffer)))
bytesRead = (int)read(fd, buffer, sizeof(buffer)))
{
if(ksjson_appendStringElement(getJsonContext(writer), buffer, bytesRead) != KSJSON_OK)
{
Expand Down Expand Up @@ -271,7 +271,7 @@ void kscrw_i_addUUIDElement(const KSCrashReportWriter* const writer,
*dst++ = g_hexNybbles[(*src++)&15];
}

ksjson_addStringElement(getJsonContext(writer), key, uuidBuffer, dst - uuidBuffer);
ksjson_addStringElement(getJsonContext(writer), key, uuidBuffer, (int)(dst - uuidBuffer));
}
}

Expand Down Expand Up @@ -1224,7 +1224,7 @@ void kscrw_i_writeStackContents(const KSCrashReportWriter* const writer,
writer->addUIntegerElement(writer, KSCrashField_StackPtr, sp);
writer->addBooleanElement(writer, KSCrashField_Overflow, isStackOverflow);
uint8_t stackBuffer[kStackContentsTotalDistance * sizeof(sp)];
int copyLength = (intptr_t)highAddress - (intptr_t)lowAddress;
int copyLength = (int)(highAddress - lowAddress);
if(ksmach_copyMem((void*)lowAddress, stackBuffer, copyLength) == KERN_SUCCESS)
{
writer->addDataElement(writer, KSCrashField_Contents, (void*)stackBuffer, copyLength);
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Recording/KSCrashReportStore.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void kscrs_addUserReport(const char* report, int reportLength)
goto done;
}

int bytesWritten = write(fd, report, (unsigned)reportLength);
int bytesWritten = (int)write(fd, report, (unsigned)reportLength);
if(bytesWritten < 0)
{
KSLOG_ERROR("Could not write to file %s: %s", crashReportPath, strerror(errno));
Expand Down
2 changes: 2 additions & 0 deletions Source/KSCrash/Recording/Sentry/KSCrashSentry_Deadlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ extern "C" {

#include "KSCrashSentry.h"

#include <stdbool.h>


/** Install the deadlock handler.
*
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Recording/Sentry/KSCrashSentry_Deadlock.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#import "KSCrashSentry_Deadlock.h"
#import "KSCrashSentry_Private.h"
#include "KSMach.h"
#import "KSMach.h"
#import <Foundation/Foundation.h>

//#define KSLogger_LocalLevel TRACE
Expand Down
2 changes: 2 additions & 0 deletions Source/KSCrash/Recording/Sentry/KSCrashSentry_NSException.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extern "C" {

#include "KSCrashSentry.h"

#include <stdbool.h>


/** Install our custom NSException handler.
*
Expand Down
2 changes: 2 additions & 0 deletions Source/KSCrash/Recording/Sentry/KSCrashSentry_Signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extern "C" {

#include "KSCrashSentry.h"

#include <stdbool.h>


/** Install our custom signal handler.
*
Expand Down
12 changes: 6 additions & 6 deletions Source/KSCrash/Recording/Tools/KSFileUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static bool deletePathContents(const char* path, bool deleteTopLevelPathAlso)
char* pathBuffer = malloc((unsigned)bufferLength);
snprintf(pathBuffer, bufferLength, "%s/", path);
char* pathPtr = pathBuffer + strlen(pathBuffer);
int pathRemainingLength = bufferLength - (pathPtr - pathBuffer);
int pathRemainingLength = bufferLength - (int)(pathPtr - pathBuffer);

for(int i = 0; i < entryCount; i++)
{
Expand Down Expand Up @@ -217,7 +217,7 @@ bool ksfu_writeBytesToFD(const int fd, const char* const bytes, int length)
const char* pos = bytes;
while(length > 0)
{
int bytesWritten = write(fd, pos, (unsigned)length);
int bytesWritten = (int)write(fd, pos, (unsigned)length);
if(bytesWritten == -1)
{
KSLOG_ERROR("Could not write to fd %d: %s", fd, strerror(errno));
Expand All @@ -234,7 +234,7 @@ bool ksfu_readBytesFromFD(const int fd, char* const bytes, int length)
char* pos = bytes;
while(length > 0)
{
int bytesRead = read(fd, pos, (unsigned)length);
int bytesRead = (int)read(fd, pos, (unsigned)length);
if(bytesRead == -1)
{
KSLOG_ERROR("Could not write to fd %d: %s", fd, strerror(errno));
Expand Down Expand Up @@ -311,7 +311,7 @@ bool ksfu_writeStringToFD(const int fd, const char* const string)
const char* pos = string;
while(bytesToWrite > 0)
{
int bytesWritten = write(fd, pos, (unsigned)bytesToWrite);
int bytesWritten = (int)write(fd, pos, (unsigned)bytesToWrite);
if(bytesWritten == -1)
{
KSLOG_ERROR("Could not write to fd %d: %s",
Expand Down Expand Up @@ -359,7 +359,7 @@ int ksfu_readLineFromFD(const int fd, char* const buffer, const int maxLength)
char* ch;
for(ch = buffer; ch < end; ch++)
{
int bytesRead = read(fd, ch, 1);
int bytesRead = (int)read(fd, ch, 1);
if(bytesRead < 0)
{
KSLOG_ERROR("Could not read from fd %d: %s", fd, strerror(errno));
Expand All @@ -371,7 +371,7 @@ int ksfu_readLineFromFD(const int fd, char* const buffer, const int maxLength)
}
}
*ch = 0;
return ch - buffer;
return (int)(ch - buffer);
}

bool ksfu_makePath(const char* absolutePath)
Expand Down
14 changes: 7 additions & 7 deletions Source/KSCrash/Recording/Tools/KSJSONCodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ int ksjsoncodec_i_appendEscapedString(KSJSONEncodeContext* const context,
*dst++ = *src;
}
}
int encLength = (dst - workBuffer);
int encLength = (int)(dst - workBuffer);
dst -= encLength;
return addJSONData(context, dst, encLength);
}
Expand Down Expand Up @@ -753,7 +753,7 @@ int ksjsoncodec_i_decodeString(KSJSONDecodeContext* context, char* dstBuffer, in
}
const char* srcEnd = src;
src = context->bufferPtr + 1;
int length = srcEnd - src;
int length = (int)(srcEnd - src);
if(length >= dstBufferLength)
{
KSLOG_DEBUG("String is too long");
Expand Down Expand Up @@ -1095,7 +1095,7 @@ int ksjsoncodec_i_decodeElement(const char* const name,
// it would be undefined to call sscanf/sttod etc. directly.
// instead we create a temporary string.
double value;
int len = context->bufferPtr - start;
int len = (int)(context->bufferPtr - start);
if(len >= context->stringBufferLength)
{
KSLOG_DEBUG("Number is too long.");
Expand Down Expand Up @@ -1148,7 +1148,7 @@ int ksjson_decode(const char* const data,

unlikely_if(result != KSJSON_OK && errorOffset != NULL)
{
*errorOffset = ptr - data;
*errorOffset = (int)(ptr - data);
}
return result;
}
Expand Down Expand Up @@ -1180,14 +1180,14 @@ static void updateDecoder_readFile(struct JSONFromFileContext* context)
const char* end = context->decodeContext->bufferEnd;
char* start = context->bufferStart;
const char* ptr = context->decodeContext->bufferPtr;
int bufferLength = end - start;
int remainingLength = end - ptr;
int bufferLength = (int)(end - start);
int remainingLength = (int)(end - ptr);
unlikely_if(remainingLength < bufferLength / 2)
{
int fillLength = bufferLength - remainingLength;
memcpy(start, ptr, remainingLength);
context->decodeContext->bufferPtr = start;
int bytesRead = read(context->fd, start+remainingLength, (unsigned)fillLength);
int bytesRead = (int)read(context->fd, start+remainingLength, (unsigned)fillLength);
unlikely_if(bytesRead < fillLength)
{
if(bytesRead < 0)
Expand Down
4 changes: 2 additions & 2 deletions Source/KSCrash/Recording/Tools/KSLogger.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void kslog_i_writeToLog(const char* const str)
const char* pos = str;
while(bytesToWrite > 0)
{
int bytesWritten = write(g_fd, pos, (unsigned)bytesToWrite);
int bytesWritten = (int)write(g_fd, pos, (unsigned)bytesToWrite);
unlikely_if(bytesWritten == -1)
{
return;
Expand Down Expand Up @@ -281,7 +281,7 @@ void i_kslog_logObjCBasic(CFStringRef fmt, ...)
CFStringRef entry = CFStringCreateWithFormatAndArguments(NULL, NULL, fmt, args);
va_end(args);

int bufferLength = CFStringGetLength(entry) * 4 + 1;
int bufferLength = (int)CFStringGetLength(entry) * 4 + 1;
char* stringBuffer = malloc((unsigned)bufferLength);
if(CFStringGetCString(entry, stringBuffer, (CFIndex)bufferLength, kCFStringEncodingUTF8))
{
Expand Down
2 changes: 1 addition & 1 deletion Source/KSCrash/Recording/Tools/KSMach.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ int ksmach_copyMaxPossibleMem(const void* const src, void* const dst, const int

for(;;)
{
int copyLength = pSrcEnd - pSrc;
int copyLength = (int)(pSrcEnd - pSrc);
if(copyLength <= 0)
{
break;
Expand Down
Loading

0 comments on commit 190c618

Please sign in to comment.