From 023cf626b18487b93b47fa57a14e4e3760cd75d1 Mon Sep 17 00:00:00 2001 From: Konstantin Makariev Date: Wed, 2 Oct 2019 12:58:19 -0500 Subject: [PATCH] sec_mmi: fixing compiler warnings Change-Id: Ie4a4ef9e159bec8ffd7cab86b3d6ecd34e5c4d61 Signed-off-by: Konstantin Makariev Reviewed-on: https://gerrit.mot.com/1431578 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- drivers/input/touchscreen/sec_mmi/Kbuild | 4 +- drivers/input/touchscreen/sec_mmi/sec_cmd.c | 12 +++++- drivers/input/touchscreen/sec_mmi/sec_ts_fn.c | 43 ++++++++++--------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/drivers/input/touchscreen/sec_mmi/Kbuild b/drivers/input/touchscreen/sec_mmi/Kbuild index cd84764555d0..46ebdbd70dff 100644 --- a/drivers/input/touchscreen/sec_mmi/Kbuild +++ b/drivers/input/touchscreen/sec_mmi/Kbuild @@ -1,8 +1,8 @@ # add -Wall to try to catch everything we can. -EXTRA_CFLAGS += -Wall +# EXTRA_CFLAGS += -Wall EXTRA_CFLAGS += \ -I$(TOP)/motorola/kernel/modules/include \ -I$(TOP)/motorola/kernel/modules/drivers/input/touchscreen/sec_mmi obj-m := sec_mmi.o -sec_mmi-objs = sec_ts.o sec_ts_fn.o sec_ts_fw.o sec_ts_mmi.o sec_cmd.o sec_ts_only_vendor.o \ No newline at end of file +sec_mmi-objs = sec_ts.o sec_ts_fn.o sec_ts_fw.o sec_ts_mmi.o sec_cmd.o sec_ts_only_vendor.o diff --git a/drivers/input/touchscreen/sec_mmi/sec_cmd.c b/drivers/input/touchscreen/sec_mmi/sec_cmd.c index 5608995801bc..9e7c6a9e1781 100644 --- a/drivers/input/touchscreen/sec_mmi/sec_cmd.c +++ b/drivers/input/touchscreen/sec_mmi/sec_cmd.c @@ -389,8 +389,13 @@ static ssize_t sec_cmd_list_show(struct device *dev, { struct sec_cmd_data *data = dev_get_drvdata(dev); struct sec_cmd *sec_cmd_ptr = NULL; - char buffer[data->cmd_buffer_size + 30]; + char *buffer; char buffer_name[SEC_CMD_STR_LEN]; + ssize_t len; + + buffer = kzalloc(data->cmd_buffer_size + 30, GFP_KERNEL); + if (!buffer) + return -ENOMEM; snprintf(buffer, 30, "++factory command list++\n"); @@ -401,7 +406,10 @@ static ssize_t sec_cmd_list_show(struct device *dev, } } - return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buffer); + len = snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buffer); + kfree(buffer); + + return len; } static DEVICE_ATTR(cmd, S_IWUSR | S_IWGRP, NULL, sec_cmd_store); diff --git a/drivers/input/touchscreen/sec_mmi/sec_ts_fn.c b/drivers/input/touchscreen/sec_mmi/sec_ts_fn.c index 0cd6e78c8a3c..4e40a7f12e2e 100644 --- a/drivers/input/touchscreen/sec_mmi/sec_ts_fn.c +++ b/drivers/input/touchscreen/sec_mmi/sec_ts_fn.c @@ -504,21 +504,21 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "mutual,%d,", data[0] & 0x01 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "hover,%d,", data[0] & 0x02 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "cover,%d,", data[0] & 0x04 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "glove,%d,", data[0] & 0x08 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "stylus,%d,", data[0] & 0x10 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "palm,%d,", data[0] & 0x20 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "wet,%d,", data[0] & 0x40 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "prox,%d,", data[0] & 0x80 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); memset(data, 0x00, 2); ret = ts->sec_ts_i2c_read(ts, SEC_TS_CMD_SET_POWER_MODE, data, 1); @@ -526,13 +526,13 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "npm,%d,", data[0] == 0 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "lpm,%d,", data[0] == 1 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "test,%d,", data[0] == 2 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "flash,%d,", data[0] == 3 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); memset(data, 0x00, 2); ret = ts->sec_ts_i2c_read(ts, SET_TS_CMD_SET_CHARGER_MODE, data, 1); @@ -540,11 +540,11 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "no_charge,%d,", data[0] == 0 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "wire_charge,%d,", data[0] == 1 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); snprintf(temp, sizeof(temp), "wireless_charge,%d,", data[0] == 2 ? 1 : 0); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); memset(data, 0x00, 2); ret = ts->sec_ts_i2c_read(ts, SET_TS_CMD_SET_NOISE_MODE, data, 1); @@ -552,7 +552,7 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "noise,%d,", data[0]); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); memset(data, 0x00, 2); ret = ts->sec_ts_i2c_read(ts, SEC_TS_CMD_SET_COVERTYPE, data, 1); @@ -560,7 +560,7 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "cover_type,%d,", data[0]); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); data[0] = 0; @@ -569,7 +569,7 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "dex,%d,", data[0]); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); data[0] = 0; @@ -578,7 +578,7 @@ static ssize_t ic_status_show(struct device *dev, return snprintf(buf, SEC_CMD_BUF_SIZE, "%s\n", buff); snprintf(temp, sizeof(temp), "artcanvas,%d,", data[0]); - strncat(buff, temp, sizeof(temp)); + strncat(buff, temp, strlen(temp)); input_info(true, &ts->client->dev, "%s: %s\n", __func__, buff); @@ -2592,7 +2592,8 @@ static void clear_cover_mode(void *device_data) ts->flip_enable = false; } - if (!ts->power_status == SEC_TS_STATE_POWER_OFF && ts->reinit_done) { + /* initial if condition ambiguous */ + if (!(ts->power_status == SEC_TS_STATE_POWER_OFF && ts->reinit_done)) { if (ts->flip_enable) sec_ts_set_cover_type(ts, true); else @@ -2946,7 +2947,7 @@ static void run_trx_short_test(void *device_data) strncat(pStr, pTmp, strnlen(pTmp, sizeof(pTmp))); if (ii % 8 == 4) { input_raw_info(true, &ts->client->dev, "%s\n", pStr); - strncat(buff, pStr, sizeof(pStr)); + strncat(buff, pStr, strlen(pStr)); memset(pStr, 0x00, sizeof(pStr)); } else {