linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Input-cyttsp4_core: Adjustments for some function implementations
@ 2018-01-21 20:26 SF Markus Elfring
  2018-01-21 20:27 ` [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-21 20:26 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:23:45 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Delete two error messages for a failed memory allocation in cyttsp4_probe()
  Delete an unnecessary return statement in three functions
  Adjust 13 checks for null pointers

 drivers/input/touchscreen/cyttsp4_core.c | 33 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

-- 
2.16.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe()
  2018-01-21 20:26 [PATCH 0/3] Input-cyttsp4_core: Adjustments for some function implementations SF Markus Elfring
@ 2018-01-21 20:27 ` SF Markus Elfring
  2018-01-21 20:29 ` [PATCH 2/3] Input: cyttsp4_core: Delete an unnecessary return statement in three functions SF Markus Elfring
  2018-01-21 20:30 ` [PATCH 3/3] Input: cyttsp4_core: Adjust 13 checks for null pointers SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-21 20:27 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 20:57:40 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 727c3232517c..f0bf3cc20e9d 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -2037,14 +2037,12 @@ struct cyttsp4 *cyttsp4_probe(const struct cyttsp4_bus_ops *ops,
 
 	cd = kzalloc(sizeof(*cd), GFP_KERNEL);
 	if (!cd) {
-		dev_err(dev, "%s: Error, kzalloc\n", __func__);
 		rc = -ENOMEM;
 		goto error_alloc_data;
 	}
 
 	cd->xfer_buf = kzalloc(xfer_buf_size, GFP_KERNEL);
 	if (!cd->xfer_buf) {
-		dev_err(dev, "%s: Error, kzalloc\n", __func__);
 		rc = -ENOMEM;
 		goto error_free_cd;
 	}
-- 
2.16.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] Input: cyttsp4_core: Delete an unnecessary return statement in three functions
  2018-01-21 20:26 [PATCH 0/3] Input-cyttsp4_core: Adjustments for some function implementations SF Markus Elfring
  2018-01-21 20:27 ` [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe() SF Markus Elfring
@ 2018-01-21 20:29 ` SF Markus Elfring
  2018-01-21 20:30 ` [PATCH 3/3] Input: cyttsp4_core: Adjust 13 checks for null pointers SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-21 20:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:13:21 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in the affected functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index f0bf3cc20e9d..35f48b66ff36 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -956,8 +956,6 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch)
 	cyttsp4_final_sync(md->input, si->si_ofs.tch_abs[CY_TCH_T].max, ids);
 
 	md->num_prv_tch = num_cur_tch;
-
-	return;
 }
 
 /* read xy_data for all current touches */
@@ -1272,8 +1270,6 @@ static void cyttsp4_watchdog_timer(struct timer_list *t)
 	dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__);
 
 	schedule_work(&cd->watchdog_work);
-
-	return;
 }
 
 static int cyttsp4_request_exclusive(struct cyttsp4 *cd, void *ownptr,
@@ -1492,7 +1488,6 @@ static void cyttsp4_watchdog_work(struct work_struct *work)
 	cyttsp4_start_wd_timer(cd);
 cyttsp4_timer_watchdog_exit_error:
 	mutex_unlock(&cd->system_lock);
-	return;
 }
 
 static int cyttsp4_core_sleep_(struct cyttsp4 *cd)
-- 
2.16.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] Input: cyttsp4_core: Adjust 13 checks for null pointers
  2018-01-21 20:26 [PATCH 0/3] Input-cyttsp4_core: Adjustments for some function implementations SF Markus Elfring
  2018-01-21 20:27 ` [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe() SF Markus Elfring
  2018-01-21 20:29 ` [PATCH 2/3] Input: cyttsp4_core: Delete an unnecessary return statement in three functions SF Markus Elfring
@ 2018-01-21 20:30 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2018-01-21 20:30 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Ferruh Yigit; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Jan 2018 21:15:11 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/touchscreen/cyttsp4_core.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 35f48b66ff36..32a4a45554fe 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -213,7 +213,7 @@ static int cyttsp4_si_get_cydata(struct cyttsp4 *cd)
 			si->si_ofs.cydata_size);
 
 	p = krealloc(si->si_ptrs.cydata, si->si_ofs.cydata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate cydata memory\n",
 			__func__);
 		return -ENOMEM;
@@ -288,7 +288,7 @@ static int cyttsp4_si_get_test_data(struct cyttsp4 *cd)
 	si->si_ofs.test_size = si->si_ofs.pcfg_ofs - si->si_ofs.test_ofs;
 
 	p = krealloc(si->si_ptrs.test, si->si_ofs.test_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate test memory\n",
 			__func__);
 		return -ENOMEM;
@@ -347,7 +347,7 @@ static int cyttsp4_si_get_pcfg_data(struct cyttsp4 *cd)
 	si->si_ofs.pcfg_size = si->si_ofs.opcfg_ofs - si->si_ofs.pcfg_ofs;
 
 	p = krealloc(si->si_ptrs.pcfg, si->si_ofs.pcfg_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate pcfg memory\n",
 			__func__);
 		return -ENOMEM;
@@ -399,7 +399,7 @@ static int cyttsp4_si_get_opcfg_data(struct cyttsp4 *cd)
 	si->si_ofs.opcfg_size = si->si_ofs.ddata_ofs - si->si_ofs.opcfg_ofs;
 
 	p = krealloc(si->si_ptrs.opcfg, si->si_ofs.opcfg_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: failed to allocate opcfg memory\n",
 			__func__);
 		return -ENOMEM;
@@ -488,7 +488,7 @@ static int cyttsp4_si_get_ddata(struct cyttsp4 *cd)
 	si->si_ofs.ddata_size = si->si_ofs.mdata_ofs - si->si_ofs.ddata_ofs;
 
 	p = krealloc(si->si_ptrs.ddata, si->si_ofs.ddata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: fail alloc ddata memory\n", __func__);
 		return -ENOMEM;
 	}
@@ -515,7 +515,7 @@ static int cyttsp4_si_get_mdata(struct cyttsp4 *cd)
 	si->si_ofs.mdata_size = si->si_ofs.map_sz - si->si_ofs.mdata_ofs;
 
 	p = krealloc(si->si_ptrs.mdata, si->si_ofs.mdata_size, GFP_KERNEL);
-	if (p == NULL) {
+	if (!p) {
 		dev_err(cd->dev, "%s: fail alloc mdata memory\n", __func__);
 		return -ENOMEM;
 	}
@@ -548,16 +548,16 @@ static int cyttsp4_si_get_btn_data(struct cyttsp4 *cd)
 
 		p = krealloc(si->btn, si->si_ofs.btn_keys_size,
 				GFP_KERNEL|__GFP_ZERO);
-		if (p == NULL) {
+		if (!p) {
 			dev_err(cd->dev, "%s: %s\n", __func__,
 				"fail alloc btn_keys memory");
 			return -ENOMEM;
 		}
 		si->btn = p;
 
-		if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS] == NULL)
+		if (!cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS])
 			num_defined_keys = 0;
-		else if (cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS]->data == NULL)
+		else if (!cd->cpdata->sett[CY_IC_GRPNUM_BTN_KEYS]->data)
 			num_defined_keys = 0;
 		else
 			num_defined_keys = cd->cpdata->sett
@@ -592,19 +592,19 @@ static int cyttsp4_si_get_op_data_ptrs(struct cyttsp4 *cd)
 	void *p;
 
 	p = krealloc(si->xy_mode, si->si_ofs.mode_size, GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->xy_mode = p;
 
 	p = krealloc(si->xy_data, si->si_ofs.data_size, GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->xy_data = p;
 
 	p = krealloc(si->btn_rec_data,
 			si->si_ofs.btn_rec_size * si->si_ofs.num_btns,
 			GFP_KERNEL|__GFP_ZERO);
-	if (p == NULL)
+	if (!p)
 		return -ENOMEM;
 	si->btn_rec_data = p;
 
@@ -1977,7 +1977,7 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd)
 	dev_vdbg(dev, "%s: Create the input device and register it\n",
 		__func__);
 	md->input = input_allocate_device();
-	if (md->input == NULL) {
+	if (!md->input) {
 		dev_err(dev, "%s: Error, failed to allocate input device\n",
 			__func__);
 		rc = -ENOSYS;
-- 
2.16.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-21 20:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-21 20:26 [PATCH 0/3] Input-cyttsp4_core: Adjustments for some function implementations SF Markus Elfring
2018-01-21 20:27 ` [PATCH 1/3] Input: cyttsp4_core: Delete two error messages for a failed memory allocation in cyttsp4_probe() SF Markus Elfring
2018-01-21 20:29 ` [PATCH 2/3] Input: cyttsp4_core: Delete an unnecessary return statement in three functions SF Markus Elfring
2018-01-21 20:30 ` [PATCH 3/3] Input: cyttsp4_core: Adjust 13 checks for null pointers SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).