Skip to content

Fix three compiler warnings in RSA.xs#185

Draft
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-compiler-warnings
Draft

Fix three compiler warnings in RSA.xs#185
toddr-bot wants to merge 1 commit into
cpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-compiler-warnings

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

Summary

  • Remove unused error variable in extractBioString() by replacing THROW with direct goto
  • Move to_length < 0 check into pre-3.x block (dead code on 3.x where to_length is size_t)
  • Fix signed/unsigned comparison in verify() between EVP_PKEY_get_size() (int) and sig_length (STRLEN)

Why

Building with -Wall -Wextra produces warnings that obscure real issues.
These three are straightforward to fix without changing behavior:

  1. -Wunused-but-set-variable: error was written by THROW but never
    read — the err handler unconditionally croaks
  2. -Wtype-limits: size_t < 0 is always false
  3. -Wsign-compare: comparing signed int with unsigned STRLEN

Four remaining -Wunused-but-set-variable warnings from the THROW macro
in 3.x-only functions (rsa_crypt, get_public_key_string, sign, verify)
are inherent to the macro pattern and left as-is.

Testing

  • Full test suite passes
  • Verified with make OPTIMIZE="-Wall -Wextra -Wno-unused-parameter":
    warnings reduced from 8 to 4

🤖 Generated with Claude Code

1. extractBioString(): replace THROW+error with direct if+goto.
   The error variable was set by THROW but never read — the err
   handler unconditionally croaks via CHECK_OPEN_SSL(0).

2. rsa_crypt(): move the to_length<0 check into the pre-3.x #else
   block where to_length is int. On 3.x, to_length is size_t
   (unsigned), making the comparison always false (dead code) and
   triggering -Wtype-limits.

3. verify(): fix signed/unsigned comparison between EVP_PKEY_get_size()
   (int) and sig_length (STRLEN/size_t). Add explicit negative check
   before casting to STRLEN for the comparison.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant