Add some const and remove some unnecessary headers. Suggested by Flexelint.
diff --git a/lib/zip_close.c b/lib/zip_close.c index fe83fc2..a885527 100644 --- a/lib/zip_close.c +++ b/lib/zip_close.c
@@ -562,7 +562,7 @@ int -_zip_changed(struct zip *za, zip_uint64_t *survivorsp) +_zip_changed(const struct zip *za, zip_uint64_t *survivorsp) { int changed; zip_uint64_t i, survivors;
diff --git a/lib/zip_dirent.c b/lib/zip_dirent.c index 595b524..db6141c 100644 --- a/lib/zip_dirent.c +++ b/lib/zip_dirent.c
@@ -44,7 +44,7 @@ static time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t); static struct zip_string *_zip_read_string(const unsigned char **, FILE *, zip_uint16_t, int, struct zip_error *); -static struct zip_string *_zip_dirent_process_ef_utf_8(struct zip_dirent *, zip_uint16_t, struct zip_string *); +static struct zip_string *_zip_dirent_process_ef_utf_8(const struct zip_dirent *, zip_uint16_t, struct zip_string *); static struct zip_extra_field *_zip_ef_utf8(zip_uint16_t, struct zip_string *, struct zip_error *); @@ -508,7 +508,7 @@ static struct zip_string * -_zip_dirent_process_ef_utf_8(struct zip_dirent *de, zip_uint16_t id, struct zip_string *str) +_zip_dirent_process_ef_utf_8(const struct zip_dirent *de, zip_uint16_t id, struct zip_string *str) { zip_uint16_t ef_len; zip_uint32_t ef_crc;
diff --git a/lib/zip_file_get_offset.c b/lib/zip_file_get_offset.c index a19e906..65a011f 100644 --- a/lib/zip_file_get_offset.c +++ b/lib/zip_file_get_offset.c
@@ -51,7 +51,7 @@ */ zip_uint64_t -_zip_file_get_offset(struct zip *za, zip_uint64_t idx, struct zip_error *error) +_zip_file_get_offset(const struct zip *za, zip_uint64_t idx, struct zip_error *error) { zip_uint64_t offset; zip_int32_t size;
diff --git a/lib/zip_file_set_comment.c b/lib/zip_file_set_comment.c index e7f9590..722f3d4 100644 --- a/lib/zip_file_set_comment.c +++ b/lib/zip_file_set_comment.c
@@ -34,7 +34,6 @@ #include <stdlib.h> -#include <string.h> #include "zipint.h"
diff --git a/lib/zip_open.c b/lib/zip_open.c index b7ddc16..e6a30d5 100644 --- a/lib/zip_open.c +++ b/lib/zip_open.c
@@ -42,20 +42,20 @@ #include "zipint.h" -static void set_error(int *, struct zip_error *, int); +static void set_error(int *, const struct zip_error *, int); static struct zip *_zip_allocate_new(const char *, unsigned int, int *); static zip_int64_t _zip_checkcons(FILE *, struct zip_cdir *, struct zip_error *); static void _zip_check_torrentzip(struct zip *, const struct zip_cdir *); static struct zip_cdir *_zip_find_central_dir(FILE *, unsigned int, int *, off_t); static int _zip_file_exists(const char *, unsigned int, int *); -static int _zip_headercomp(struct zip_dirent *, struct zip_dirent *); +static int _zip_headercomp(const struct zip_dirent *, const struct zip_dirent *); static unsigned char *_zip_memmem(const unsigned char *, size_t, const unsigned char *, size_t); -static struct zip_cdir *_zip_readcdir(FILE *, off_t, unsigned char *, unsigned char *, +static struct zip_cdir *_zip_readcdir(FILE *, off_t, unsigned char *, const unsigned char *, size_t, unsigned int, struct zip_error *); -static struct zip_cdir *_zip_read_eocd(const unsigned char *, unsigned char *, off_t, +static struct zip_cdir *_zip_read_eocd(const unsigned char *, const unsigned char *, off_t, size_t, unsigned int, struct zip_error *); -static struct zip_cdir *_zip_read_eocd64(FILE *, const unsigned char *, unsigned char *, +static struct zip_cdir *_zip_read_eocd64(FILE *, const unsigned char *, const unsigned char *, off_t, size_t, unsigned int, struct zip_error *); @@ -175,7 +175,7 @@ static void -set_error(int *zep, struct zip_error *err, int ze) +set_error(int *zep, const struct zip_error *err, int ze) { int se; @@ -198,7 +198,7 @@ entries, or NULL if unsuccessful. */ static struct zip_cdir * -_zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eocd, size_t buflen, +_zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, const unsigned char *eocd, size_t buflen, unsigned int flags, struct zip_error *error) { struct zip_cdir *cd; @@ -402,7 +402,7 @@ Return 0 if they are consistent, -1 if not. */ static int -_zip_headercomp(struct zip_dirent *central, struct zip_dirent *local) +_zip_headercomp(const struct zip_dirent *central, const struct zip_dirent *local) { if ((central->version_needed != local->version_needed) #if 0 @@ -590,7 +590,7 @@ static struct zip_cdir * -_zip_read_eocd(const unsigned char *eocd, unsigned char *buf, off_t buf_offset, size_t buflen, +_zip_read_eocd(const unsigned char *eocd, const unsigned char *buf, off_t buf_offset, size_t buflen, unsigned int flags, struct zip_error *error) { struct zip_cdir *cd; @@ -645,7 +645,7 @@ static struct zip_cdir * -_zip_read_eocd64(FILE *f, const zip_uint8_t *eocd64loc, zip_uint8_t *buf, +_zip_read_eocd64(FILE *f, const zip_uint8_t *eocd64loc, const zip_uint8_t *buf, off_t buf_offset, size_t buflen, unsigned int flags, struct zip_error *error) { struct zip_cdir *cd;
diff --git a/lib/zip_set_file_comment.c b/lib/zip_set_file_comment.c index 9643ab0..7acd0eb 100644 --- a/lib/zip_set_file_comment.c +++ b/lib/zip_set_file_comment.c
@@ -34,7 +34,6 @@ #include <stdlib.h> -#include <string.h> #define _ZIP_COMPILING_DEPRECATED #include "zipint.h"
diff --git a/lib/zipint.h b/lib/zipint.h index aa9dee7..6ff370a 100644 --- a/lib/zipint.h +++ b/lib/zipint.h
@@ -433,7 +433,7 @@ int _zip_file_extra_field_prepare_for_change(struct zip *, zip_uint64_t); int _zip_file_fillbuf(void *, size_t, struct zip_file *); -zip_uint64_t _zip_file_get_offset(struct zip *, zip_uint64_t, struct zip_error *); +zip_uint64_t _zip_file_get_offset(const struct zip *, zip_uint64_t, struct zip_error *); int _zip_filerange_crc(FILE *, off_t, off_t, uLong *, struct zip_error *); @@ -462,7 +462,7 @@ struct zip_string *_zip_string_new(const zip_uint8_t *, zip_uint16_t, zip_flags_t, struct zip_error *); void _zip_string_write(const struct zip_string *, FILE *); -int _zip_changed(struct zip *, zip_uint64_t *); +int _zip_changed(const struct zip *, zip_uint64_t *); const char *_zip_get_name(struct zip *, zip_uint64_t, zip_flags_t, struct zip_error *); int _zip_local_header_read(struct zip *, int); void *_zip_memdup(const void *, size_t, struct zip_error *);