soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb
Subsystems (2)
PATCH 1/1 soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb
Clang warns:
../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
list_for_each_entry(pds, &pdr->lookups, node) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/list.h:624:7: note: expanded from macro
'list_for_each_entry'
&pos->member != (head);
^~~~~~~~~~~~~~~~~~~~~~
../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use
occurs here
if (!found)
^~~~~
../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if
it is always true
list_for_each_entry(pds, &pdr->lookups, node) {
^
../include/linux/list.h:624:7: note: expanded from macro
'list_for_each_entry'
&pos->member != (head);
^
../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the
variable 'found' to silence this warning
bool found;
^
= 01 warning generated.
Initialize found to false to fix this warning.
--- drivers/soc/qcom/pdr_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pdr_interface.c +1 -1
@@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,const struct servreg_state_updated_ind *ind_msg = data;struct pdr_list_node *ind;struct pdr_service *pds; -bool found; +bool found = false;if (!ind_msg || !ind_msg->service_path[0 ] ||strlen (ind_msg->service_path) >SERVREG_NAME_LENGTH )
Signature · 1 line
2.26.0.rc1
Quoted 29 lines · Nathan Chancellor
Clang warns:
../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]list_for_each_entry(pds, &pdr->lookups, node) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/linux/list.h:624:7: note: expanded from macro 'list_for_each_entry' &pos->member != (head); ^~~~~~~~~~~~~~~~~~~~~~ ../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use occurs here if (!found) ^~~~~ ../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if it is always true list_for_each_entry(pds, &pdr->lookups, node) { ^ ../include/linux/list.h:624:7: note: expanded from macro 'list_for_each_entry' &pos->member != (head); ^ ../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the variable 'found' to silence this warning bool found; ^ = 0
Quoted 7 lines
1 warning generated.
Initialize found to false to fix this warning.
Fixes fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")Signed-off-by Nathan Chancellor <[email protected]>
Yep, thanks for the patch!
Quoted 24 lines
--- drivers/soc/qcom/pdr_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/qcom/pdr_interface.c +1
-2@@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,const struct servreg_state_updated_ind *ind_msg = data;struct pdr_list_node *ind;struct pdr_service *pds; -bool found; +bool found = false;if (!ind_msg || !ind_msg->service_path[0 ] ||strlen (ind_msg->service_path) >SERVREG_NAME_LENGTH ) --2.26.0.rc1
--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200316204855.15611-1-natechancellor%40gmail.com.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 28 lines · Nathan Chancellor
Clang warns:
../drivers/soc/qcom/pdr_interface.c:316:2: warning: variable 'found' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]list_for_each_entry(pds, &pdr->lookups, node) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/linux/list.h:624:7: note: expanded from macro 'list_for_each_entry' &pos->member != (head); ^~~~~~~~~~~~~~~~~~~~~~ ../drivers/soc/qcom/pdr_interface.c:325:7: note: uninitialized use occurs here if (!found) ^~~~~ ../drivers/soc/qcom/pdr_interface.c:316:2: note: remove the condition if it is always true list_for_each_entry(pds, &pdr->lookups, node) { ^ ../include/linux/list.h:624:7: note: expanded from macro 'list_for_each_entry' &pos->member != (head); ^ ../drivers/soc/qcom/pdr_interface.c:309:12: note: initialize the variable 'found' to silence this warning bool found; ^ = 0
Quoted 7 lines
1 warning generated.
Initialize found to false to fix this warning.
Fixes fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")Signed-off-by Nathan Chancellor <[email protected]>
Thanks Nathan, applied with Nick's ack.
Regards,
Bjorn
Quoted 20 lines
--- drivers/soc/qcom/pdr_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/qcom/pdr_interface.c +1
-1@@ -306,7 +306,7 @@ static void pdr_indication_cb(struct qmi_handle *qmi,const struct servreg_state_updated_ind *ind_msg = data;struct pdr_list_node *ind;struct pdr_service *pds; -bool found; +bool found = false;if (!ind_msg || !ind_msg->service_path[0 ] ||strlen (ind_msg->service_path) >SERVREG_NAME_LENGTH )Signature · 1 line
2.26.0.rc1