| The etphidiap-1.1 Makefile forces CC=gcc and does not specify a C standard. As |
| of 2019-03 the Chromium OS chroot environment uses gcc 4.9.2 which has a default |
| of -std=gnu90. This patch makes etphid_updater compile in that environment. |
| |
| Notable changes applied by this patch: |
| 1) Makefile: Allow inheriting CC. |
| 2) Makefile: Clean up CFLAGS. |
| 3) etphid_updater.c: Fix all warnings. |
| |
| diff -Naur a/Makefile b/Makefile |
| --- a/Makefile 2019-05-01 23:08:36.000000000 -0700 |
| +++ b/Makefile 2019-08-16 00:35:04.308715080 -0700 |
| @@ -1,7 +1,8 @@ |
| #elan touchpad updater Makefile |
| -CC = gcc |
| |
| -CFLAGS += -g -Wall -fexceptions |
| +CC ?= gcc |
| + |
| +CFLAGS += -Wall -Werror |
| |
| main: etphid_updater.o |
| ${CC} ${CFLAGS} ${LDFLAGS} etphid_updater.o -o etphid_updater |
| @@ -10,5 +11,4 @@ |
| ${CC} ${CFLAGS} ${CPPFLAGS} etphid_updater.c -c |
| |
| clean: |
| - rm -rf etphid_updater.o |
| - |
| + rm -rf etphid_updater.o etphid_updater |
| diff -Naur a/etphid_updater.c b/etphid_updater.c |
| --- a/etphid_updater.c 2019-05-01 23:08:36.000000000 -0700 |
| +++ b/etphid_updater.c 2019-08-16 00:54:39.675549953 -0700 |
| @@ -216,7 +216,7 @@ |
| static int dev_fd; |
| static int bus_type = -1; |
| static int interface_type = -1; |
| -static char raw_name[255]; |
| +static char raw_name[256]; |
| static int is_new_pattern=0; |
| static int scan_i2c() |
| { |
| @@ -237,7 +237,7 @@ |
| continue; |
| } |
| |
| - char dev_name[255]; |
| + char dev_name[sizeof(LINUX_DEV_PATH) + sizeof(in_file->d_name)]; |
| sprintf(dev_name, "%s%s", (char*)LINUX_DEV_PATH,in_file->d_name); |
| if(extended_i2c_exercise) |
| printf("search i2c device name = %s\n",dev_name); |
| @@ -301,7 +301,7 @@ |
| continue; |
| } |
| |
| - char dev_name[255]; |
| + char dev_name[sizeof(LINUX_DEV_PATH) + sizeof(in_file->d_name)]; |
| sprintf(dev_name, "%s%s", (char*)LINUX_DEV_PATH,in_file->d_name); |
| |
| |
| @@ -310,7 +310,7 @@ |
| } |
| |
| /* Get Raw Name */ |
| - res = ioctl(tmp_fd, HIDIOCGRAWNAME(256), raw_name); |
| + res = ioctl(tmp_fd, HIDIOCGRAWNAME(sizeof(raw_name)), raw_name); |
| /*if (res < 0) |
| //elan_log->WriteLine((char*)"Error: HIDIOCGRAWNAME"); |
| else*/ |
| @@ -347,7 +347,7 @@ |
| } |
| static int assign_hidraw() |
| { |
| - char dev_name[255]; |
| + char dev_name[sizeof(LINUX_DEV_PATH) + sizeof(HID_RAW_NAME) + 20]; |
| sprintf(dev_name, "%s%s%d", (char*)LINUX_DEV_PATH, |
| (char*)HID_RAW_NAME, hidraw_num); |
| //printf("dev_name = %s\n", dev_name); |
| @@ -362,7 +362,7 @@ |
| } |
| static int assign_i2c() |
| { |
| - char dev_name[255]; |
| + char dev_name[sizeof(LINUX_DEV_PATH) + sizeof(I2C_NAME) + 20]; |
| sprintf(dev_name, "%s%s%d", (char*)LINUX_DEV_PATH, |
| (char*)I2C_NAME, i2c_num); |
| |