From a4e2377c72f2e6f018792dff10ed967f08cfac5f Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Mon, 8 Feb 2010 14:04:16 +0000 Subject: OTP-8412 Fixed numerous compiler warnings generated by gcc 4.4.1 and tile-cc 2.0.1.78377 when compiling the runtime system. --- erts/emulator/beam/bif.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'erts/emulator/beam/bif.c') diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index 9c8c0df9f0..1b670585a7 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -4143,6 +4143,7 @@ BIF_RETTYPE blocking_read_file_1(BIF_ALIST_1) FILE *file; struct stat file_info; char *filename = NULL; + size_t size; i = list_length(BIF_ARG_1); if (i < 0) { @@ -4170,9 +4171,13 @@ BIF_RETTYPE blocking_read_file_1(BIF_ALIST_1) fclose(file); BIF_RET(TUPLE2(hp, am_error, am_allocator)); } - fread(buff, 1, buff_size, file); + size = fread(buff, 1, buff_size, file); fclose(file); - bin = new_binary(BIF_P, buff, buff_size); + if (size < 0) + size = 0; + else if (size > buff_size) + size = (size_t) buff_size; + bin = new_binary(BIF_P, buff, (int) size); erts_free(ERTS_ALC_T_TMP, (void *) buff); BIF_RET(TUPLE2(hp, am_ok, bin)); -- cgit v1.2.3