* [PATCH] can: softing: Remove redundant variable ptr
@ 2021-04-26 10:08 Jiapeng Chong
2021-04-26 12:24 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-04-26 10:08 UTC (permalink / raw)
To: wg; +Cc: mkl, davem, kuba, linux-can, netdev, linux-kernel, Jiapeng Chong
Variable ptr is being assigned a value from a calculation
however the variable is never read, so this redundant variable
can be removed.
Cleans up the following clang-analyzer warning:
drivers/net/can/softing/softing_main.c:279:3: warning: Value stored to
'ptr' is never read [clang-analyzer-deadcode.DeadStores].
drivers/net/can/softing/softing_main.c:242:3: warning: Value stored to
'ptr' is never read [clang-analyzer-deadcode.DeadStores].
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
drivers/net/can/softing/softing_main.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
index c44f341..cfc1325 100644
--- a/drivers/net/can/softing/softing_main.c
+++ b/drivers/net/can/softing/softing_main.c
@@ -239,7 +239,6 @@ static int softing_handle_1(struct softing *card)
DPRAM_INFO_BUSSTATE2 : DPRAM_INFO_BUSSTATE]);
/* timestamp */
tmp_u32 = le32_to_cpup((void *)ptr);
- ptr += 4;
ktime = softing_raw2ktime(card, tmp_u32);
++netdev->stats.rx_errors;
@@ -276,7 +275,6 @@ static int softing_handle_1(struct softing *card)
ktime = softing_raw2ktime(card, tmp_u32);
if (!(msg.can_id & CAN_RTR_FLAG))
memcpy(&msg.data[0], ptr, 8);
- ptr += 8;
/* update socket */
if (cmd & CMD_ACK) {
/* acknowledge, was tx msg */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: softing: Remove redundant variable ptr
2021-04-26 10:08 [PATCH] can: softing: Remove redundant variable ptr Jiapeng Chong
@ 2021-04-26 12:24 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2021-04-26 12:24 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: wg, davem, kuba, linux-can, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2241 bytes --]
On 26.04.2021 18:08:16, Jiapeng Chong wrote:
> Variable ptr is being assigned a value from a calculation
> however the variable is never read,
^^^^^^^^^^^^^
This is not 100% correct.
The variable ptr is read from, see a line directly above the line this
patch removes.
> so this redundant variable can be removed.
This patch doesn't remove the variable.
> Cleans up the following clang-analyzer warning:
>
> drivers/net/can/softing/softing_main.c:279:3: warning: Value stored to
> 'ptr' is never read [clang-analyzer-deadcode.DeadStores].
>
> drivers/net/can/softing/softing_main.c:242:3: warning: Value stored to
> 'ptr' is never read [clang-analyzer-deadcode.DeadStores].
The clang warning is more precise: the value stored to ptr in the
calculations this patch removes is not used, so the calculation and the
assignment can be removed.
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/net/can/softing/softing_main.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
> index c44f341..cfc1325 100644
> --- a/drivers/net/can/softing/softing_main.c
> +++ b/drivers/net/can/softing/softing_main.c
> @@ -239,7 +239,6 @@ static int softing_handle_1(struct softing *card)
> DPRAM_INFO_BUSSTATE2 : DPRAM_INFO_BUSSTATE]);
> /* timestamp */
> tmp_u32 = le32_to_cpup((void *)ptr);
> - ptr += 4;
> ktime = softing_raw2ktime(card, tmp_u32);
>
> ++netdev->stats.rx_errors;
> @@ -276,7 +275,6 @@ static int softing_handle_1(struct softing *card)
> ktime = softing_raw2ktime(card, tmp_u32);
> if (!(msg.can_id & CAN_RTR_FLAG))
> memcpy(&msg.data[0], ptr, 8);
> - ptr += 8;
> /* update socket */
> if (cmd & CMD_ACK) {
> /* acknowledge, was tx msg */
> --
> 1.8.3.1
>
>
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-26 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 10:08 [PATCH] can: softing: Remove redundant variable ptr Jiapeng Chong
2021-04-26 12:24 ` Marc Kleine-Budde
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).