rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

sha1.c warnings due to inconsistent USE_64_BIT_INT #12

Closed puetzk closed 5 years ago

puetzk commented 5 years ago

The logic in https://github.com/rschupp/PAR-Packer/blob/5a98e29745d4f6dcae748787fcd0d47db77c76e9/myldr/sha1.c.PL#L33-L36 seems incorrect (or at least incomplete):

If perl.h has not been included, this defaults to BYTEORDER 0x12345678, which implies a 64-bit swap operation down at https://github.com/rschupp/PAR-Packer/blob/5a98e29745d4f6dcae748787fcd0d47db77c76e9/myldr/sha1.c.PL#L154-L166

However, since it does not define U64TYPE or USE_64_BIT_INT, PAR_ULONG is only a 32-bit type: https://github.com/rschupp/PAR-Packer/blob/5a98e29745d4f6dcae748787fcd0d47db77c76e9/myldr/sha1.c.PL#L51

When building on windows-x86 using strawberryperl 5.28.1, this shows up a warning from gcc

sha1.c:153:4: warning: right shift count >= width of type [-Wshift-count-overflow] T >>= 32;

But it seems like the real issue isn't really on that line, but up here where BYTEORDER and PAR_ULONG got out of sync. There's a lot of ways this could get fixed, but it seems like the simplest and probably best would be to just #include "config.h" in boot.c before it brings in mktemp.c, so this and main.c would be consistent about which types are used.

puetzk commented 5 years ago

caveat: I'm not terribly familar with how the perl headers are laid out, so maybe there's something you should bring in that in turn brings in config.h...

rschupp commented 5 years ago

Thanks for spotting! Can you test with HEAD?