Fix signedness warnings (-Wsign-conversion, gcc)
diff --git a/lib/zip_source_filep.c b/lib/zip_source_filep.c index c448171..4987f62 100644 --- a/lib/zip_source_filep.c +++ b/lib/zip_source_filep.c
@@ -185,7 +185,7 @@ if (S_ISREG(sb.st_mode)) { ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; - if (ctx->start + ctx->end > sb.st_size) { + if (ctx->start + ctx->end > (zip_uint64_t)sb.st_size) { zip_error_set(error, ZIP_ER_INVAL, 0); free(ctx->fname); free(ctx); @@ -193,7 +193,7 @@ } if (ctx->end == 0) { - ctx->st.size = sb.st_size - ctx->start; + ctx->st.size = (zip_uint64_t)sb.st_size - ctx->start; ctx->st.valid |= ZIP_STAT_SIZE; if (start == 0) {
diff --git a/lib/zip_source_read.c b/lib/zip_source_read.c index 88edd65..28c0834 100644 --- a/lib/zip_source_read.c +++ b/lib/zip_source_read.c
@@ -64,7 +64,7 @@ return -1; } else { - return bytes_read; + return (zip_int64_t)bytes_read; } }
diff --git a/lib/zip_source_winzip_aes_decode.c b/lib/zip_source_winzip_aes_decode.c index 9c8cc3f..54f695f 100644 --- a/lib/zip_source_winzip_aes_decode.c +++ b/lib/zip_source_winzip_aes_decode.c
@@ -42,7 +42,7 @@ #define MAX_HEADER_LENGTH (16+PWD_VER_LENGTH) #define HMAC_LENGTH 10 -static int salt_length[] = { 0, 8, 12, 16 }; +static unsigned int salt_length[] = { 0, 8, 12, 16 }; struct winzip_aes { char *password; @@ -139,7 +139,7 @@ return -1; } - if (_zip_fcrypt_init(ctx->mode, ctx->password, strlen(ctx->password), header, password_verification, &ctx->fcrypt_ctx) != 0) { + if (_zip_fcrypt_init(ctx->mode, (unsigned char *)ctx->password, strlen(ctx->password), header, password_verification, &ctx->fcrypt_ctx) != 0) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } @@ -204,7 +204,7 @@ _zip_error_set_from_source(&ctx->error, src); return -1; } - ctx->current_position += n; + ctx->current_position += (zip_uint64_t)n; total = (zip_uint64_t)n; for (offset = 0; offset < total; offset += ZIP_MIN(total - offset, UINT_MAX)) {
diff --git a/lib/zip_source_winzip_aes_encode.c b/lib/zip_source_winzip_aes_encode.c index eab2964..cd30be5 100644 --- a/lib/zip_source_winzip_aes_encode.c +++ b/lib/zip_source_winzip_aes_encode.c
@@ -42,7 +42,7 @@ #define MAX_HEADER_LENGTH (16+PWD_VER_LENGTH) #define HMAC_LENGTH 10 -static int salt_length[] = { 0, 8, 12, 16 }; +static unsigned int salt_length[] = { 0, 8, 12, 16 }; struct winzip_aes { char *password; @@ -110,7 +110,7 @@ return -1; } - if (_zip_fcrypt_init(ctx->mode, ctx->password, strlen(ctx->password), ctx->data, ctx->data+salt_length[ctx->mode], &ctx->fcrypt_ctx) != 0) { + if (_zip_fcrypt_init(ctx->mode, (unsigned char *)ctx->password, strlen(ctx->password), ctx->data, ctx->data+salt_length[ctx->mode], &ctx->fcrypt_ctx) != 0) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } @@ -177,7 +177,7 @@ } if (ctx->eof) { - return buffer_n; + return (zip_int64_t)buffer_n; } if ((ret = zip_source_read(src, data, length)) < 0) {