Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode warning on result = iconv in mz_os_posix.c #386

Closed
Coeur opened this issue May 1, 2019 · 2 comments
Closed

Xcode warning on result = iconv in mz_os_posix.c #386

Coeur opened this issue May 1, 2019 · 2 comments
Labels
compilation Issues related to compiling source code fixed Issue or bug has been fixed

Comments

@Coeur
Copy link
Contributor

Coeur commented May 1, 2019

I'm in the process of migrating minizip 1.2 to 2.8.6 on Apple platforms, using 'HAVE_ARC4RANDOM_BUF HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB' and including libs z and iconv, as seen on the temporary branch https://github.com/ZipArchive/ZipArchive/tree/minizip286.

Now, using iconv is new (compared to minizip 1.2), and its signature on Apple platforms is:

extern __LIBICONV_DLL_EXPORTED size_t iconv (iconv_t __cd, char* * __restrict __inbuf, size_t * __restrict __inbytesleft, char* * __restrict __outbuf, size_t * __restrict __outbytesleft);

Where size_t is an unsigned long, so it produces that warning:

mz_os_posix.c:73:18: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int32_t' (aka 'int')

I'm also a bit surprised that you're going to compare an unsigned long casted to an int with the value -1 a few lines below. So there may be something to change here.
Screen Shot 2019-05-01 at 1 30 16 PM

@nmoinvaz
Copy link
Member

nmoinvaz commented May 1, 2019

From the linux manpages:

The iconv() function returns the number of characters converted in a
nonreversible way during this call; reversible conversions are not
counted. In case of error, it sets errno and returns (size_t) -1.

http://man7.org/linux/man-pages/man3/iconv.3.html

Probably we need to cast -1 to size_t when comparing.

nmoinvaz added a commit that referenced this issue May 1, 2019
@nmoinvaz
Copy link
Member

nmoinvaz commented May 1, 2019

Ok that should fix it, let me know if it doesn't. Thanks for reporting it.

@nmoinvaz nmoinvaz closed this as completed May 1, 2019
@nmoinvaz nmoinvaz added 2.0 compilation Issues related to compiling source code fixed Issue or bug has been fixed labels May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation Issues related to compiling source code fixed Issue or bug has been fixed
Projects
None yet
Development

No branches or pull requests

2 participants