Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace
640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) 5047ae5a2 chore: make the source tarball exhibit the old behavior 14804a4b8 chore: Fix sonar-scan CI action. e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project. 3accade67 chore: Fix CI, disabling some tests that no longer run on CI. ef8d767e6 cleanup: Fix comment formatting errors. 34ec822da cleanup: Fix some clang-19 format warnings. 40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes. f81e30679 refactor: Use per-parameter nullability annotations. REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
314
toxcore/group.c
314
toxcore/group.c
@@ -216,20 +216,17 @@ const Mono_Time *g_mono_time(const Group_Chats *g_c)
|
||||
return g_c->mono_time;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool group_id_eq(const uint8_t *a, const uint8_t *b)
|
||||
static bool group_id_eq(const uint8_t *_Nonnull a, const uint8_t *_Nonnull b)
|
||||
{
|
||||
return pk_equal(a, b);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool g_title_eq(const Group_c *g, const uint8_t *title, uint8_t title_len)
|
||||
static bool g_title_eq(const Group_c *_Nonnull g, const uint8_t *_Nonnull title, uint8_t title_len)
|
||||
{
|
||||
return memeq(g->title, g->title_len, title, title_len);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool g_peer_nick_eq(const Group_Peer *peer, const uint8_t *nick, uint8_t nick_len)
|
||||
static bool g_peer_nick_eq(const Group_Peer *_Nonnull peer, const uint8_t *_Nonnull nick, uint8_t nick_len)
|
||||
{
|
||||
return memeq(peer->nick, peer->nick_len, nick, nick_len);
|
||||
}
|
||||
@@ -238,8 +235,7 @@ static bool g_peer_nick_eq(const Group_Peer *peer, const uint8_t *nick, uint8_t
|
||||
* @retval false if the groupnumber is not valid.
|
||||
* @retval true if the groupnumber is valid.
|
||||
*/
|
||||
non_null()
|
||||
static bool is_groupnumber_valid(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
static bool is_groupnumber_valid(const Group_Chats *_Nonnull g_c, uint32_t groupnumber)
|
||||
{
|
||||
return groupnumber < g_c->num_chats
|
||||
&& g_c->chats != nullptr
|
||||
@@ -251,8 +247,7 @@ static bool is_groupnumber_valid(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
* @retval false if mem_vrealloc fails.
|
||||
* @retval true if it succeeds.
|
||||
*/
|
||||
non_null()
|
||||
static bool realloc_conferences(Group_Chats *g_c, uint16_t num)
|
||||
static bool realloc_conferences(Group_Chats *_Nonnull g_c, uint16_t num)
|
||||
{
|
||||
if (num == 0) {
|
||||
mem_delete(g_c->mem, g_c->chats);
|
||||
@@ -270,8 +265,7 @@ static bool realloc_conferences(Group_Chats *g_c, uint16_t num)
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void setup_conference(Group_c *g)
|
||||
static void setup_conference(Group_c *_Nonnull g)
|
||||
{
|
||||
*g = empty_group_c;
|
||||
g->maxfrozen = MAX_FROZEN_DEFAULT;
|
||||
@@ -282,8 +276,7 @@ static void setup_conference(Group_c *g)
|
||||
* @retval -1 on failure.
|
||||
* @return groupnumber on success.
|
||||
*/
|
||||
non_null()
|
||||
static int32_t create_group_chat(Group_Chats *g_c)
|
||||
static int32_t create_group_chat(Group_Chats *_Nonnull g_c)
|
||||
{
|
||||
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
|
||||
if (g_c->chats[i].status == GROUPCHAT_STATUS_NONE) {
|
||||
@@ -301,8 +294,7 @@ static int32_t create_group_chat(Group_Chats *g_c)
|
||||
return -1;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void wipe_group_c(const Memory *mem, Group_c *g)
|
||||
static void wipe_group_c(const Memory *_Nonnull mem, Group_c *_Nonnull g)
|
||||
{
|
||||
mem_delete(mem, g->frozen);
|
||||
mem_delete(mem, g->group);
|
||||
@@ -313,8 +305,7 @@ static void wipe_group_c(const Memory *mem, Group_c *g)
|
||||
*
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null()
|
||||
static bool wipe_group_chat(Group_Chats *g_c, uint32_t groupnumber)
|
||||
static bool wipe_group_chat(Group_Chats *_Nonnull g_c, uint32_t groupnumber)
|
||||
{
|
||||
if (groupnumber >= g_c->num_chats || g_c->chats == nullptr) {
|
||||
return false;
|
||||
@@ -338,8 +329,7 @@ static bool wipe_group_chat(Group_Chats *g_c, uint32_t groupnumber)
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static Group_c *get_group_c(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
static Group_c *get_group_c(const Group_Chats *_Nonnull g_c, uint32_t groupnumber)
|
||||
{
|
||||
if (!is_groupnumber_valid(g_c, groupnumber)) {
|
||||
return nullptr;
|
||||
@@ -356,8 +346,7 @@ static Group_c *get_group_c(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
*
|
||||
* TODO(irungentoo): make this more efficient.
|
||||
*/
|
||||
non_null()
|
||||
static int peer_in_group(const Group_c *g, const uint8_t *real_pk)
|
||||
static int peer_in_group(const Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk)
|
||||
{
|
||||
for (uint32_t i = 0; i < g->numpeers; ++i) {
|
||||
if (pk_equal(g->group[i].real_pk, real_pk)) {
|
||||
@@ -368,8 +357,7 @@ static int peer_in_group(const Group_c *g, const uint8_t *real_pk)
|
||||
return -1;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int frozen_in_group(const Group_c *g, const uint8_t *real_pk)
|
||||
static int frozen_in_group(const Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk)
|
||||
{
|
||||
for (uint32_t i = 0; i < g->numfrozen; ++i) {
|
||||
if (pk_equal(g->frozen[i].real_pk, real_pk)) {
|
||||
@@ -388,8 +376,7 @@ static int frozen_in_group(const Group_c *g, const uint8_t *real_pk)
|
||||
*
|
||||
* TODO(irungentoo): make this more efficient and maybe use constant time comparisons?
|
||||
*/
|
||||
non_null()
|
||||
static int32_t get_group_num(const Group_Chats *g_c, const uint8_t type, const uint8_t *id)
|
||||
static int32_t get_group_num(const Group_Chats *_Nonnull g_c, const uint8_t type, const uint8_t *_Nonnull id)
|
||||
{
|
||||
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
|
||||
if (g_c->chats[i].type == type && group_id_eq(g_c->chats[i].id, id)) {
|
||||
@@ -419,8 +406,7 @@ int32_t conference_by_id(const Group_Chats *g_c, const uint8_t *id)
|
||||
*
|
||||
* TODO(irungentoo): make this more efficient.
|
||||
*/
|
||||
non_null()
|
||||
static int get_peer_index(const Group_c *g, uint16_t peer_number)
|
||||
static int get_peer_index(const Group_c *_Nonnull g, uint16_t peer_number)
|
||||
{
|
||||
for (uint32_t i = 0; i < g->numpeers; ++i) {
|
||||
if (g->group[i].peer_number == peer_number) {
|
||||
@@ -431,8 +417,7 @@ static int get_peer_index(const Group_c *g, uint16_t peer_number)
|
||||
return -1;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static uint64_t calculate_comp_value(const uint8_t *pk1, const uint8_t *pk2)
|
||||
static uint64_t calculate_comp_value(const uint8_t *_Nonnull pk1, const uint8_t *_Nonnull pk2)
|
||||
{
|
||||
uint64_t cmp1 = 0;
|
||||
uint64_t cmp2 = 0;
|
||||
@@ -451,8 +436,7 @@ typedef enum Groupchat_Closest_Change {
|
||||
GROUPCHAT_CLOSEST_CHANGE_REMOVED,
|
||||
} Groupchat_Closest_Change;
|
||||
|
||||
non_null()
|
||||
static bool add_to_closest(Group_c *g, const uint8_t *real_pk, const uint8_t *temp_pk)
|
||||
static bool add_to_closest(Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk, const uint8_t *_Nonnull temp_pk)
|
||||
{
|
||||
if (pk_equal(g->real_pk, real_pk)) {
|
||||
return false;
|
||||
@@ -527,8 +511,7 @@ static bool add_to_closest(Group_c *g, const uint8_t *real_pk, const uint8_t *te
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool pk_in_closest_peers(const Group_c *g, const uint8_t *real_pk)
|
||||
static bool pk_in_closest_peers(const Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk)
|
||||
{
|
||||
for (unsigned int i = 0; i < DESIRED_CLOSEST; ++i) {
|
||||
if (!g->closest_peers[i].active) {
|
||||
@@ -543,11 +526,9 @@ static bool pk_in_closest_peers(const Group_c *g, const uint8_t *real_pk)
|
||||
return false;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void remove_connection_reason(Group_Chats *g_c, Group_c *g, uint16_t i, uint8_t reason);
|
||||
static void remove_connection_reason(Group_Chats *_Nonnull g_c, Group_c *_Nonnull g, uint16_t i, uint8_t reason);
|
||||
|
||||
non_null()
|
||||
static void purge_closest(Group_Chats *g_c, uint32_t groupnumber)
|
||||
static void purge_closest(Group_Chats *_Nonnull g_c, uint32_t groupnumber)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
@@ -573,19 +554,13 @@ static void purge_closest(Group_Chats *g_c, uint32_t groupnumber)
|
||||
}
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool send_packet_online(const Friend_Connections *fr_c, int friendcon_id, uint16_t group_num,
|
||||
uint8_t type, const uint8_t *id);
|
||||
static bool send_packet_online(const Friend_Connections *_Nonnull fr_c, int friendcon_id, uint16_t group_num, uint8_t type, const uint8_t *_Nonnull id);
|
||||
|
||||
non_null()
|
||||
static int add_conn_to_groupchat(Group_Chats *g_c, int friendcon_id, Group_c *g, uint8_t reason,
|
||||
bool lock);
|
||||
static int add_conn_to_groupchat(Group_Chats *_Nonnull g_c, int friendcon_id, Group_c *_Nonnull g, uint8_t reason, bool lock);
|
||||
|
||||
non_null(1) nullable(3)
|
||||
static void add_closest_connections(Group_Chats *g_c, uint32_t groupnumber, void *userdata)
|
||||
static void add_closest_connections(Group_Chats *_Nonnull g_c, uint32_t groupnumber, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -628,11 +603,9 @@ static void add_closest_connections(Group_Chats *g_c, uint32_t groupnumber, void
|
||||
}
|
||||
}
|
||||
|
||||
non_null(1) nullable(3)
|
||||
static bool connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *userdata)
|
||||
static bool connect_to_closest(Group_Chats *_Nonnull g_c, uint32_t groupnumber, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@@ -656,8 +629,7 @@ static bool connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *use
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static int get_frozen_index(const Group_c *g, uint16_t peer_number)
|
||||
static int get_frozen_index(const Group_c *_Nonnull g, uint16_t peer_number)
|
||||
{
|
||||
for (uint32_t i = 0; i < g->numfrozen; ++i) {
|
||||
if (g->frozen[i].peer_number == peer_number) {
|
||||
@@ -668,8 +640,7 @@ static int get_frozen_index(const Group_c *g, uint16_t peer_number)
|
||||
return -1;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool delete_frozen(const Memory *mem, Group_c *g, uint32_t frozen_index)
|
||||
static bool delete_frozen(const Memory *_Nonnull mem, Group_c *_Nonnull g, uint32_t frozen_index)
|
||||
{
|
||||
if (frozen_index >= g->numfrozen) {
|
||||
return false;
|
||||
@@ -702,11 +673,9 @@ static bool delete_frozen(const Memory *mem, Group_c *g, uint32_t frozen_index)
|
||||
* @return peer index if peer is in the conference.
|
||||
* @retval -1 otherwise, and on error.
|
||||
*/
|
||||
non_null(1) nullable(4)
|
||||
static int note_peer_active(Group_Chats *g_c, uint32_t groupnumber, uint16_t peer_number, void *userdata)
|
||||
static int note_peer_active(Group_Chats *_Nonnull g_c, uint32_t groupnumber, uint16_t peer_number, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -758,14 +727,10 @@ static int note_peer_active(Group_Chats *g_c, uint32_t groupnumber, uint16_t pee
|
||||
return thawed_index;
|
||||
}
|
||||
|
||||
non_null(1) nullable(4)
|
||||
static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void *userdata);
|
||||
|
||||
non_null(1, 3) nullable(4)
|
||||
static void delete_any_peer_with_pk(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_pk, void *userdata)
|
||||
static bool delpeer(Group_Chats *_Nonnull g_c, uint32_t groupnumber, int peer_index, void *_Nullable userdata);
|
||||
static void delete_any_peer_with_pk(Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull real_pk, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -795,12 +760,10 @@ static void delete_any_peer_with_pk(Group_Chats *g_c, uint32_t groupnumber, cons
|
||||
* @return peer_index if success or peer already in chat.
|
||||
* @retval -1 if error.
|
||||
*/
|
||||
non_null(1, 3, 4) nullable(6)
|
||||
static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_pk, const uint8_t *temp_pk,
|
||||
uint16_t peer_number, void *userdata, bool fresh, bool do_gc_callback)
|
||||
static int addpeer(Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull real_pk, const uint8_t *_Nonnull temp_pk,
|
||||
uint16_t peer_number, void *_Nullable userdata, bool fresh, bool do_gc_callback)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -871,8 +834,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p
|
||||
return new_index;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void remove_connection(Group_Chats *g_c, Group_c *g, uint16_t i)
|
||||
static void remove_connection(Group_Chats *_Nonnull g_c, Group_c *_Nonnull g, uint16_t i)
|
||||
{
|
||||
if ((g->connections[i].reasons & GROUPCHAT_CONNECTION_REASON_INTRODUCER) != 0) {
|
||||
--g->num_introducer_connections;
|
||||
@@ -882,8 +844,7 @@ static void remove_connection(Group_Chats *g_c, Group_c *g, uint16_t i)
|
||||
g->connections[i].type = GROUPCHAT_CONNECTION_NONE;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void remove_from_closest(Group_c *g, int peer_index)
|
||||
static void remove_from_closest(Group_c *_Nonnull g, int peer_index)
|
||||
{
|
||||
for (uint32_t i = 0; i < DESIRED_CLOSEST; ++i) {
|
||||
if (g->closest_peers[i].active
|
||||
@@ -958,8 +919,7 @@ static bool delpeer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void
|
||||
}
|
||||
|
||||
/** Order peers with friends first and with more recently active earlier */
|
||||
non_null()
|
||||
static bool group_peer_less_handler(const void *object, const void *a, const void *b)
|
||||
static bool group_peer_less_handler(const void *_Nonnull object, const void *_Nonnull a, const void *_Nonnull b)
|
||||
{
|
||||
const Group_Peer *pa = (const Group_Peer *)a;
|
||||
const Group_Peer *pb = (const Group_Peer *)b;
|
||||
@@ -971,30 +931,26 @@ static bool group_peer_less_handler(const void *object, const void *a, const voi
|
||||
return cmp_uint(pb->last_active, pa->last_active) < 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static const void *group_peer_get_handler(const void *arr, uint32_t index)
|
||||
static const void *group_peer_get_handler(const void *_Nonnull arr, uint32_t index)
|
||||
{
|
||||
const Group_Peer *entries = (const Group_Peer *)arr;
|
||||
return &entries[index];
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void group_peer_set_handler(void *arr, uint32_t index, const void *val)
|
||||
static void group_peer_set_handler(void *_Nonnull arr, uint32_t index, const void *_Nonnull val)
|
||||
{
|
||||
Group_Peer *entries = (Group_Peer *)arr;
|
||||
const Group_Peer *entry = (const Group_Peer *)val;
|
||||
entries[index] = *entry;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void *group_peer_subarr_handler(void *arr, uint32_t index, uint32_t size)
|
||||
static void *group_peer_subarr_handler(void *_Nonnull arr, uint32_t index, uint32_t size)
|
||||
{
|
||||
Group_Peer *entries = (Group_Peer *)arr;
|
||||
return &entries[index];
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void *group_peer_alloc_handler(const void *object, uint32_t size)
|
||||
static void *group_peer_alloc_handler(const void *_Nonnull object, uint32_t size)
|
||||
{
|
||||
const Memory *mem = (const Memory *)object;
|
||||
Group_Peer *tmp = (Group_Peer *)mem_valloc(mem, size, sizeof(Group_Peer));
|
||||
@@ -1006,8 +962,7 @@ static void *group_peer_alloc_handler(const void *object, uint32_t size)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void group_peer_delete_handler(const void *object, void *arr, uint32_t size)
|
||||
static void group_peer_delete_handler(const void *_Nonnull object, void *_Nonnull arr, uint32_t size)
|
||||
{
|
||||
const Memory *mem = (const Memory *)object;
|
||||
mem_delete(mem, arr);
|
||||
@@ -1026,8 +981,7 @@ static const Sort_Funcs group_peer_cmp_funcs = {
|
||||
*
|
||||
* @retval true if any frozen peers are removed.
|
||||
*/
|
||||
non_null()
|
||||
static bool delete_old_frozen(Group_c *g, const Memory *mem)
|
||||
static bool delete_old_frozen(Group_c *_Nonnull g, const Memory *_Nonnull mem)
|
||||
{
|
||||
if (g->numfrozen <= g->maxfrozen) {
|
||||
return false;
|
||||
@@ -1055,14 +1009,11 @@ static bool delete_old_frozen(Group_c *g, const Memory *mem)
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool try_send_rejoin(Group_Chats *g_c, Group_c *g, const uint8_t *real_pk);
|
||||
static bool try_send_rejoin(Group_Chats *_Nonnull g_c, Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk);
|
||||
|
||||
non_null(1) nullable(4)
|
||||
static bool freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, void *userdata)
|
||||
static bool freeze_peer(Group_Chats *_Nonnull g_c, uint32_t groupnumber, int peer_index, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@@ -1098,9 +1049,8 @@ static bool freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index,
|
||||
*
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null(1, 4) nullable(6)
|
||||
static bool setnick(Group_Chats *g_c, uint32_t groupnumber, int peer_index, const uint8_t *nick, uint16_t nick_len,
|
||||
void *userdata, bool do_gc_callback)
|
||||
static bool setnick(Group_Chats *_Nonnull g_c, uint32_t groupnumber, int peer_index, const uint8_t *_Nonnull nick, uint16_t nick_len,
|
||||
void *_Nullable userdata, bool do_gc_callback)
|
||||
{
|
||||
if (nick_len > MAX_NAME_LENGTH) {
|
||||
return false;
|
||||
@@ -1136,9 +1086,8 @@ static bool setnick(Group_Chats *g_c, uint32_t groupnumber, int peer_index, cons
|
||||
*
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null(1, 4) nullable(6)
|
||||
static bool settitle(Group_Chats *g_c, uint32_t groupnumber, int peer_index, const uint8_t *title, uint8_t title_len,
|
||||
void *userdata)
|
||||
static bool settitle(Group_Chats *_Nonnull g_c, uint32_t groupnumber, int peer_index, const uint8_t *_Nonnull title, uint8_t title_len,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
if (title_len > MAX_NAME_LENGTH || title_len == 0) {
|
||||
return false;
|
||||
@@ -1168,11 +1117,9 @@ static bool settitle(Group_Chats *g_c, uint32_t groupnumber, int peer_index, con
|
||||
}
|
||||
|
||||
/** Check if the group has no online connection, and freeze all peers if so */
|
||||
non_null(1) nullable(3)
|
||||
static void check_disconnected(Group_Chats *g_c, uint32_t groupnumber, void *userdata)
|
||||
static void check_disconnected(Group_Chats *_Nonnull g_c, uint32_t groupnumber, void *_Nullable userdata)
|
||||
{
|
||||
const Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -1190,12 +1137,10 @@ static void check_disconnected(Group_Chats *g_c, uint32_t groupnumber, void *use
|
||||
}
|
||||
}
|
||||
|
||||
non_null(1) nullable(5)
|
||||
static void set_conns_type_connections(Group_Chats *g_c, uint32_t groupnumber, int friendcon_id, uint8_t type,
|
||||
void *userdata)
|
||||
static void set_conns_type_connections(Group_Chats *_Nonnull g_c, uint32_t groupnumber, int friendcon_id, uint8_t type,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -1219,16 +1164,14 @@ static void set_conns_type_connections(Group_Chats *g_c, uint32_t groupnumber, i
|
||||
}
|
||||
|
||||
/** Set the type for all connections with friendcon_id */
|
||||
non_null(1) nullable(4)
|
||||
static void set_conns_status_groups(Group_Chats *g_c, int friendcon_id, uint8_t type, void *userdata)
|
||||
static void set_conns_status_groups(Group_Chats *_Nonnull g_c, int friendcon_id, uint8_t type, void *_Nullable userdata)
|
||||
{
|
||||
for (uint16_t i = 0; i < g_c->num_chats; ++i) {
|
||||
set_conns_type_connections(g_c, i, friendcon_id, type, userdata);
|
||||
}
|
||||
}
|
||||
|
||||
non_null()
|
||||
static void rejoin_frozen_friend(Group_Chats *g_c, int friendcon_id)
|
||||
static void rejoin_frozen_friend(Group_Chats *_Nonnull g_c, int friendcon_id)
|
||||
{
|
||||
uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE];
|
||||
get_friendcon_public_keys(real_pk, nullptr, g_c->fr_c, friendcon_id);
|
||||
@@ -1249,11 +1192,9 @@ static void rejoin_frozen_friend(Group_Chats *g_c, int friendcon_id)
|
||||
}
|
||||
}
|
||||
|
||||
non_null(1) nullable(4)
|
||||
static int g_handle_any_status(void *object, int friendcon_id, bool status, void *userdata)
|
||||
static int g_handle_any_status(void *_Nonnull object, int friendcon_id, bool status, void *_Nullable userdata)
|
||||
{
|
||||
Group_Chats *g_c = (Group_Chats *)object;
|
||||
|
||||
if (status) {
|
||||
rejoin_frozen_friend(g_c, friendcon_id);
|
||||
}
|
||||
@@ -1261,11 +1202,9 @@ static int g_handle_any_status(void *object, int friendcon_id, bool status, void
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1) nullable(4)
|
||||
static int g_handle_status(void *object, int friendcon_id, bool status, void *userdata)
|
||||
static int g_handle_status(void *_Nonnull object, int friendcon_id, bool status, void *_Nullable userdata)
|
||||
{
|
||||
Group_Chats *g_c = (Group_Chats *)object;
|
||||
|
||||
if (status) { /* Went online */
|
||||
set_conns_status_groups(g_c, friendcon_id, GROUPCHAT_CONNECTION_ONLINE, userdata);
|
||||
} else { /* Went offline */
|
||||
@@ -1276,11 +1215,8 @@ static int g_handle_status(void *object, int friendcon_id, bool status, void *us
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int g_handle_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata);
|
||||
non_null(1, 3) nullable(5)
|
||||
static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata);
|
||||
|
||||
static int g_handle_packet(void *_Nonnull object, int friendcon_id, const uint8_t *_Nonnull data, uint16_t length, void *_Nullable userdata);
|
||||
static int handle_lossy(void *_Nonnull object, int friendcon_id, const uint8_t *_Nonnull data, uint16_t length, void *_Nullable userdata);
|
||||
/** @brief Add friend to group chat.
|
||||
*
|
||||
* @return connections index on success
|
||||
@@ -1333,8 +1269,7 @@ static int add_conn_to_groupchat(Group_Chats *g_c, int friendcon_id, Group_c *g,
|
||||
return ind;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool send_peer_introduced(const Group_Chats *g_c, int friendcon_id, uint16_t group_num);
|
||||
static bool send_peer_introduced(const Group_Chats *_Nonnull g_c, int friendcon_id, uint16_t group_num);
|
||||
|
||||
/** @brief Removes reason for keeping connection.
|
||||
*
|
||||
@@ -1397,8 +1332,7 @@ int add_groupchat(Group_Chats *g_c, const Random *rng, uint8_t type)
|
||||
return groupnumber;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool group_leave(const Group_Chats *g_c, uint32_t groupnumber, bool permanent);
|
||||
static bool group_leave(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, bool permanent);
|
||||
|
||||
/** @brief Delete a groupchat from the chats array, informing the group first as
|
||||
* appropriate.
|
||||
@@ -1438,8 +1372,7 @@ bool del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanentl
|
||||
return wipe_group_chat(g_c, groupnumber);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static const Group_Peer *peer_in_list(const Group_c *g, uint32_t peernumber, bool frozen)
|
||||
static const Group_Peer *peer_in_list(const Group_c *_Nonnull g, uint32_t peernumber, bool frozen)
|
||||
{
|
||||
const Group_Peer *list = frozen ? g->frozen : g->group;
|
||||
const uint32_t num = frozen ? g->numfrozen : g->numpeers;
|
||||
@@ -1658,9 +1591,7 @@ bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id
|
||||
* @retval true on success
|
||||
* @retval false on failure
|
||||
*/
|
||||
non_null()
|
||||
static bool send_packet_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
static bool send_packet_group_peer(const Friend_Connections *_Nonnull fr_c, int friendcon_id, uint8_t packet_id, uint16_t group_num, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (1 + sizeof(uint16_t) + length > MAX_CRYPTO_DATA_SIZE) {
|
||||
return false;
|
||||
@@ -1681,9 +1612,7 @@ static bool send_packet_group_peer(const Friend_Connections *fr_c, int friendcon
|
||||
* @retval true on success
|
||||
* @retval false on failure
|
||||
*/
|
||||
non_null()
|
||||
static bool send_lossy_group_peer(const Friend_Connections *fr_c, int friendcon_id, uint8_t packet_id,
|
||||
uint16_t group_num, const uint8_t *data, uint16_t length)
|
||||
static bool send_lossy_group_peer(const Friend_Connections *_Nonnull fr_c, int friendcon_id, uint8_t packet_id, uint16_t group_num, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (1 + sizeof(uint16_t) + length > MAX_CRYPTO_DATA_SIZE) {
|
||||
return false;
|
||||
@@ -1759,12 +1688,9 @@ static bool try_send_rejoin(Group_Chats *g_c, Group_c *g, const uint8_t *real_pk
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool send_peer_query(const Group_Chats *g_c, int friendcon_id, uint16_t group_num);
|
||||
static bool send_peer_query(const Group_Chats *_Nonnull g_c, int friendcon_id, uint16_t group_num);
|
||||
|
||||
non_null()
|
||||
static bool send_invite_response(Group_Chats *g_c, int groupnumber, uint32_t friendnumber, const uint8_t *data,
|
||||
uint16_t length);
|
||||
static bool send_invite_response(Group_Chats *_Nonnull g_c, int groupnumber, uint32_t friendnumber, const uint8_t *_Nonnull data, uint16_t length);
|
||||
|
||||
/** @brief Join a group (we need to have been invited first).
|
||||
*
|
||||
@@ -1972,15 +1898,12 @@ int callback_groupchat_delete(const Group_Chats *g_c, uint32_t groupnumber, grou
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1) nullable(4)
|
||||
static int send_message_group(const Group_Chats *g_c, uint32_t groupnumber, uint8_t message_id, const uint8_t *data,
|
||||
static int send_message_group(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, uint8_t message_id, const uint8_t *_Nullable data,
|
||||
uint16_t len);
|
||||
|
||||
/** @brief send a ping message
|
||||
* return true on success
|
||||
*/
|
||||
non_null()
|
||||
static bool group_ping_send(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
static bool group_ping_send(const Group_Chats *_Nonnull g_c, uint32_t groupnumber)
|
||||
{
|
||||
return send_message_group(g_c, groupnumber, GROUP_MESSAGE_PING_ID, nullptr, 0) > 0;
|
||||
}
|
||||
@@ -1988,9 +1911,7 @@ static bool group_ping_send(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
/** @brief send a new_peer message
|
||||
* return true on success
|
||||
*/
|
||||
non_null()
|
||||
static bool group_new_peer_send(const Group_Chats *g_c, uint32_t groupnumber, uint16_t peer_num, const uint8_t *real_pk,
|
||||
const uint8_t *temp_pk)
|
||||
static bool group_new_peer_send(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, uint16_t peer_num, const uint8_t *_Nonnull real_pk, const uint8_t *_Nonnull temp_pk)
|
||||
{
|
||||
uint8_t packet[GROUP_MESSAGE_NEW_PEER_LENGTH];
|
||||
|
||||
@@ -2005,8 +1926,7 @@ static bool group_new_peer_send(const Group_Chats *g_c, uint32_t groupnumber, ui
|
||||
/** @brief send a kill_peer message
|
||||
* return true on success
|
||||
*/
|
||||
non_null()
|
||||
static bool group_kill_peer_send(const Group_Chats *g_c, uint32_t groupnumber, uint16_t peer_num)
|
||||
static bool group_kill_peer_send(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, uint16_t peer_num)
|
||||
{
|
||||
uint8_t packet[GROUP_MESSAGE_KILL_PEER_LENGTH];
|
||||
|
||||
@@ -2019,8 +1939,7 @@ static bool group_kill_peer_send(const Group_Chats *g_c, uint32_t groupnumber, u
|
||||
/** @brief send a freeze_peer message
|
||||
* return true on success
|
||||
*/
|
||||
non_null()
|
||||
static bool group_freeze_peer_send(const Group_Chats *g_c, uint32_t groupnumber, uint16_t peer_num)
|
||||
static bool group_freeze_peer_send(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, uint16_t peer_num)
|
||||
{
|
||||
uint8_t packet[GROUP_MESSAGE_KILL_PEER_LENGTH];
|
||||
|
||||
@@ -2033,8 +1952,7 @@ static bool group_freeze_peer_send(const Group_Chats *g_c, uint32_t groupnumber,
|
||||
/** @brief send a name message
|
||||
* return true on success
|
||||
*/
|
||||
non_null()
|
||||
static bool group_name_send(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t *nick, uint16_t nick_len)
|
||||
static bool group_name_send(const Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull nick, uint16_t nick_len)
|
||||
{
|
||||
if (nick_len > MAX_NAME_LENGTH) {
|
||||
return false;
|
||||
@@ -2141,8 +2059,7 @@ int group_title_get(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *title
|
||||
return g->title_len;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool get_peer_number(const Group_c *g, const uint8_t *real_pk, uint16_t *peer_number)
|
||||
static bool get_peer_number(const Group_c *_Nonnull g, const uint8_t *_Nonnull real_pk, uint16_t *_Nonnull peer_number)
|
||||
{
|
||||
const int peer_index = peer_in_group(g, real_pk);
|
||||
|
||||
@@ -2161,12 +2078,10 @@ static bool get_peer_number(const Group_c *g, const uint8_t *real_pk, uint16_t *
|
||||
return false;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static void handle_friend_invite_packet(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
|
||||
void *user_data)
|
||||
static void handle_friend_invite_packet(Messenger *_Nonnull m, uint32_t friend_number, const uint8_t *_Nonnull cookie, uint16_t length,
|
||||
void *_Nullable user_data)
|
||||
{
|
||||
Group_Chats *g_c = m->conferences_object;
|
||||
|
||||
if (length <= 1) {
|
||||
return;
|
||||
}
|
||||
@@ -2289,8 +2204,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friend_number, co
|
||||
* return index on success
|
||||
* return -1 on failure.
|
||||
*/
|
||||
non_null()
|
||||
static int friend_in_connections(const Group_c *g, int friendcon_id)
|
||||
static int friend_in_connections(const Group_c *_Nonnull g, int friendcon_id)
|
||||
{
|
||||
for (unsigned int i = 0; i < MAX_GROUP_CONNECTIONS; ++i) {
|
||||
if (g->connections[i].type == GROUPCHAT_CONNECTION_NONE) {
|
||||
@@ -2306,8 +2220,7 @@ static int friend_in_connections(const Group_c *g, int friendcon_id)
|
||||
}
|
||||
|
||||
/** return number of connections. */
|
||||
non_null()
|
||||
static unsigned int count_connected(const Group_c *g)
|
||||
static unsigned int count_connected(const Group_c *_Nonnull g)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
|
||||
@@ -2333,11 +2246,9 @@ static bool send_packet_online(const Friend_Connections *fr_c, int friendcon_id,
|
||||
sizeof(packet), false) != -1;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool ping_groupchat(const Group_Chats *g_c, uint32_t groupnumber);
|
||||
static bool ping_groupchat(const Group_Chats *_Nonnull g_c, uint32_t groupnumber);
|
||||
|
||||
non_null()
|
||||
static int handle_packet_online(const Group_Chats *g_c, int friendcon_id, const uint8_t *data, uint16_t length)
|
||||
static int handle_packet_online(const Group_Chats *_Nonnull g_c, int friendcon_id, const uint8_t *_Nonnull data, uint16_t length)
|
||||
{
|
||||
if (length != ONLINE_PACKET_DATA_SIZE) {
|
||||
return -1;
|
||||
@@ -2396,9 +2307,8 @@ static int handle_packet_online(const Group_Chats *g_c, int friendcon_id, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int handle_packet_rejoin(Group_Chats *g_c, int friendcon_id, const uint8_t *data, uint16_t length,
|
||||
void *userdata)
|
||||
static int handle_packet_rejoin(Group_Chats *_Nonnull g_c, int friendcon_id, const uint8_t *_Nonnull data, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
if (length < 1 + GROUP_ID_LENGTH) {
|
||||
return -1;
|
||||
@@ -2461,8 +2371,7 @@ static bool send_peer_query(const Group_Chats *g_c, int friendcon_id, uint16_t g
|
||||
* @return number of peers sent on success.
|
||||
* @retval 0 on failure.
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int send_peers(const Group_Chats *g_c, const Group_c *g, int friendcon_id, uint16_t group_num)
|
||||
static unsigned int send_peers(const Group_Chats *_Nonnull g_c, const Group_c *_Nonnull g, int friendcon_id, uint16_t group_num)
|
||||
{
|
||||
uint8_t response_packet[MAX_CRYPTO_DATA_SIZE - (1 + sizeof(uint16_t))];
|
||||
response_packet[0] = PEER_RESPONSE_ID;
|
||||
@@ -2513,9 +2422,8 @@ static unsigned int send_peers(const Group_Chats *g_c, const Group_c *g, int fri
|
||||
return sent;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(5)
|
||||
static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, uint16_t length,
|
||||
void *userdata)
|
||||
static int handle_send_peers(Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull data, uint16_t length,
|
||||
void *_Nullable userdata)
|
||||
{
|
||||
if (length == 0) {
|
||||
return -1;
|
||||
@@ -2571,9 +2479,8 @@ static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(6)
|
||||
static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, uint16_t length,
|
||||
uint32_t connection_index, void *userdata)
|
||||
static void handle_direct_packet(Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull data, uint16_t length,
|
||||
uint32_t connection_index, void *_Nullable userdata)
|
||||
{
|
||||
if (length == 0) {
|
||||
return;
|
||||
@@ -2621,9 +2528,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u
|
||||
*
|
||||
* @return number of messages sent.
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int send_message_all_connections(const Group_Chats *g_c, const Group_c *g, const uint8_t *data,
|
||||
uint16_t length, int receiver)
|
||||
static unsigned int send_message_all_connections(const Group_Chats *_Nonnull g_c, const Group_c *_Nonnull g, const uint8_t *_Nonnull data, uint16_t length, int receiver)
|
||||
{
|
||||
uint16_t sent = 0;
|
||||
|
||||
@@ -2651,9 +2556,7 @@ static unsigned int send_message_all_connections(const Group_Chats *g_c, const G
|
||||
*
|
||||
* @return number of messages sent.
|
||||
*/
|
||||
non_null()
|
||||
static unsigned int send_lossy_all_connections(const Group_Chats *g_c, const Group_c *g, const uint8_t *data,
|
||||
uint16_t length, int receiver)
|
||||
static unsigned int send_lossy_all_connections(const Group_Chats *_Nonnull g_c, const Group_c *_Nonnull g, const uint8_t *_Nonnull data, uint16_t length, int receiver)
|
||||
{
|
||||
unsigned int sent = 0;
|
||||
unsigned int num_connected_closest = 0;
|
||||
@@ -2829,8 +2732,7 @@ int send_group_lossy_packet(const Group_Chats *g_c, uint32_t groupnumber, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_t message_id, Group_Peer *peer)
|
||||
static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_t message_id, Group_Peer *_Nonnull peer)
|
||||
{
|
||||
const bool ignore_older = message_id == GROUP_MESSAGE_NAME_ID || message_id == GROUP_MESSAGE_TITLE_ID;
|
||||
|
||||
@@ -2858,8 +2760,7 @@ static Message_Info *find_message_slot_or_reject(uint32_t message_number, uint8_
|
||||
* @retval true if message should be processed.
|
||||
* @retval false otherwise.
|
||||
*/
|
||||
non_null()
|
||||
static bool check_message_info(uint32_t message_number, uint8_t message_id, Group_Peer *peer)
|
||||
static bool check_message_info(uint32_t message_number, uint8_t message_id, Group_Peer *_Nonnull peer)
|
||||
{
|
||||
Message_Info *const i = find_message_slot_or_reject(message_number, message_id, peer);
|
||||
|
||||
@@ -2883,9 +2784,8 @@ static bool check_message_info(uint32_t message_number, uint8_t message_id, Grou
|
||||
return true;
|
||||
}
|
||||
|
||||
non_null(1, 3) nullable(6)
|
||||
static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, uint16_t length,
|
||||
uint32_t connection_index, void *userdata)
|
||||
static void handle_message_packet_group(Group_Chats *_Nonnull g_c, uint32_t groupnumber, const uint8_t *_Nonnull data, uint16_t length,
|
||||
uint32_t connection_index, void *_Nullable userdata)
|
||||
{
|
||||
if (length < sizeof(uint16_t) + sizeof(uint32_t) + 1) {
|
||||
return;
|
||||
@@ -3115,8 +3015,7 @@ static int g_handle_packet(void *object, int friendcon_id, const uint8_t *data,
|
||||
*
|
||||
* TODO(irungentoo): test this
|
||||
*/
|
||||
non_null()
|
||||
static int lossy_packet_not_received(const Group_c *g, int peer_index, uint16_t message_number)
|
||||
static int lossy_packet_not_received(const Group_c *_Nonnull g, int peer_index, uint16_t message_number)
|
||||
{
|
||||
if (peer_index == -1) {
|
||||
return -1;
|
||||
@@ -3337,11 +3236,9 @@ static bool ping_groupchat(const Group_Chats *g_c, uint32_t groupnumber)
|
||||
/** Seconds of inactivity after which to freeze a peer */
|
||||
#define FREEZE_TIMEOUT (GROUP_PING_INTERVAL * 3)
|
||||
|
||||
non_null(1) nullable(3)
|
||||
static bool groupchat_freeze_timedout(Group_Chats *g_c, uint32_t groupnumber, void *userdata)
|
||||
static bool groupchat_freeze_timedout(Group_Chats *_Nonnull g_c, uint32_t groupnumber, void *_Nullable userdata)
|
||||
{
|
||||
Group_c *g = get_group_c(g_c, groupnumber);
|
||||
|
||||
if (g == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@@ -3364,8 +3261,7 @@ static bool groupchat_freeze_timedout(Group_Chats *g_c, uint32_t groupnumber, vo
|
||||
}
|
||||
|
||||
/** Push non-empty slots to start. */
|
||||
non_null()
|
||||
static void squash_connections(Group_c *g)
|
||||
static void squash_connections(Group_c *_Nonnull g)
|
||||
{
|
||||
uint16_t num_connected = 0;
|
||||
|
||||
@@ -3383,8 +3279,7 @@ static void squash_connections(Group_c *g)
|
||||
|
||||
#define MIN_EMPTY_CONNECTIONS (1 + MAX_GROUP_CONNECTIONS / 10)
|
||||
|
||||
non_null()
|
||||
static uint16_t empty_connection_count(const Group_c *g)
|
||||
static uint16_t empty_connection_count(const Group_c *_Nonnull g)
|
||||
{
|
||||
uint16_t to_clear = MIN_EMPTY_CONNECTIONS;
|
||||
|
||||
@@ -3408,8 +3303,7 @@ static uint16_t empty_connection_count(const Group_c *g)
|
||||
* This invalidates connections array indices (which is
|
||||
* why we do this periodically rather than on adding a connection).
|
||||
*/
|
||||
non_null()
|
||||
static void clean_connections(Group_Chats *g_c, Group_c *g)
|
||||
static void clean_connections(Group_Chats *_Nonnull g_c, Group_c *_Nonnull g)
|
||||
{
|
||||
for (uint16_t to_clear = empty_connection_count(g); to_clear > 0; --to_clear) {
|
||||
// Remove a connection. Prefer non-closest connections, and given
|
||||
@@ -3460,14 +3354,12 @@ void send_name_all_groups(const Group_Chats *g_c)
|
||||
|
||||
#define SAVED_PEER_SIZE_CONSTANT (2 * CRYPTO_PUBLIC_KEY_SIZE + sizeof(uint16_t) + sizeof(uint64_t) + 1)
|
||||
|
||||
non_null()
|
||||
static uint32_t saved_peer_size(const Group_Peer *peer)
|
||||
static uint32_t saved_peer_size(const Group_Peer *_Nonnull peer)
|
||||
{
|
||||
return SAVED_PEER_SIZE_CONSTANT + peer->nick_len;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static uint8_t *save_peer(const Group_Peer *peer, uint8_t *data)
|
||||
static uint8_t *save_peer(const Group_Peer *_Nonnull peer, uint8_t *_Nonnull data)
|
||||
{
|
||||
memcpy(data, peer->real_pk, CRYPTO_PUBLIC_KEY_SIZE);
|
||||
data += CRYPTO_PUBLIC_KEY_SIZE;
|
||||
@@ -3494,8 +3386,7 @@ static uint8_t *save_peer(const Group_Peer *peer, uint8_t *data)
|
||||
#define SAVED_CONF_SIZE_CONSTANT (1 + GROUP_ID_LENGTH + sizeof(uint32_t) \
|
||||
+ sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + 1)
|
||||
|
||||
non_null()
|
||||
static uint32_t saved_conf_size(const Group_c *g)
|
||||
static uint32_t saved_conf_size(const Group_c *_Nonnull g)
|
||||
{
|
||||
uint32_t len = SAVED_CONF_SIZE_CONSTANT + g->title_len;
|
||||
|
||||
@@ -3519,8 +3410,7 @@ static uint32_t saved_conf_size(const Group_c *g)
|
||||
#define SAVE_OFFSET_MESSAGE_NUMBER (1 << 16)
|
||||
#define SAVE_OFFSET_LOSSY_MESSAGE_NUMBER (1 << 13)
|
||||
|
||||
non_null()
|
||||
static uint8_t *save_conf(const Group_c *g, uint8_t *data)
|
||||
static uint8_t *save_conf(const Group_c *_Nonnull g, uint8_t *_Nonnull data)
|
||||
{
|
||||
*data = g->type;
|
||||
++data;
|
||||
@@ -3564,8 +3454,7 @@ static uint8_t *save_conf(const Group_c *g, uint8_t *data)
|
||||
return data;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static uint32_t conferences_section_size(const Group_Chats *g_c)
|
||||
static uint32_t conferences_section_size(const Group_Chats *_Nonnull g_c)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
|
||||
@@ -3613,8 +3502,7 @@ uint8_t *conferences_save(const Group_Chats *g_c, uint8_t *data)
|
||||
* @param length Length of data
|
||||
* @return 0 on error, number of consumed bytes otherwise
|
||||
*/
|
||||
non_null()
|
||||
static uint32_t load_group(Group_c *g, const Group_Chats *g_c, const uint8_t *data, uint32_t length)
|
||||
static uint32_t load_group(Group_c *_Nonnull g, const Group_Chats *_Nonnull g_c, const uint8_t *_Nonnull data, uint32_t length)
|
||||
{
|
||||
const uint8_t *init_data = data;
|
||||
|
||||
@@ -3721,8 +3609,7 @@ static uint32_t load_group(Group_c *g, const Group_Chats *g_c, const uint8_t *da
|
||||
return (uint32_t)(data - init_data);
|
||||
}
|
||||
|
||||
non_null()
|
||||
static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t *data, uint32_t length)
|
||||
static State_Load_Status load_conferences_helper(Group_Chats *_Nonnull g_c, const uint8_t *_Nonnull data, uint32_t length)
|
||||
{
|
||||
const uint8_t *init_data = data;
|
||||
|
||||
@@ -3772,8 +3659,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t
|
||||
return STATE_LOAD_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
non_null()
|
||||
static State_Load_Status load_conferences(Group_Chats *g_c, const uint8_t *data, uint32_t length)
|
||||
static State_Load_Status load_conferences(Group_Chats *_Nonnull g_c, const uint8_t *_Nonnull data, uint32_t length)
|
||||
{
|
||||
const State_Load_Status res = load_conferences_helper(g_c, data, length);
|
||||
|
||||
|
Reference in New Issue
Block a user