From 52dd5575ab40c9d1bc5f1c3921a1168d281f4660 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sat, 11 Aug 2018 12:51:29 +0000 Subject: [PATCH] Avoid implicit conversion of negative value to uint32_t. --- toxcore/tox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/toxcore/tox.c b/toxcore/tox.c index b2ea1969..cd1b71f0 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -1000,15 +1000,17 @@ bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_number, uint8 return 0; } - const Messenger *m = tox->m; - // TODO(irungentoo): size parameter? - int ret = m_copy_statusmessage(m, friend_number, status_message, m_get_statusmessage_size(m, friend_number)); + const Messenger *const m = tox->m; + const int size = m_get_statusmessage_size(m, friend_number); - if (ret == -1) { + if (size == -1) { SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND); return 0; } + const int ret = m_copy_statusmessage(m, friend_number, status_message, size); + assert(ret == size && "concurrency problem: friend status message changed"); + SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK); return 1; }