diff --git a/ports/port.script b/ports/port.script index 25f7a93..e45eb4d 100644 --- a/ports/port.script +++ b/ports/port.script @@ -214,7 +214,7 @@ void PortGCC() { assert SystemShellExecute("which xz"); // Check all the needed libraries are available. - assert FileWriteAll("bin/test.c", "void main() {}"); + assert FileWriteAll("bin/test.c", "int main() { return 0; }"); assert SystemShellExecute("gcc %libraryPath% -lmpc bin/test.c -o bin/test"); // If this fails, install mpc/libmpc/libmpc-dev. assert SystemShellExecute("gcc %libraryPath% -lmpfr bin/test.c -o bin/test"); // If this fails, install mpfr/libmpfr/libmpfr-dev. assert SystemShellExecute("gcc %libraryPath% -lgmp bin/test.c -o bin/test"); // If this fails, install gmp/libgmp/libgmp-dev. diff --git a/util/script.c b/util/script.c index f3f31a8..1ad950c 100644 --- a/util/script.c +++ b/util/script.c @@ -4732,7 +4732,7 @@ int ExternalSystemShellExecuteWithWorkingDirectory(ExecutionContext *context, Va pid_t pid = fork(); if (pid == 0) { - chdir(temporary); + Assert(chdir(temporary) == 0); exit(system(temporary2)); } else if (pid < 0) { PrintDebug("Unable to fork(), got pid = %d, errno = %d.\n", pid, errno); @@ -4758,7 +4758,7 @@ int ExternalSystemShellExecuteWithWorkingDirectory(ExecutionContext *context, Va return 0; } - chdir(temporary); + Assert(chdir(temporary) == 0); returnValue->i = system(temporary2) == 0; chdir(data); free(temporary); @@ -5257,7 +5257,8 @@ int ExternalConsoleGetLine(ExecutionContext *context, Value *returnValue) { #else char *line = NULL; size_t pos; - getline(&line, &pos, stdin); + size_t unused = getline(&line, &pos, stdin); + (void) unused; uintptr_t index = HeapAllocate(context); context->heap[index].type = T_STR; context->heap[index].bytes = strlen(line) - 1; @@ -5502,8 +5503,9 @@ void *FileLoad(const char *path, size_t *length) { fseek(file, 0, SEEK_SET); char *buffer = (char *) malloc(fileSize + 1); buffer[fileSize] = 0; - fread(buffer, 1, fileSize, file); + size_t readBytes = fread(buffer, 1, fileSize, file); fclose(file); + if (readBytes != fileSize) { free(buffer); return NULL; } if (length) *length = fileSize; return buffer; }