mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations
@ 2017-05-19 17:45 SF Markus Elfring
  2017-05-19 17:47 ` [PATCH 1/4] ueagle-atm: Delete error messages for failed memory allocations in two functions SF Markus Elfring
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-19 17:45 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Matthieu Castet, Stanislaw Gruszka
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 19:41:23 +0200

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

Markus Elfring (4):
  Delete error messages for failed memory allocations in two functions
  Improve a size determination in uea_bind()
  Delete unnecessary return statements in two functions
  Adjust three checks for null pointers

 drivers/usb/atm/ueagle-atm.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

-- 
2.13.0

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

* [PATCH 1/4] ueagle-atm: Delete error messages for failed memory allocations in two functions
  2017-05-19 17:45 [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations SF Markus Elfring
@ 2017-05-19 17:47 ` SF Markus Elfring
  2017-05-19 17:49 ` [PATCH 2/4] ueagle-atm: Improve a size determination in uea_bind() SF Markus Elfring
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-19 17:47 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Matthieu Castet, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 19:02:01 +0200

Omit two extra messages for memory allocation failures in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/atm/ueagle-atm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index df67815f74e6..16fd87df69e1 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -868,10 +868,8 @@ static int uea_idma_write(struct uea_softc *sc, const void *data, u32 size)
 	int bytes_read;
 
 	xfer_buff = kmemdup(data, size, GFP_KERNEL);
-	if (!xfer_buff) {
-		uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
+	if (!xfer_buff)
 		return ret;
-	}
 
 	ret = usb_bulk_msg(sc->usb_dev,
 			 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
@@ -1147,10 +1145,8 @@ static int uea_request(struct uea_softc *sc,
 	int ret = -ENOMEM;
 
 	xfer_buff = kmemdup(data, size, GFP_KERNEL);
-	if (!xfer_buff) {
-		uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
+	if (!xfer_buff)
 		return ret;
-	}
 
 	ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
 			      UCDC_SEND_ENCAPSULATED_COMMAND,
-- 
2.13.0

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

* [PATCH 2/4] ueagle-atm: Improve a size determination in uea_bind()
  2017-05-19 17:45 [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations SF Markus Elfring
  2017-05-19 17:47 ` [PATCH 1/4] ueagle-atm: Delete error messages for failed memory allocations in two functions SF Markus Elfring
@ 2017-05-19 17:49 ` SF Markus Elfring
  2017-05-19 17:50 ` [PATCH 3/4] ueagle-atm: Delete unnecessary return statements in two functions SF Markus Elfring
  2017-05-19 17:51 ` [PATCH 4/4] ueagle-atm: Adjust three checks for null pointers SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-19 17:49 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Matthieu Castet, Stanislaw Gruszka
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 19:09:28 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/atm/ueagle-atm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 16fd87df69e1..9725e6f2f301 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2551,7 +2551,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
 			return ret;
 	}
 
-	sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
+	sc = kzalloc(sizeof(*sc), GFP_KERNEL);
 	if (!sc)
 		return -ENOMEM;
 
-- 
2.13.0

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

* [PATCH 3/4] ueagle-atm: Delete unnecessary return statements in two functions
  2017-05-19 17:45 [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations SF Markus Elfring
  2017-05-19 17:47 ` [PATCH 1/4] ueagle-atm: Delete error messages for failed memory allocations in two functions SF Markus Elfring
  2017-05-19 17:49 ` [PATCH 2/4] ueagle-atm: Improve a size determination in uea_bind() SF Markus Elfring
@ 2017-05-19 17:50 ` SF Markus Elfring
  2017-05-19 17:51 ` [PATCH 4/4] ueagle-atm: Adjust three checks for null pointers SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-19 17:50 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Matthieu Castet, Stanislaw Gruszka
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 19:22:12 +0200

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/usb/atm/ueagle-atm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 9725e6f2f301..0ca4ff3e6683 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1058,7 +1058,6 @@ static void __uea_load_page_e4(struct uea_softc *sc, u8 pageno, int boot)
 
 bad:
 	uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", blockno);
-	return;
 }
 
 static void uea_load_page_e4(struct work_struct *work)
@@ -2101,7 +2100,6 @@ static void uea_dispatch_cmv_e4(struct uea_softc *sc, struct intr_pkt *intr)
 			E4_FUNCTION_TYPE(cmv->wFunction),
 			E4_FUNCTION_SUBTYPE(cmv->wFunction));
 	uea_leaves(INS_TO_USBDEV(sc));
-	return;
 }
 
 static void uea_schedule_load_page_e1(struct uea_softc *sc,
-- 
2.13.0

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

* [PATCH 4/4] ueagle-atm: Adjust three checks for null pointers
  2017-05-19 17:45 [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-05-19 17:50 ` [PATCH 3/4] ueagle-atm: Delete unnecessary return statements in two functions SF Markus Elfring
@ 2017-05-19 17:51 ` SF Markus Elfring
  3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-19 17:51 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Matthieu Castet, Stanislaw Gruszka
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 May 2017 19:29:08 +0200
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/usb/atm/ueagle-atm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 0ca4ff3e6683..5c9517bfb82c 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -955,7 +955,7 @@ static void uea_load_page_e1(struct work_struct *work)
 		sc->dsp_firm = NULL;
 	}
 
-	if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
+	if (!sc->dsp_firm && request_dsp(sc) < 0)
 		return;
 
 	p = sc->dsp_firm->data;
@@ -1076,7 +1076,7 @@ static void uea_load_page_e4(struct work_struct *work)
 		sc->dsp_firm = NULL;
 	}
 
-	if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
+	if (!sc->dsp_firm && request_dsp(sc) < 0)
 		return;
 
 	p = (struct l1_code *) sc->dsp_firm->data;
@@ -1596,7 +1596,7 @@ static void cmvs_file_name(struct uea_softc *sc, char *const cmv_name, int ver)
 
 	kernel_param_lock(THIS_MODULE);
 	/* set proper name corresponding modem version and line type */
-	if (cmv_file[sc->modem_index] == NULL) {
+	if (!cmv_file[sc->modem_index]) {
 		if (UEA_CHIP_VERSION(sc) == ADI930)
 			file_arr[3] = '9';
 		else if (UEA_CHIP_VERSION(sc) == EAGLE_IV)
-- 
2.13.0

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

end of thread, other threads:[~2017-05-19 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-19 17:45 [PATCH 0/4] ueagle-atm: Adjustments for eight function implementations SF Markus Elfring
2017-05-19 17:47 ` [PATCH 1/4] ueagle-atm: Delete error messages for failed memory allocations in two functions SF Markus Elfring
2017-05-19 17:49 ` [PATCH 2/4] ueagle-atm: Improve a size determination in uea_bind() SF Markus Elfring
2017-05-19 17:50 ` [PATCH 3/4] ueagle-atm: Delete unnecessary return statements in two functions SF Markus Elfring
2017-05-19 17:51 ` [PATCH 4/4] ueagle-atm: Adjust three 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

all inboxes | Powered by JetHome®