* [U-Boot] [PATCH] usb: gadget: dfu: discard dead code
@ 2016-05-03 2:25 Peng Fan
2016-05-03 21:29 ` Tom Rini
2016-05-06 9:12 ` Lukasz Majewski
0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2016-05-03 2:25 UTC (permalink / raw)
To: u-boot
Reported by Coverity:
Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement:
(f_dfu->strings + --i).s = ....
If calloc failed, i is still 0 and no need to call free,
so discard the dead code.
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: "?ukasz Majewski" <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
drivers/usb/gadget/f_dfu.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 7d88008..8e7c981 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -636,7 +636,7 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n)
f_dfu->strings = calloc(sizeof(struct usb_string), n + 1);
if (!f_dfu->strings)
- goto enomem;
+ return -ENOMEM;
for (i = 0; i < n; ++i) {
de = dfu_get_entity(i);
@@ -647,14 +647,6 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n)
f_dfu->strings[i].s = NULL;
return 0;
-
-enomem:
- while (i)
- f_dfu->strings[--i].s = NULL;
-
- free(f_dfu->strings);
-
- return -ENOMEM;
}
static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] usb: gadget: dfu: discard dead code
2016-05-03 2:25 [U-Boot] [PATCH] usb: gadget: dfu: discard dead code Peng Fan
@ 2016-05-03 21:29 ` Tom Rini
2016-05-06 9:12 ` Lukasz Majewski
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-05-03 21:29 UTC (permalink / raw)
To: u-boot
On Tue, May 03, 2016 at 10:25:22AM +0800, Peng Fan wrote:
> Reported by Coverity:
> Logically dead code (DEADCODE)
> dead_error_line: Execution cannot reach this statement:
> (f_dfu->strings + --i).s = ....
>
> If calloc failed, i is still 0 and no need to call free,
> so discard the dead code.
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: "?ukasz Majewski" <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160503/2817cdbb/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] usb: gadget: dfu: discard dead code
2016-05-03 2:25 [U-Boot] [PATCH] usb: gadget: dfu: discard dead code Peng Fan
2016-05-03 21:29 ` Tom Rini
@ 2016-05-06 9:12 ` Lukasz Majewski
1 sibling, 0 replies; 3+ messages in thread
From: Lukasz Majewski @ 2016-05-06 9:12 UTC (permalink / raw)
To: u-boot
Hi Peng,
> Reported by Coverity:
> Logically dead code (DEADCODE)
> dead_error_line: Execution cannot reach this statement:
> (f_dfu->strings + --i).s = ....
>
> If calloc failed, i is still 0 and no need to call free,
> so discard the dead code.
>
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: "?ukasz Majewski" <l.majewski@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
> drivers/usb/gadget/f_dfu.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
> index 7d88008..8e7c981 100644
> --- a/drivers/usb/gadget/f_dfu.c
> +++ b/drivers/usb/gadget/f_dfu.c
> @@ -636,7 +636,7 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n)
>
> f_dfu->strings = calloc(sizeof(struct usb_string), n + 1);
> if (!f_dfu->strings)
> - goto enomem;
> + return -ENOMEM;
>
> for (i = 0; i < n; ++i) {
> de = dfu_get_entity(i);
> @@ -647,14 +647,6 @@ dfu_prepare_strings(struct f_dfu *f_dfu, int n)
> f_dfu->strings[i].s = NULL;
>
> return 0;
> -
> -enomem:
> - while (i)
> - f_dfu->strings[--i].s = NULL;
> -
> - free(f_dfu->strings);
> -
> - return -ENOMEM;
> }
>
> static int dfu_prepare_function(struct f_dfu *f_dfu, int n)
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Applied to u-boot-dfu tree.
Tested-at: Odroid U3 (Exynos4412)
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-06 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 2:25 [U-Boot] [PATCH] usb: gadget: dfu: discard dead code Peng Fan
2016-05-03 21:29 ` Tom Rini
2016-05-06 9:12 ` Lukasz Majewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox