* [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB
@ 2019-08-10 4:49 Nathan Chancellor
2019-08-12 10:32 ` Sudeep Holla
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2019-08-10 4:49 UTC (permalink / raw)
To: Sudeep Holla
Cc: linux-arm-kernel, linux-kernel, clang-built-linux, Nathan Chancellor
clang warns four times:
drivers/firmware/arm_scmi/perf.c:320:24: warning: variable 'db' is
uninitialized when used within its own initialization [-Wuninitialized]
SCMI_PERF_FC_RING_DB(db, 64);
~~~~~~~~~~~~~~~~~~~~~^~~~~~~
drivers/firmware/arm_scmi/perf.c:300:31: note: expanded from macro
'SCMI_PERF_FC_RING_DB'
struct scmi_fc_db_info *db = doorbell; \
~~ ^~~~~~~~
This happens because the doorbell identifier becomes db after
preprocessing:
if (db->width == 1)
do {
u8 val = 0;
struct scmi_fc_db_info *db = db;
if (db->mask)
val = ioread8(db->addr) & db->mask;
iowrite8((u8)db->set | val, db->addr);
} while (0);
We could swap the doorbell and db identifiers within the macro and that
would resolve the issue; however, there doesn't appear to be a good
reason for having two copies of the same variable. Eliminate the one in
the do while loop to prevent this warning and make the code clearer.
Fixes: 8f12cbcb6abc ("firmware: arm_scmi: Make use SCMI v2.0 fastchannel for performance protocol")
Link: https://github.com/ClangBuiltLinux/linux/issues/635
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/firmware/arm_scmi/perf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 2c5201c8354c..ab946ef6b914 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -294,10 +294,9 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
return ret;
}
-#define SCMI_PERF_FC_RING_DB(doorbell, w) \
+#define SCMI_PERF_FC_RING_DB(db, w) \
do { \
u##w val = 0; \
- struct scmi_fc_db_info *db = doorbell; \
\
if (db->mask) \
val = ioread##w(db->addr) & db->mask; \
--
2.23.0.rc2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB
2019-08-10 4:49 [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB Nathan Chancellor
@ 2019-08-12 10:32 ` Sudeep Holla
0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2019-08-12 10:32 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: linux-arm-kernel, linux-kernel, clang-built-linux
On Fri, Aug 09, 2019 at 09:49:10PM -0700, Nathan Chancellor wrote:
> clang warns four times:
>
> drivers/firmware/arm_scmi/perf.c:320:24: warning: variable 'db' is
> uninitialized when used within its own initialization [-Wuninitialized]
> SCMI_PERF_FC_RING_DB(db, 64);
> ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
> drivers/firmware/arm_scmi/perf.c:300:31: note: expanded from macro
> 'SCMI_PERF_FC_RING_DB'
> struct scmi_fc_db_info *db = doorbell; \
> ~~ ^~~~~~~~
>
> This happens because the doorbell identifier becomes db after
> preprocessing:
>
> if (db->width == 1)
> do {
> u8 val = 0;
> struct scmi_fc_db_info *db = db;
> if (db->mask)
> val = ioread8(db->addr) & db->mask;
> iowrite8((u8)db->set | val, db->addr);
> } while (0);
>
> We could swap the doorbell and db identifiers within the macro and that
> would resolve the issue; however, there doesn't appear to be a good
> reason for having two copies of the same variable. Eliminate the one in
> the do while loop to prevent this warning and make the code clearer.
>
I originally had exactly what we will after this patch applied. I think
one of the tool complained about argument 'db' reused in the macro
might have possible side-effects. That's the reason I moved it. I will
dig it up and fold this in the original patch as before.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-12 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10 4:49 [PATCH] firmware: arm_scmi: Eliminate local db variable in SCMI_PERF_FC_RING_DB Nathan Chancellor
2019-08-12 10:32 ` Sudeep Holla
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).