summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-12-01 20:02:36 +0100
committerThomas Haller <thaller@redhat.com>2023-12-01 20:04:04 +0100
commit57e0170607a9cb5bc94eb2b8472a7dd01bd610d6 (patch)
tree48cdc1475b438a86855639f00209b30ce59673ae
parent46e8739ef70874310501bb80769016337fd8aa65 (diff)
downloadlibnl-57e0170607a9cb5bc94eb2b8472a7dd01bd610d6.tar.gz
socket: explicitly cast time() to uint32_t
Coverity warns about this. Try to avoid the warning by casting. We only use time() to get some (very little) entropy. The cast is fine.
-rw-r--r--lib/socket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/socket.c b/lib/socket.c
index b0a65301..5f28ea83 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -73,7 +73,7 @@ static uint32_t generate_local_port(void)
nl_write_lock(&port_map_lock);
if (idx_state == 0) {
- uint32_t t = time(NULL);
+ uint32_t t = (uint32_t) time(NULL);
/* from time to time (on average each 2^15 calls), the idx_state will
* be zero again. No problem, just "seed" anew with time(). */
@@ -190,7 +190,8 @@ static struct nl_sock *__alloc_socket(struct nl_cb *cb)
sk->s_cb = nl_cb_get(cb);
sk->s_local.nl_family = AF_NETLINK;
sk->s_peer.nl_family = AF_NETLINK;
- sk->s_seq_expect = sk->s_seq_next = time(NULL);
+ sk->s_seq_next = (unsigned int) time(NULL);
+ sk->s_seq_expect = sk->s_seq_next;
/* the port is 0 (unspecified), meaning NL_OWN_PORT */
sk->s_flags = NL_OWN_PORT;