From 932a226195b3925c1b8f3d2ef11c0c7f7eb4a0ae Mon Sep 17 00:00:00 2001 From: Li Xiaoming Date: Mon, 20 May 2019 15:57:42 +0800 Subject: Fix build warning of typecast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit struct stat stbuf.st_size is off_t{aka long int}, but malloc and free need size_t{aka long unsigned int}. Bug-AGL: SPEC-2422 Change-Id: I93fe49004133cd979fe24001d029a56c2660a62b Signed-off-by: Li Xiaoming --- src/steering_wheel_json.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/steering_wheel_json.c b/src/steering_wheel_json.c index 9d72284..4377a72 100644 --- a/src/steering_wheel_json.c +++ b/src/steering_wheel_json.c @@ -148,8 +148,8 @@ int wheel_define_init(const char *fname) return -1; } - filebuf = (char *)malloc(stbuf.st_size); - fread(filebuf, 1, stbuf.st_size, fp); + filebuf = (char *)malloc((size_t)stbuf.st_size); + fread(filebuf, 1, (size_t)stbuf.st_size, fp); fclose(fp); jobj = json_tokener_parse(filebuf); @@ -274,8 +274,8 @@ int wheel_gear_para_init(const char *fname) return -1; } - filebuf = (char*)malloc(stbuf.st_size); - fread(filebuf, 1, stbuf.st_size, fp); + filebuf = (char*)malloc((size_t)stbuf.st_size); + fread(filebuf, 1, (size_t)stbuf.st_size, fp); fclose(fp); jobj = json_tokener_parse(filebuf); -- cgit 1.2.3-korg