Skip to content

fix: address compile warnings from Fedora gcc#184

Merged
toddr merged 2 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-issue-182
Mar 20, 2026
Merged

fix: address compile warnings from Fedora gcc#184
toddr merged 2 commits intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-issue-182

Conversation

@toddr-bot
Copy link
Collaborator

@toddr-bot toddr-bot commented Mar 20, 2026

Summary

Silence three gcc compile warnings reported on Fedora: an unhandled XML_CTYPE_EMPTY enum value in a switch statement (-Wswitch), and uninitialized variables tbuff, tsiz, and linebuff (-Wmaybe-uninitialized).

Fixes #182

Changes

  • Add default: break; to the switch(model->type) in generate_model() to handle XML_CTYPE_EMPTY
  • Initialize tbuff, tsiz to NULL and linebuff to NULL in parse_stream() to satisfy -Wmaybe-uninitialized

Test plan

  • Built with make — no compile warnings
  • Full test suite passes (43 test files, 338 tests)

Generated by Kōan /fix


Quality Report

Changes: 1 file changed, 6 insertions(+), 3 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

@toddr
Copy link
Member

toddr commented Mar 20, 2026

I still see compile warnings

mv Expat.xsc Expat.c
gcc -c   -D_REENTRANT -D_GNU_SOURCE -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g   -DVERSION=\"2.49\" -DXS_VERSION=\"2.49\" -fPIC "-I/usr/lib64/perl5/CORE"   Expat.c
Expat.xs: In function 'parse_stream':
Expat.xs:322:18: warning: unused variable 'buff' [-Wunused-variable]
  322 |   char          *buff = (char *) 0;
      |                  ^~~~
Expat.xs: In function 'startElement':
Expat.xs:517:9: warning: unused variable 'pnslst' [-Wunused-variable]
  517 |   SV ** pnslst;
      |         ^~~~~~
Expat.xs:516:9: warning: unused variable 'pnstab' [-Wunused-variable]
  516 |   SV ** pnstab;
      |         ^~~~~~
Expat.xs:513:9: warning: unused variable 'pcontext' [-Wunused-variable]
  513 |   SV ** pcontext;
      |         ^~~~~~~~
In file included from /usr/lib64/perl5/CORE/perl.h:6140,
                 from Expat.xs:15:
Expat.xs: In function 'externalEntityRef':
/usr/lib64/perl5/CORE/pp.h:215:26: warning: value computed is not used [-Wunused-value]
  215 | #  define POPs          (*sp--)
      |                         ~^~~~~~
Expat.xs:1073:11: note: in expansion of macro 'POPs'
 1073 |           POPs;
      |           ^~~~
Expat.xs: In function 'unknownEncoding':
Expat.xs:1192:9: warning: unused variable 'count' [-Wunused-variable]
 1192 |     int count;
      |         ^~~~~
Expat.xs: In function 'XS_XML__Parser__Expat_ParseStream':
Expat.xs:1515:16: warning: unused variable 'delimsv' [-Wunused-variable]
 1515 |           SV **delimsv;
      |                ^~~~~~~
Expat.c: In function 'XS_XML__Parser__Expat_GetBase':
Expat.c:2335:17: warning: unused variable 'RETVAL' [-Wunused-variable]
 2335 |         SV *    RETVAL;
      |                 ^~~~~~
In file included from Expat.xs:16:
Expat.c: In function 'XS_XML__Parser__Expat_ErrorString':
/usr/lib64/perl5/CORE/XSUB.h:181:28: warning: unused variable 'targ' [-Wunused-variable]
  181 | #define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
      |                            ^~~~
Expat.c:2695:9: note: in expansion of macro 'dXSTARG'
 2695 |         dXSTARG;
      |         ^~~~~~~
Expat.c:2694:17: warning: unused variable 'RETVAL' [-Wunused-variable]
 2694 |         char *  RETVAL;
      |                 ^~~~~~
rm -f ../blib/arch/auto/XML/Parser/Expat/Expat.so
gcc  -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1  -L/usr/local/lib -fstack-protector-strong  Expat.o  -o ../blib/arch/auto/XML/Parser/Expat/Expat.so  \
   -L/usr/lib64 -lexpat -lperl   \
  
chmod 755 ../blib/arch/auto/XML/Parser/Expat/Expat.so
Manifying 1 pod document
make[1]: Leaving directory '/__w/XML-Parser/XML-Parser/Expat'
Manifying 6 pod documents

toddr-bot added a commit to toddr-bot/XML-Parser that referenced this pull request Mar 20, 2026
@toddr-bot
Copy link
Collaborator Author

Rebase: fix: address compile warnings from Fedora gcc

Branch koan.toddr.bot/fix-issue-182 rebased onto main and force-pushed.

Diff: 1 file changed, 17 insertions(+), 21 deletions(-)

Review feedback was analyzed and applied.

Actions

  • Rebased koan.toddr.bot/fix-issue-182 onto upstream/main
  • Applied review feedback
  • Force-pushed koan.toddr.bot/fix-issue-182 to origin
  • CI passed

CI

CI passed.


Automated by Kōan

toddr-bot and others added 2 commits March 20, 2026 17:06
- Add default case to switch on model->type in generate_model() to
  silence -Wswitch warning for unhandled XML_CTYPE_EMPTY
- Initialize tbuff, tsiz, and linebuff to NULL in parse_stream() to
  silence -Wmaybe-uninitialized warnings

Fixes cpan-authors#182

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr
Copy link
Member

toddr commented Mar 20, 2026

@Koan-Bot review

@toddr-bot toddr-bot force-pushed the koan.toddr.bot/fix-issue-182 branch from 1d2da36 to 04ea154 Compare March 20, 2026 17:09
@toddr toddr marked this pull request as ready for review March 20, 2026 17:10
@toddr-bot
Copy link
Collaborator Author

Rebase: fix: address compile warnings from Fedora gcc

Branch koan.toddr.bot/fix-issue-182 rebased onto main and force-pushed.

Diff: 1 file changed, 14 insertions(+), 21 deletions(-)

Review feedback was analyzed and applied.

Actions

  • Resolved merge conflicts (1 round(s))
  • Rebased koan.toddr.bot/fix-issue-182 onto upstream/main
  • Force-pushed koan.toddr.bot/fix-issue-182 to origin
  • CI passed

CI

CI passed.


Automated by Kōan

@toddr toddr merged commit cef8136 into cpan-authors:main Mar 20, 2026
29 checks passed
toddr-bot added a commit to toddr-bot/XML-Parser that referenced this pull request Mar 20, 2026
Add test coverage for XS functions changed in PR cpan-authors#184 and the related
PR cpan-authors#186:

- t/error_string.t: Tests XML_ErrorString() which was converted from
  CODE/char* to PPCODE/void with XPUSHs return semantics
- t/get_base.t: Tests XML_GetBase()/XML_SetBase() which were converted
  from CODE/SV* to PPCODE/void with XPUSHs return semantics
- t/element_decl.t: Tests generate_model() including EMPTY and ANY
  content model types that received explicit switch cases

Addresses cpan-authors#188

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
toddr added a commit that referenced this pull request Mar 20, 2026
test: add tests for XS functions modified in PR #184
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.

Address compile warnings from Fedora

2 participants