Skip to contentSkip to conversation

soc/tegra: Fix terminating condition

PATCH Applied Nathan Chancellor 3 participants 4 messages Nov 22, 2018 Tegra architecture support

lore
Share & tools
lore
#0 lore raw

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.

Fixes c57eff9503a5 ("soc/tegra: refactor soc_is_tegra()")
---
 drivers/soc/tegra/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/common.c +1 -1
index 8a538b968fe9..54627ca957e8 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
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()")
---
 drivers/soc/tegra/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/common.c +0 -0
index 8a538b968fe9..54627ca957e8 100644

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 -1
                if (of_machine_is_compatible(match->compatible))
                        return true;
 
--

2.20.0.rc1

#2 lore raw
In reply to Nathan Chancellor
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()")
---
 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

#3 lore raw

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()")
---
 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