Skip to content

THRIFT-5941: Add Ruby ext cppcheck coverage#3387

Open
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:rb-cppcheck
Open

THRIFT-5941: Add Ruby ext cppcheck coverage#3387
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:rb-cppcheck

Conversation

@kpumuk
Copy link
Copy Markdown
Contributor

@kpumuk kpumuk commented Apr 9, 2026

Introduce cppcheck SCA for the Ruby native extension under lib/rb/ext and fix the existing findings so it can run in CI without noise.

Offenses addressed:

lib/rb/ext/compact_protocol.c:128:24: error: Shifting signed 32-bit value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
  return (n << 1) ^ (n >> 31);
                       ^
lib/rb/ext/compact_protocol.c:132:24: error: Shifting signed 64-bit value by 63 bits is undefined behaviour [shiftTooManyBitsSigned]
  return (n << 1) ^ (n >> 63);
                       ^
lib/rb/ext/compact_protocol.c:427:33: error: Signed integer overflow for expression '-(n&1)'. [integerOverflow]
  return (((uint32_t)n) >> 1) ^ -(n & 1);
                                ^
lib/rb/ext/struct.c:255:11: style: The scope of the variable 'key' can be reduced. [variableScope]
    VALUE key;
          ^
lib/rb/ext/struct.c:256:11: style: The scope of the variable 'val' can be reduced. [variableScope]
    VALUE val;
          ^
lib/rb/ext/struct.c:492:9: style: The scope of the variable 'i' can be reduced. [variableScope]
    int i;
        ^
lib/rb/ext/struct.c:531:9: style: The scope of the variable 'i' can be reduced. [variableScope]
    int i;
        ^
lib/rb/ext/struct.c:558:9: style: The scope of the variable 'i' can be reduced. [variableScope]
    int i;
        ^
lib/rb/ext/thrift_native.c:124:0: style: The function 'Init_thrift_native' is never used. [unusedFunction]
RUBY_FUNC_EXPORTED void Init_thrift_native(void) {
^
  • Did you create an Apache Jira ticket? THRIFT-5941
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
@mergeable mergeable bot added ruby github_actions Pull requests that update GitHub Actions code labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code ruby

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant