aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-27 22:51:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-07-28 08:40:08 +0100
commit41d5f05b86c4cebc4338c0a038d47c0db023ce71 (patch)
tree0f2db324a8f77e7d65749bcf47c653bc2e4a4820 /src/libutil/util.c
parentf877a24ae0707ce8dd30d143fe306e4325de888c (diff)
downloadrspamd-41d5f05b86c4cebc4338c0a038d47c0db023ce71.tar.gz
rspamd-41d5f05b86c4cebc4338c0a038d47c0db023ce71.zip
[Minor] Some improvements to utility functions
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 55fd7c2a2..c8c446138 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -181,9 +181,10 @@ static gint
rspamd_inet_socket_create (gint type, struct addrinfo *addr, gboolean is_server,
gboolean async, GList **list)
{
- gint fd = -1, r, optlen, on = 1, s_error;
+ gint fd = -1, r, on = 1, s_error;
struct addrinfo *cur;
gpointer ptr;
+ socklen_t optlen;
cur = addr;
while (cur) {
@@ -294,7 +295,9 @@ rspamd_socket_unix (const gchar *path,
gboolean is_server,
gboolean async)
{
- gint fd = -1, s_error, r, optlen, serrno, on = 1;
+
+ socklen_t optlen;
+ gint fd = -1, s_error, r, serrno, on = 1;
struct stat st;
if (path == NULL)
@@ -1864,7 +1867,7 @@ rspamd_get_ticks (void)
struct timeval tv;
(void)gettimeofday (&tv, NULL);
- res = (double)tv.tv_sec + tv.tv_nsec / 1000000.;
+ res = (double)tv.tv_sec + tv.tv_usec / 1000000.;
#endif
return res;
@@ -1926,7 +1929,7 @@ rspamd_random_hex (guchar *buf, guint64 len)
g_assert (len > 0);
- ottery_rand_bytes (buf, (len / 2.0 + 0.5));
+ ottery_rand_bytes (buf, ceil (len / 2.0));
for (i = (gint64)len - 1; i >= 0; i -= 2) {
buf[i] = hexdigests[buf[i / 2] & 0xf];