commit 765813e: [Minor] silence warnings about unused function results
Christian Göttsche
cgzones at googlemail.com
Tue Apr 14 09:56:12 UTC 2020
Author: Christian Göttsche
Date: 2020-04-06 16:27:41 +0200
URL: https://github.com/rspamd/rspamd/commit/765813e908e0f23e98ec6224b0408a152a9d3ec0
[Minor] silence warnings about unused function results
GCC does not respect `(void) func()`
---
contrib/kann/kann.c | 6 +++---
contrib/kann/kautodiff.c | 24 ++++++++++++------------
contrib/libev/ev.c | 8 ++++----
src/libserver/re_cache.c | 2 +-
src/libserver/rspamd_control.c | 4 ++--
src/libutil/multipattern.c | 6 +++---
src/libutil/sqlite_utils.c | 2 +-
src/lua/lua_cryptobox.c | 4 ++--
src/lua/lua_worker.c | 4 ++--
9 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/contrib/kann/kann.c b/contrib/kann/kann.c
index 76ade6a52..72fb0c061 100644
--- a/contrib/kann/kann.c
+++ b/contrib/kann/kann.c
@@ -496,7 +496,7 @@ kann_t *kann_load_fp(FILE *fp)
kann_t *ann;
int n_var, n_const;
- fread(magic, 1, 4, fp);
+ (void) !fread(magic, 1, 4, fp);
if (strncmp(magic, KANN_MAGIC, 4) != 0) {
fclose(fp);
return 0;
@@ -508,8 +508,8 @@ kann_t *kann_load_fp(FILE *fp)
ann->x = (float*)malloc(n_var * sizeof(float));
ann->g = (float*)calloc(n_var, sizeof(float));
ann->c = (float*)malloc(n_const * sizeof(float));
- fread(ann->x, sizeof(float), n_var, fp);
- fread(ann->c, sizeof(float), n_const, fp);
+ (void) !fread(ann->x, sizeof(float), n_var, fp);
+ (void) !fread(ann->c, sizeof(float), n_const, fp);
kad_ext_sync(ann->n, ann->v, ann->x, ann->g, ann->c);
return ann;
}
diff --git a/contrib/kann/kautodiff.c b/contrib/kann/kautodiff.c
index bc9458f42..47a86a71e 100644
--- a/contrib/kann/kautodiff.c
+++ b/contrib/kann/kautodiff.c
@@ -617,28 +617,28 @@ static kad_node_t *kad_load1(FILE *fp, kad_node_t **node)
{
kad_node_t *p;
p = (kad_node_t*)calloc(1, sizeof(kad_node_t));
- fread(&p->ext_label, 4, 1, fp);
- fread(&p->ext_flag, 4, 1, fp);
- fread(&p->flag, 1, 1, fp);
- fread(&p->n_child, 4, 1, fp);
+ (void) !fread(&p->ext_label, 4, 1, fp);
+ (void) !fread(&p->ext_flag, 4, 1, fp);
+ (void) !fread(&p->flag, 1, 1, fp);
+ (void) !fread(&p->n_child, 4, 1, fp);
if (p->n_child) {
int32_t j, k;
p->child = (kad_node_t**)calloc(p->n_child, sizeof(kad_node_t*));
- fread(&p->op, 2, 1, fp);
+ (void) !fread(&p->op, 2, 1, fp);
for (j = 0; j < p->n_child; ++j) {
- fread(&k, 4, 1, fp);
+ (void) !fread(&k, 4, 1, fp);
p->child[j] = node? node[k] : 0;
}
- fread(&k, 4, 1, fp);
+ (void) !fread(&k, 4, 1, fp);
if (k >= 0) p->pre = node[k];
- fread(&p->ptr_size, 4, 1, fp);
+ (void) !fread(&p->ptr_size, 4, 1, fp);
if (p->ptr_size > 0) {
p->ptr = malloc(p->ptr_size);
- fread(p->ptr, p->ptr_size, 1, fp);
+ (void) !fread(p->ptr, p->ptr_size, 1, fp);
}
} else {
- fread(&p->n_d, 1, 1, fp);
- if (p->n_d) fread(p->d, 4, p->n_d, fp);
+ (void) !fread(&p->n_d, 1, 1, fp);
+ if (p->n_d) (void) !fread(p->d, 4, p->n_d, fp);
}
return p;
}
@@ -657,7 +657,7 @@ kad_node_t **kad_load(FILE *fp, int *_n_node)
{
int32_t i, n_node;
kad_node_t **node;
- fread(&n_node, 4, 1, fp);
+ (void) !fread(&n_node, 4, 1, fp);
node = (kad_node_t**)malloc(n_node * sizeof(kad_node_t*));
for (i = 0; i < n_node; ++i) {
kad_node_t *p;
diff --git a/contrib/libev/ev.c b/contrib/libev/ev.c
index 12eafd8a4..533b19e3d 100644
--- a/contrib/libev/ev.c
+++ b/contrib/libev/ev.c
@@ -2808,7 +2808,7 @@ evpipe_write (EV_P_ EV_ATOMIC_T *flag)
if (evpipe [0] < 0)
{
uint64_t counter = 1;
- write (evpipe [1], &counter, sizeof (uint64_t));
+ (void) !write (evpipe [1], &counter, sizeof (uint64_t));
}
else
#endif
@@ -2820,7 +2820,7 @@ evpipe_write (EV_P_ EV_ATOMIC_T *flag)
buf.len = 1;
WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0);
#else
- write (evpipe [1], &(evpipe [1]), 1);
+ (void) !write (evpipe [1], &(evpipe [1]), 1);
#endif
}
@@ -2841,7 +2841,7 @@ pipecb (EV_P_ ev_io *iow, int revents)
if (evpipe [0] < 0)
{
uint64_t counter;
- read (evpipe [1], &counter, sizeof (uint64_t));
+ (void) !read (evpipe [1], &counter, sizeof (uint64_t));
}
else
#endif
@@ -2855,7 +2855,7 @@ pipecb (EV_P_ ev_io *iow, int revents)
buf.len = sizeof (dummy);
WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, &flags, 0, 0);
#else
- read (evpipe [0], &dummy, sizeof (dummy));
+ (void) !read (evpipe [0], &dummy, sizeof (dummy));
#endif
}
}
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 6dc13220b..fe5e1476b 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -391,7 +391,7 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg)
rspamd_regexp_set_cache_id (re, i);
if (re_class->st == NULL) {
- posix_memalign ((void **)&re_class->st, _Alignof (rspamd_cryptobox_hash_state_t),
+ (void) !posix_memalign ((void **)&re_class->st, _Alignof (rspamd_cryptobox_hash_state_t),
sizeof (*re_class->st));
g_assert (re_class->st != NULL);
rspamd_cryptobox_hash_init (re_class->st, NULL, 0);
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 0dc04d291..2670263f3 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -781,7 +781,7 @@ rspamd_control_ignore_io_handler (int fd, short what, void *ud)
struct rspamd_control_reply rep;
/* At this point we just ignore replies from the workers */
- (void)read (fd, &rep, sizeof (rep));
+ (void) !read (fd, &rep, sizeof (rep));
rspamd_control_stop_pending (elt);
}
@@ -793,7 +793,7 @@ rspamd_control_log_pipe_io_handler (int fd, short what, void *ud)
struct rspamd_control_reply rep;
/* At this point we just ignore replies from the workers */
- (void) read (fd, &rep, sizeof (rep));
+ (void) !read (fd, &rep, sizeof (rep));
rspamd_control_stop_pending (elt);
}
diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c
index 547762d26..8ddd9af38 100644
--- a/src/libutil/multipattern.c
+++ b/src/libutil/multipattern.c
@@ -256,7 +256,7 @@ rspamd_multipattern_create (enum rspamd_multipattern_flags flags)
struct rspamd_multipattern *mp;
/* Align due to blake2b state */
- posix_memalign((void **)&mp, _Alignof (struct rspamd_multipattern),
+ (void) !posix_memalign((void **)&mp, _Alignof (struct rspamd_multipattern),
sizeof (*mp));
g_assert (mp != NULL);
memset (mp, 0, sizeof (*mp));
@@ -285,7 +285,7 @@ rspamd_multipattern_create_sized (guint npatterns,
struct rspamd_multipattern *mp;
/* Align due to blake2b state */
- posix_memalign((void **)&mp, _Alignof (struct rspamd_multipattern), sizeof (*mp));
+ (void) !posix_memalign((void **)&mp, _Alignof (struct rspamd_multipattern), sizeof (*mp));
g_assert (mp != NULL);
memset (mp, 0, sizeof (*mp));
mp->flags = flags;
@@ -789,4 +789,4 @@ gboolean
rspamd_multipattern_has_hyperscan (void)
{
return rspamd_hs_check ();
-}
\ No newline at end of file
+}
diff --git a/src/libutil/sqlite_utils.c b/src/libutil/sqlite_utils.c
index 9bb0b9c1f..f9e47032c 100644
--- a/src/libutil/sqlite_utils.c
+++ b/src/libutil/sqlite_utils.c
@@ -356,7 +356,7 @@ rspamd_sqlite3_open_or_create (rspamd_mempool_t *pool, const gchar *path, const
else {
pid_t myself = getpid ();
msg_debug_pool_check ("locking %s to block other processes", lock_path);
- (void)write (lock_fd, &myself, sizeof (myself));
+ (void) !write (lock_fd, &myself, sizeof (myself));
g_assert (rspamd_file_lock (lock_fd, FALSE));
has_lock = TRUE;
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index 07b4888b9..784abea65 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -1008,7 +1008,7 @@ rspamd_lua_hash_create (const gchar *type)
}
else if (g_ascii_strcasecmp (type, "blake2") == 0) {
h->type = LUA_CRYPTOBOX_HASH_BLAKE2;
- posix_memalign ((void **)&h->content.h, _Alignof (rspamd_cryptobox_hash_state_t),
+ (void) !posix_memalign ((void **)&h->content.h, _Alignof (rspamd_cryptobox_hash_state_t),
sizeof (*h->content.h));
g_assert (h->content.h != NULL);
rspamd_cryptobox_hash_init (h->content.h, NULL, 0);
@@ -1045,7 +1045,7 @@ rspamd_lua_hash_create (const gchar *type)
}
else {
h->type = LUA_CRYPTOBOX_HASH_BLAKE2;
- posix_memalign ((void **)&h->content.h, _Alignof (rspamd_cryptobox_hash_state_t),
+ (void) !posix_memalign ((void **)&h->content.h, _Alignof (rspamd_cryptobox_hash_state_t),
sizeof (*h->content.h));
g_assert (h->content.h != NULL);
rspamd_cryptobox_hash_init (h->content.h, NULL, 0);
diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c
index a286069cb..badc50a72 100644
--- a/src/lua/lua_worker.c
+++ b/src/lua/lua_worker.c
@@ -746,7 +746,7 @@ rspamd_lua_subprocess_io (EV_P_ ev_io *w, int revents)
/* Write reply to the child */
rspamd_socket_blocking (cbdata->sp[0]);
memset (rep, 0, sizeof (rep));
- (void)write (cbdata->sp[0], rep, sizeof (rep));
+ (void) !write (cbdata->sp[0], rep, sizeof (rep));
}
}
}
@@ -891,4 +891,4 @@ void
luaopen_worker (lua_State * L)
{
rspamd_lua_new_class (L, "rspamd{worker}", worker_reg);
-}
\ No newline at end of file
+}
More information about the Commits
mailing list