Skip to contentSkip to conversation

hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible()

PATCH In review Nathan Chancellor 2 participants 2 messages Nov 16, 2021 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (tmp401) Fix clang -Wimplicit-fallthrough in tmp401_is_visible()

Clang warns:

drivers/hwmon/tmp401.c:526:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

        default:
        ^
drivers/hwmon/tmp401.c:526:2: note: insert 'break;' to avoid fall-through
        default:
        ^
        break;

1 error generated.

Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.

---

Feel free to squash this into the offending commit.

 drivers/hwmon/tmp401.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/tmp401.c +1 -0
index f7b6a2c4fbcf..b86d9df7105d 100644
@@ -523,6 +523,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,
 		default:
 			break;
 		}
+		break;
 	default:
 		break;
 	}

base-commit: 82b520da9134a594eb9816759ed66ba6ef44888e

Signature · 1 line
2.34.0
maintainer
#1 lore raw
Quoted 18 lines · Nathan Chancellor

Clang warns:

drivers/hwmon/tmp401.c:526:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]

         default:
         ^
drivers/hwmon/tmp401.c:526:2: note: insert 'break;' to avoid fall-through
         default:
         ^
         break;

1 error generated.

Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.

Quoted 5 lines

---

Feel free to squash this into the offending commit.

Done, thanks a lot for the feedback.

Guenter

Quoted 19 lines
  drivers/hwmon/tmp401.c | 1 +
  1 file changed, 1 insertion(+)
drivers/hwmon/tmp401.c +1 -0
index f7b6a2c4fbcf..b86d9df7105d 100644
@@ -523,6 +523,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,
  		default:
  			break;
  		}
+		break;
  	default:
  		break;
  	}

base-commit: 82b520da9134a594eb9816759ed66ba6ef44888e