nghttp2 icon indicating copy to clipboard operation
nghttp2 copied to clipboard

chore: fix -Wimplicit-fallthrough

Open codebytere opened this issue 4 years ago • 1 comments

Fixes -Wimplicit-fallthrough clang compilation errors encountered when building Electron and pulling in nghttp2 as a dependency via Node.js.

../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:1895:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case NGHTTP2_HD_STATE_INFLATE_START:
    ^
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:1895:5: note: insert '__attribute__((fallthrough));' to silence this warning
    case NGHTTP2_HD_STATE_INFLATE_START:
    ^
    __attribute__((fallthrough));
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:1895:5: note: insert 'break;' to avoid fall-through
    case NGHTTP2_HD_STATE_INFLATE_START:
    ^
    break;
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2005:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN:
    ^
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2005:5: note: insert '__attribute__((fallthrough));' to silence this warning
    case NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN:
    ^
    __attribute__((fallthrough));
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2005:5: note: insert 'break;' to avoid fall-through
    case NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN:
    ^
    break;
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2089:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case NGHTTP2_HD_STATE_READ_VALUELEN:
    ^
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2089:5: note: insert '__attribute__((fallthrough));' to silence this warning
    case NGHTTP2_HD_STATE_READ_VALUELEN:
    ^
    __attribute__((fallthrough));
../../third_party/electron_node/deps/nghttp2/lib/nghttp2_hd.c:2089:5: note: insert 'break;' to avoid fall-through
    case NGHTTP2_HD_STATE_READ_VALUELEN:
    ^
    break;
3 errors generated.
[2/24] CC obj/third_party/electron_node/deps/nghttp2/nghttp2/nghttp2_session.o
ninja: build stopped: subcommand failed.
ERROR Error: Command failed: ninja -j 200 electron
    at checkExecSyncError (node:child_process:707:11)
    at Object.execFileSync (node:child_process:726:15)
    at Object.depotExecFileSync [as execFileSync] (/Users/codebytere/build-tools/src/utils/depot-tools.js:119:16)
    at runNinja (/Users/codebytere/build-tools/src/e-build.js:84:9)
    at Object.<anonymous> (/Users/codebytere/build-tools/src/e-build.js:142:3)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)

which is fixed by adding the explicit fallthrough attribute. Please let me know if you all would prefer a different solution to this issue!

codebytere avatar Oct 11 '21 11:10 codebytere

Hmm - looks like this fails here (though not in our CI) - i'll keep looking 🤔

codebytere avatar Oct 11 '21 11:10 codebytere