From e7b2d7d833c340bd76a0cfd551658d79d75cf838 Mon Sep 17 00:00:00 2001 From: cpunch Date: Wed, 27 Dec 2023 21:12:12 -0600 Subject: [PATCH] cbaselib.c:fileB_read() fix MSVC warnings --- src/cbaselib.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cbaselib.c b/src/cbaselib.c index 138141f..82d641b 100644 --- a/src/cbaselib.c +++ b/src/cbaselib.c @@ -295,14 +295,14 @@ int fileB_read(CState *state, int nargs, CValue *args) } // allocate a buffer for the read data - buffer = cosmoM_xmalloc(state, length + 1); + buffer = cosmoM_xmalloc(state, (size_t)length + 1); // read the data - fread(buffer, sizeof(char), length, file); + fread(buffer, sizeof(char), (size_t)length, file); buffer[(int)length] = '\0'; // write the NULL terminator // push the read data - temp = cosmoV_newRef(cosmoO_takeString(state, buffer, length)); + temp = cosmoV_newRef(cosmoO_takeString(state, buffer, (size_t)length)); cosmoV_pushValue(state, temp); } else if (IS_STRING(args[1])) { if (strcmp(cosmoV_readCString(args[1]), "a") == 0) { @@ -316,17 +316,17 @@ int fileB_read(CState *state, int nargs, CValue *args) fseek(file, 0, SEEK_SET); // allocate a buffer for the read data - buffer = cosmoM_xmalloc(state, length + 1); + buffer = cosmoM_xmalloc(state, (size_t)length + 1); // read the data - fread(buffer, sizeof(char), length, file); + fread(buffer, sizeof(char), (size_t)length, file); buffer[length] = '\0'; // write the NULL terminator // push the read data - temp = cosmoV_newRef(cosmoO_takeString(state, buffer, length)); + temp = cosmoV_newRef(cosmoO_takeString(state, buffer, (size_t)length)); cosmoV_pushValue(state, temp); } else { - cosmoV_error(state, "file:read() expected \"a\" or , got %s!", + cosmoV_error(state, "file:read() expected \"a\" or , got \"%s\"!", cosmoV_readCString(args[1])); } } else {