From: Hans Kristian Rosbach Date: Sat, 7 May 2022 17:10:29 +0000 (+0200) Subject: Add nonnull attributes to trees.c functions. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fhinting;p=thirdparty%2Fzlib-ng.git Add nonnull attributes to trees.c functions. --- diff --git a/deflate.h b/deflate.h index b5ae2f8e..e04f90b3 100644 --- a/deflate.h +++ b/deflate.h @@ -372,17 +372,17 @@ static inline void put_uint64(deflate_state *s, uint64_t lld) { memory checker errors from longest match routines */ -void Z_INTERNAL fill_window(deflate_state *s); -void Z_INTERNAL slide_hash_c(deflate_state *s); +void Z_INTERNAL fill_window(deflate_state *s) Z_NONULL; +void Z_INTERNAL slide_hash_c(deflate_state *s) Z_NONULL; /* in trees.c */ -void Z_INTERNAL zng_tr_init(deflate_state *s); -void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last); -void Z_INTERNAL zng_tr_flush_bits(deflate_state *s); -void Z_INTERNAL zng_tr_align(deflate_state *s); -void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last); +void Z_INTERNAL zng_tr_init(deflate_state *s) Z_NONULL; +void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last) Z_NONULL_A(1); +void Z_INTERNAL zng_tr_flush_bits(deflate_state *s) Z_NONULL; +void Z_INTERNAL zng_tr_align(deflate_state *s) Z_NONULL; +void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last) Z_NONULL_A(1); uint16_t Z_INTERNAL PREFIX(bi_reverse)(unsigned code, int len); -void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm); +void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm) Z_NONULL; #define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never diff --git a/trees.c b/trees.c index 7bc70075..74fae7c8 100644 --- a/trees.c +++ b/trees.c @@ -65,17 +65,17 @@ static const static_tree_desc static_bl_desc = * Local (static) routines in this file. */ -static void init_block (deflate_state *s); -static void pqdownheap (deflate_state *s, ct_data *tree, int k); -static void gen_bitlen (deflate_state *s, tree_desc *desc); -static void build_tree (deflate_state *s, tree_desc *desc); -static void scan_tree (deflate_state *s, ct_data *tree, int max_code); -static void send_tree (deflate_state *s, ct_data *tree, int max_code); -static int build_bl_tree (deflate_state *s); -static void send_all_trees (deflate_state *s, int lcodes, int dcodes, int blcodes); -static void compress_block (deflate_state *s, const ct_data *ltree, const ct_data *dtree); -static int detect_data_type (deflate_state *s); -static void bi_flush (deflate_state *s); +static void init_block (deflate_state *s) Z_NONULL; +static void pqdownheap (deflate_state *s, ct_data *tree, int k) Z_NONULL; +static void gen_bitlen (deflate_state *s, tree_desc *desc) Z_NONULL; +static void build_tree (deflate_state *s, tree_desc *desc) Z_NONULL; +static void scan_tree (deflate_state *s, ct_data *tree, int max_code) Z_NONULL; +static void send_tree (deflate_state *s, ct_data *tree, int max_code) Z_NONULL; +static int build_bl_tree (deflate_state *s) Z_NONULL; +static void send_all_trees (deflate_state *s, int lcodes, int dcodes, int blcodes) Z_NONULL; +static void compress_block (deflate_state *s, const ct_data *ltree, const ct_data *dtree) Z_NONULL; +static int detect_data_type (deflate_state *s) Z_NONULL; +static void bi_flush (deflate_state *s) Z_NONULL; /* =========================================================================== * Initialize the tree data structures for a new zlib stream. diff --git a/zconf-ng.h.in b/zconf-ng.h.in index 21629c7b..95241dc2 100644 --- a/zconf-ng.h.in +++ b/zconf-ng.h.in @@ -168,4 +168,14 @@ typedef PTRDIFF_TYPE ptrdiff_t; # endif #endif +#if defined(__clang__) || defined(__GNUC__) +# define Z_NONULL __attribute__ ((nonnull)) +# define Z_NONULL_A(...) __attribute__ ((nonnull(__VA_ARGS__))) +# define Z_RET_NONULL __attribute__ ((returns_nonnull)) +#else +# define Z_NONULL +# define Z_NONULL_A(...) +# define Z_RET_NONULL +#endif + #endif /* ZCONFNG_H */ diff --git a/zconf.h.in b/zconf.h.in index fef6bab4..e2958801 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -188,4 +188,14 @@ typedef PTRDIFF_TYPE ptrdiff_t; # endif #endif +#if defined(__clang__) || defined(__GNUC__) +# define Z_NONULL __attribute__ ((nonnull)) +# define Z_NONULL_A(...) __attribute__ ((nonnull(__VA_ARGS__))) +# define Z_RET_NONULL __attribute__ ((returns_nonnull)) +#else +# define Z_NONULL +# define Z_NONULL_A(...) +# define Z_RET_NONULL +#endif + #endif /* ZCONF_H */