soc/tegra: Fix terminating condition
PATCH 1/1 soc/tegra: Fix terminating condition
Clang warns:
drivers/soc/tegra/common.c:27:16: error: address of array 'match->compatible' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
while (match->compatible) {
~~~~~ ~~~~~~~^~~~~~~~~~1 error generated.
Whoops, we have an infinite loop and QEMU no longer boots...
https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/160242918
Check that the first character of the string isn't null so that the loop properly terminates.
--- drivers/soc/tegra/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/common.c +1 -1
@@ -24,7 +24,7 @@ bool soc_is_tegra(void) {const struct of_device_id *match = tegra_machine_match; -while (match->compatible) { +while (match->compatible[0 ]) {if (of_machine_is_compatible (match->compatible))return true;
Signature · 1 line
2.20.0.rc1
Quoted 28 lines · Nathan Chancellor
Clang warns:
drivers/soc/tegra/common.c:27:16: error: address of array 'match->compatible' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]while (match->compatible) { ~~~~~ ~~~~~~~^~~~~~~~~~1 error generated.
Whoops, we have an infinite loop and QEMU no longer boots...
https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/160242918
Check that the first character of the string isn't null so that the loop properly terminates.
Fixes c57eff9503a5 ("soc/tegra: refactor soc_is_tegra()")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/soc/tegra/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/tegra/common.c +0
-0
drivers/soc/tegra/common.c bool soc_is_tegra(void) · line 27
Quoted 5 lines
drivers/soc/tegra/common.c +1
-1@@ -24,7 +24,7 @@ bool soc_is_tegra(void) {const struct of_device_id *match = tegra_machine_match; -while (match->compatible) { +while (match->compatible[0 ]) {
How about this?
while (*match->compatible) {:-)
Quoted 6 lines
drivers/soc/tegra/common.c +0
-1if (of_machine_is_compatible (match->compatible))return true; --2.20.0.rc1
Thierry Reding
AppliedQuoted 13 lines · Nathan Chancellor
Clang warns:
drivers/soc/tegra/common.c:27:16: error: address of array 'match->compatible' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]while (match->compatible) { ~~~~~ ~~~~~~~^~~~~~~~~~1 error generated.
Whoops, we have an infinite loop and QEMU no longer boots...
https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/160242918
Quoted 8 lines
Check that the first character of the string isn't null so that the loop properly terminates.
Fixes c57eff9503a5 ("soc/tegra: refactor soc_is_tegra()")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/soc/tegra/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Wow... that's what I get from not testing this properly. Apologies for the inconvenience.
Applied, thanks.
Thierry
Hi Thierry:
How about change it to this?
while (*match->compatible) {This is more beautiful. :-)
Thanks,
Yangtao
Quoted 30 lines · Thierry Reding
Quoted 13 lines · Nathan Chancellor
Clang warns:
drivers/soc/tegra/common.c:27:16: error: address of array 'match->compatible' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]while (match->compatible) { ~~~~~ ~~~~~~~^~~~~~~~~~1 error generated.
Whoops, we have an infinite loop and QEMU no longer boots...
https://travis-ci.com/ClangBuiltLinux/continuous-integration/jobs/160242918
Quoted 8 lines
Check that the first character of the string isn't null so that the loop properly terminates.
Fixes c57eff9503a5 ("soc/tegra: refactor soc_is_tegra()")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/soc/tegra/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Wow... that's what I get from not testing this properly. Apologies for the inconvenience.
Applied, thanks.
Thierry