kyz/libmspack

Conflicting definitions for copy_fh

dilyanpalauzov opened this issue · 3 comments

mspack/oadb.c: contains the function copy_fh() with bytes_to_copy being of type size_t on line 38 and unsigned int on line 377. This does not work with gcc 9.2.1 20200206.

kyz commented

copy_fh is defined the same way in its prototype and its implementation: static int copy_fh(struct mspack_system *, struct mspack_file *, struct mspack_file *, size_t, unsigned char *, int)

It is called with the fourth parameter being unsigned int rather than size_t. As size_t is the same or higher rank than unsigned int, and both are unsigned, it should be promoted to size_t without warning or error.

Please supply the error output by gcc, and also supply the output of changing "gcc -c" (compile) to "gcc -E" (preprocessor output) so that the definition of size_t is revealed.

The declaration of copy_fh is on line 38 and the definition is on line 377. The declaration and definitions are not the same, gcc complains with

  CC       mspack/oabd.lo
mspack/oabd.c:375:12: error: conflicting types for ‘copy_fh’
  375 | static int copy_fh(struct mspack_system *sys, struct mspack_file *infh,
      |            ^~~~~~~
mspack/oabd.c:37:12: note: previous declaration of ‘copy_fh’ was here
   37 | static int copy_fh(struct mspack_system *sys, struct mspack_file *infh,
      |            ^~~~~~~
mspack/oabd.c:37:12: warning: ‘copy_fh’ used but never defined
mspack/oabd.c:375:12: warning: ‘copy_fh’ defined but not used [-Wunused-function]
  375 | static int copy_fh(struct mspack_system *sys, struct mspack_file *infh,
      |            ^~~~~~~
make[1]: *** [Makefile:1071: mspack/oabd.lo] Error 1
make[1]: Leaving directory '/src/mail/libmspack-1.9.1/libmspack'
make: *** [Makefile:718: all] Error 2

The preprocessed output

kyz commented

OK, you are using an outdated libmspack. This was fixed in 817f2a2 and released in libmspack v0.10.1alpha.

I believe this happened: you skipped the README on the front of the repository, went to the "releases" page and clicked whatever was first in the list. This gave you a snapshot of the repository for cabextract v1.9.1, and did not give you a snapshot of the repository for libmspack* v0.10.1alpha, which is what you need, if for some reason you don't want to go to https://www.cabextract.org.uk/libmspack/ where libmspack is actually released.

Solution: Read the README and obtain libmspack from https://www.cabextract.org.uk/libmspack/

If you are doing packaging for a distro, please ensure https://www.cabextract.org.uk/libmspack/ is where the package comes from, not a third party such as GitHub.