[multiple] add attrs from gcc -Wsuggest-attribute=

master
Glenn Strauss 2 years ago
parent fe4310cc61
commit 19bc88850e

@ -31,6 +31,7 @@
#endif
#endif
#ifndef USE_NETTLE_CRYPTO
#if defined(USE_OPENSSL_CRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
#define HMAC EVP_HMAC
static unsigned char *
@ -56,6 +57,7 @@ EVP_HMAC (const EVP_MD *evp_md, const void *key,
return (1 == rc) ? md : NULL;
}
#endif
#endif
int

@ -173,7 +173,10 @@ void buffer_append_string_encoded(buffer * restrict b, const char * restrict s,
void buffer_append_string_c_escaped(buffer * restrict b, const char * restrict s, size_t s_len);
void buffer_urldecode_path(buffer *b);
__attribute_pure__
int buffer_is_valid_UTF8(const buffer *b);
void buffer_path_simplify(buffer *dest, buffer *src);
void buffer_to_lower(buffer *b);
@ -181,6 +184,7 @@ void buffer_to_upper(buffer *b);
/** deprecated */
__attribute_const__
char hex2int(unsigned char c);
__attribute_pure__

@ -309,7 +309,8 @@ static void config_check_module_duplicates (server *srv) {
srv->srvconf.modules = modules;
}
static const char * config_has_opt_and_value (server * const srv, const char * const opt, const uint32_t olen, const char * const v, const uint32_t vlen) {
__attribute_pure__
static const char * config_has_opt_and_value (const server * const srv, const char * const opt, const uint32_t olen, const char * const v, const uint32_t vlen) {
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
const data_config * const config =
(data_config const *)srv->config_context->data[i];

@ -1695,6 +1695,7 @@ connection_handle_read_post_cq_compact (chunkqueue * const cq)
}
__attribute_pure__
static int
connection_handle_read_post_chunked_crlf (chunkqueue * const cq)
{

@ -50,6 +50,7 @@ __attribute_cold__
int fdevent_config(const char **event_handler_name, struct log_error_st *errh);
__attribute_cold__
__attribute_const__
const char * fdevent_show_event_handlers(void);
__attribute_cold__
@ -88,7 +89,9 @@ int fdevent_rename(const char *oldpath, const char *newpath);
struct sockaddr;
int fdevent_accept_listenfd(int listenfd, struct sockaddr *addr, size_t *addrlen);
__attribute_pure__
char ** fdevent_environ(void);
int fdevent_open_devnull(void);
int fdevent_open_dirname(char *path, int symlinks);
int fdevent_set_stdin_stdout_stderr(int fdin, int fdout, int fderr);

@ -77,6 +77,7 @@ static int fdevent_poll_event_set(fdevents *ev, fdnode *fdn, int events) {
return 0;
}
__attribute_pure__
static int fdevent_poll_next_ndx(const fdevents *ev, int ndx) {
for (uint32_t i = (uint32_t)(ndx+1); i < ev->used; ++i) {
if (ev->pollfds[i].revents) return i;

@ -140,6 +140,15 @@
#endif
#endif
#ifndef __attribute_const__
#if __has_attribute(const) \
|| __GNUC_PREREQ(2,5)
#define __attribute_const__ __attribute__((__const__))
#else
#define __attribute_const__
#endif
#endif
#ifndef __attribute_pure__
#if __has_attribute(pure) \
|| __GNUC_PREREQ(2,96)
@ -158,5 +167,18 @@
#endif
#endif
#ifndef __attribute_malloc__
#if __has_attribute(malloc) \
|| __GNUC_PREREQ(2,96)
#define __attribute_malloc__ __attribute__((__malloc__))
#elif defined(_MSC_VER)
#undef restrict
#define __attribute_malloc__ __declspec(restrict)
#define restrict __restrict
#else
#define __attribute_malloc__
#endif
#endif
#endif

@ -702,6 +702,7 @@ static void gw_proc_kill(gw_host *host, gw_proc *proc) {
--host->num_procs;
}
__attribute_pure__
static gw_host * unixsocket_is_dup(gw_plugin_data *p, const buffer *unixsocket) {
if (NULL == p->cvlist) return NULL;
/* (init i to 0 if global context; to 1 to skip empty global context) */

@ -330,6 +330,7 @@ typedef struct gw_handler_ctx {
__attribute_cold__
__attribute_malloc__
void * gw_init(void);
__attribute_cold__

@ -134,6 +134,7 @@ void http_auth_require_free (http_auth_require_t * const require)
/* (case-sensitive version of array.c:array_get_index(),
* and common case expects small num of allowed tokens,
* so it is reasonably performant to simply walk the array) */
__attribute_pure__
static int http_auth_array_contains (const array * const a, const char * const k, const size_t klen)
{
for (size_t i = 0, used = a->used; i < used; ++i) {

@ -21,6 +21,7 @@ typedef enum http_auth_digest_type {
#define HTTP_AUTH_DIGEST_SHA256_BINLEN 32 /* SHA256_DIGEST_LENGTH */
#define HTTP_AUTH_DIGEST_SHA512_256_BINLEN 32 /* SHA512_256_DIGEST_LENGTH */
__attribute_const__
unsigned int http_auth_digest_len (int algo);
struct http_auth_scheme_t;
@ -39,11 +40,13 @@ typedef struct http_auth_require_t {
} http_auth_require_t;
__attribute_cold__
__attribute_malloc__
http_auth_require_t * http_auth_require_init (void);
__attribute_cold__
void http_auth_require_free (http_auth_require_t *require);
__attribute_pure__
int http_auth_match_rules (const http_auth_require_t *require, const char *user, const char *group, const char *host);
typedef struct http_auth_info_t {
@ -72,12 +75,14 @@ typedef struct http_auth_scheme_t {
} http_auth_scheme_t;
__attribute_cold__
__attribute_pure__
const http_auth_scheme_t * http_auth_scheme_get (const buffer *name);
__attribute_cold__
void http_auth_scheme_set (const http_auth_scheme_t *scheme);
__attribute_cold__
__attribute_pure__
const http_auth_backend_t * http_auth_backend_get (const buffer *name);
__attribute_cold__

@ -59,11 +59,21 @@ typedef enum {
typedef enum { HTTP_VERSION_UNSET = -1, HTTP_VERSION_1_0, HTTP_VERSION_1_1, HTTP_VERSION_2 } http_version_t;
__attribute_pure__
const char *get_http_status_name(int i);
__attribute_pure__
const char *get_http_version_name(int i);
__attribute_pure__
const char *get_http_method_name(http_method_t i);
__attribute_pure__
int get_http_version_key(const char *s, size_t slen);
__attribute_pure__
http_method_t get_http_method_key(const char *s, size_t slen);
void http_status_append(buffer *b, int status);
void http_method_append(buffer *b, http_method_t method);
void http_version_append(buffer *b, http_version_t version);

@ -15,6 +15,7 @@ typedef struct http_vhostdb_backend_t {
} http_vhostdb_backend_t;
__attribute_cold__
__attribute_pure__
const http_vhostdb_backend_t * http_vhostdb_backend_get (const buffer *name);
__attribute_cold__

@ -24,6 +24,7 @@ typedef struct {
} pcre_keyvalue_buffer;
__attribute_cold__
__attribute_malloc__
pcre_keyvalue_buffer *pcre_keyvalue_buffer_init(void);
__attribute_cold__

@ -133,6 +133,7 @@ log_buffer_append_encoded (buffer * const b,
}
__attribute_format__((__printf__, 2, 0))
static void
log_buffer_vprintf (buffer * const b,
const char * const fmt, va_list ap)
@ -171,6 +172,7 @@ log_buffer_vprintf (buffer * const b,
}
__attribute_format__((__printf__, 4, 0))
static void
log_error_va_list_impl (log_error_st * const errh,
const char * const filename,

@ -102,7 +102,8 @@ SETDEFAULTS_FUNC(mod_authn_pam_set_defaults) {
if (cpv->v.a->used) {
const data_string *ds = (const data_string *)
array_get_element_klen(cpv->v.a,CONST_STR_LEN("service"));
cpv->v.v = (NULL != ds) ? ds->value.ptr : "http";
*(const void **)&cpv->v.v =
(NULL != ds) ? ds->value.ptr : "http";
cpv->vtype = T_CONFIG_LOCAL;
}
break;

@ -652,6 +652,7 @@ static handler_t mod_extforward_X_Forwarded_For(request_st * const r, plugin_dat
return HANDLER_GO_ON;
}
__attribute_pure__
static int find_end_quoted_string (const char * const s, int i) {
do {
++i;
@ -659,6 +660,7 @@ static int find_end_quoted_string (const char * const s, int i) {
return i;
}
__attribute_pure__
static int find_next_semicolon_or_comma_or_eq (const char * const s, int i) {
for (; s[i] != '=' && s[i] != ';' && s[i] != ',' && s[i] != '\0'; ++i) {
if (s[i] == '"') {
@ -669,6 +671,7 @@ static int find_next_semicolon_or_comma_or_eq (const char * const s, int i) {
return i;
}
__attribute_pure__
static int find_next_semicolon_or_comma (const char * const s, int i) {
for (; s[i] != ';' && s[i] != ',' && s[i] != '\0'; ++i) {
if (s[i] == '"') {

@ -924,6 +924,7 @@ static int process_ssi_stmt(request_st * const r, handler_ctx * const p, const c
}
__attribute_pure__
static int mod_ssi_parse_ssi_stmt_value(const unsigned char * const s, const int len) {
int n;
const int c = (s[0] == '"' ? '"' : s[0] == '\'' ? '\'' : 0);

@ -22,6 +22,7 @@ typedef struct {
int in_cond;
} ssi_tokenizer_t;
__attribute_malloc__
ssi_val_t *ssi_val_init(void) {
ssi_val_t *s;
@ -36,6 +37,7 @@ void ssi_val_free(ssi_val_t *s) {
free(s);
}
__attribute_pure__
int ssi_val_tobool(ssi_val_t *B) {
if (B->type == SSI_TYPE_STRING) {
return !buffer_string_is_empty(B->str);

@ -83,9 +83,10 @@ static int request_map_insert(request_map *rm, request_st * const r, const char
return 0;
}
static request_st * request_map_get_request(request_map *rm, const char *r_id, size_t idlen) {
__attribute_pure__
static request_st * request_map_get_request(const request_map * const rm, const char * const r_id, const size_t idlen) {
for (uint32_t i = 0; i < rm->used; ++i) {
request_map_entry *rme = rm->ptr[i];
const request_map_entry * const rme = rm->ptr[i];
if (buffer_is_equal_string(rme->r_id, r_id, idlen)) {
return rme->r; /* found request */

@ -7,6 +7,7 @@ __attribute_cold__
int network_write_init(server *srv);
__attribute_cold__
__attribute_const__
const char * network_write_show_handlers(void);
#endif

@ -129,9 +129,11 @@ typedef struct {
} config_plugin_keys_t;
__attribute_cold__
__attribute_pure__
int config_plugin_value_tobool(const data_unset *du, int default_value);
__attribute_cold__
__attribute_pure__
int32_t config_plugin_value_to_int32 (const data_unset *du, int32_t default_value);
__attribute_cold__

@ -347,7 +347,7 @@ int http_request_host_policy (buffer * const b, const unsigned int http_parseopt
&& 0 != http_request_host_normalize(b, scheme_port)));
}
__attribute_pure__ /*(could be even more strict and use __attribute_const__)*/
__attribute_const__
static int request_uri_is_valid_char(const unsigned char c) {
return (c > 32 && c != 127 && c != 255);
}

@ -41,7 +41,9 @@ void stat_cache_entry_refchg(void *data, int mod);
__attribute_cold__
void stat_cache_xattrname (const char *name);
__attribute_pure__
const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen);
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR)
const buffer * stat_cache_mimetype_by_xattr(const char *name);
const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr);

@ -10,7 +10,10 @@ static inline size_t vector_align_size(size_t s) {
}
void vector_free(void *data);
__attribute_malloc__
void *vector_malloc(size_t sz);
void *vector_realloc(void *data, size_t elem_size, size_t size, size_t used);
#define DEFINE_TYPED_VECTOR(name, entry, release) \

Loading…
Cancel
Save