diff options
author | zugz (tox) <mbays+tox@sdf.org> | 2018-11-17 21:33:46 +0100 |
---|---|---|
committer | zugz (tox) <mbays+tox@sdf.org> | 2019-01-12 22:38:51 +0100 |
commit | a4bca35a1a6e17187f821dbbdfe02798f7f1469e (patch) | |
tree | 3de607d558683b9d980f63c1ead00556e89248df /toxcore/group.c | |
parent | 91ff39599d97d610321970161ba6410f3bdd9b51 (diff) |
Add some const qualifiers
(Implementing suggestions of sudden6)
Diffstat (limited to 'toxcore/group.c')
-rw-r--r-- | toxcore/group.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index d0609b1a..101c1196 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -251,7 +251,7 @@ int32_t conference_by_id(const Group_Chats *g_c, const uint8_t *id) | |||
251 | * | 251 | * |
252 | * TODO(irungentoo): make this more efficient. | 252 | * TODO(irungentoo): make this more efficient. |
253 | */ | 253 | */ |
254 | static int get_peer_index(Group_c *g, uint16_t peer_number) | 254 | static int get_peer_index(const Group_c *g, uint16_t peer_number) |
255 | { | 255 | { |
256 | for (uint32_t i = 0; i < g->numpeers; ++i) { | 256 | for (uint32_t i = 0; i < g->numpeers; ++i) { |
257 | if (g->group[i].peer_number == peer_number) { | 257 | if (g->group[i].peer_number == peer_number) { |
@@ -283,7 +283,6 @@ typedef enum Groupchat_Closest { | |||
283 | 283 | ||
284 | static int add_to_closest(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_pk, const uint8_t *temp_pk) | 284 | static int add_to_closest(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_pk, const uint8_t *temp_pk) |
285 | { | 285 | { |
286 | // TODO(zugz): this can be const. Similarly throughout the file. | ||
287 | Group_c *g = get_group_c(g_c, groupnumber); | 286 | Group_c *g = get_group_c(g_c, groupnumber); |
288 | 287 | ||
289 | if (!g) { | 288 | if (!g) { |
@@ -365,7 +364,7 @@ static int add_to_closest(Group_Chats *g_c, uint32_t groupnumber, const uint8_t | |||
365 | return 0; | 364 | return 0; |
366 | } | 365 | } |
367 | 366 | ||
368 | static unsigned int pk_in_closest_peers(Group_c *g, uint8_t *real_pk) | 367 | static unsigned int pk_in_closest_peers(const Group_c *g, uint8_t *real_pk) |
369 | { | 368 | { |
370 | unsigned int i; | 369 | unsigned int i; |
371 | 370 | ||
@@ -388,7 +387,7 @@ static int add_conn_to_groupchat(Group_Chats *g_c, int friendcon_id, uint32_t gr | |||
388 | static void remove_conn_reason(Group_Chats *g_c, uint32_t groupnumber, uint16_t i, uint8_t reason); | 387 | static void remove_conn_reason(Group_Chats *g_c, uint32_t groupnumber, uint16_t i, uint8_t reason); |
389 | 388 | ||
390 | static int send_packet_online(Friend_Connections *fr_c, int friendcon_id, uint16_t group_num, uint8_t type, | 389 | static int send_packet_online(Friend_Connections *fr_c, int friendcon_id, uint16_t group_num, uint8_t type, |
391 | uint8_t *id); | 390 | const uint8_t *id); |
392 | 391 | ||
393 | static int connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *userdata) | 392 | static int connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *userdata) |
394 | { | 393 | { |
@@ -458,7 +457,7 @@ static int connect_to_closest(Group_Chats *g_c, uint32_t groupnumber, void *user | |||
458 | return 0; | 457 | return 0; |
459 | } | 458 | } |
460 | 459 | ||
461 | static int get_frozen_index(Group_c *g, uint16_t peer_number) | 460 | static int get_frozen_index(const Group_c *g, uint16_t peer_number) |
462 | { | 461 | { |
463 | for (uint32_t i = 0; i < g->numfrozen; ++i) { | 462 | for (uint32_t i = 0; i < g->numfrozen; ++i) { |
464 | if (g->frozen[i].peer_number == peer_number) { | 463 | if (g->frozen[i].peer_number == peer_number) { |
@@ -485,7 +484,7 @@ static bool delete_frozen(Group_c *g, uint32_t frozen_index) | |||
485 | g->frozen[frozen_index] = g->frozen[g->numfrozen]; | 484 | g->frozen[frozen_index] = g->frozen[g->numfrozen]; |
486 | } | 485 | } |
487 | 486 | ||
488 | Group_Peer *frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * (g->numfrozen)); | 487 | Group_Peer *const frozen_temp = (Group_Peer *)realloc(g->frozen, sizeof(Group_Peer) * (g->numfrozen)); |
489 | 488 | ||
490 | if (frozen_temp == nullptr) { | 489 | if (frozen_temp == nullptr) { |
491 | return false; | 490 | return false; |
@@ -567,13 +566,13 @@ static void delete_any_peer_with_pk(Group_Chats *g_c, uint32_t groupnumber, cons | |||
567 | return; | 566 | return; |
568 | } | 567 | } |
569 | 568 | ||
570 | int prev_peer_index = peer_in_chat(g, real_pk); | 569 | const int prev_peer_index = peer_in_chat(g, real_pk); |
571 | 570 | ||
572 | if (prev_peer_index >= 0) { | 571 | if (prev_peer_index >= 0) { |
573 | delpeer(g_c, groupnumber, prev_peer_index, userdata, false); | 572 | delpeer(g_c, groupnumber, prev_peer_index, userdata, false); |
574 | } | 573 | } |
575 | 574 | ||
576 | int prev_frozen_index = frozen_in_chat(g, real_pk); | 575 | const int prev_frozen_index = frozen_in_chat(g, real_pk); |
577 | 576 | ||
578 | if (prev_frozen_index >= 0) { | 577 | if (prev_frozen_index >= 0) { |
579 | delete_frozen(g, prev_frozen_index); | 578 | delete_frozen(g, prev_frozen_index); |
@@ -1139,7 +1138,7 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently | |||
1139 | */ | 1138 | */ |
1140 | int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *pk, bool frozen) | 1139 | int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *pk, bool frozen) |
1141 | { | 1140 | { |
1142 | Group_c *g = get_group_c(g_c, groupnumber); | 1141 | const Group_c *g = get_group_c(g_c, groupnumber); |
1143 | 1142 | ||
1144 | if (!g) { | 1143 | if (!g) { |
1145 | return -1; | 1144 | return -1; |
@@ -1164,7 +1163,7 @@ int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, int peernumb | |||
1164 | */ | 1163 | */ |
1165 | int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, bool frozen) | 1164 | int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, bool frozen) |
1166 | { | 1165 | { |
1167 | Group_c *g = get_group_c(g_c, groupnumber); | 1166 | const Group_c *g = get_group_c(g_c, groupnumber); |
1168 | 1167 | ||
1169 | if (!g) { | 1168 | if (!g) { |
1170 | return -1; | 1169 | return -1; |
@@ -1193,7 +1192,7 @@ int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, int peernu | |||
1193 | */ | 1192 | */ |
1194 | int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *name, bool frozen) | 1193 | int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *name, bool frozen) |
1195 | { | 1194 | { |
1196 | Group_c *g = get_group_c(g_c, groupnumber); | 1195 | const Group_c *g = get_group_c(g_c, groupnumber); |
1197 | 1196 | ||
1198 | if (!g) { | 1197 | if (!g) { |
1199 | return -1; | 1198 | return -1; |
@@ -1224,7 +1223,7 @@ int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, | |||
1224 | int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, | 1223 | int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, |
1225 | uint64_t *last_active) | 1224 | uint64_t *last_active) |
1226 | { | 1225 | { |
1227 | Group_c *g = get_group_c(g_c, groupnumber); | 1226 | const Group_c *g = get_group_c(g_c, groupnumber); |
1228 | 1227 | ||
1229 | if (!g) { | 1228 | if (!g) { |
1230 | return -1; | 1229 | return -1; |
@@ -1251,7 +1250,7 @@ int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, int p | |||
1251 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], | 1250 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], |
1252 | uint16_t length, bool frozen) | 1251 | uint16_t length, bool frozen) |
1253 | { | 1252 | { |
1254 | Group_c *g = get_group_c(g_c, groupnumber); | 1253 | const Group_c *g = get_group_c(g_c, groupnumber); |
1255 | 1254 | ||
1256 | if (!g) { | 1255 | if (!g) { |
1257 | return -1; | 1256 | return -1; |
@@ -1274,7 +1273,7 @@ int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MA | |||
1274 | */ | 1273 | */ |
1275 | int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen) | 1274 | int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen) |
1276 | { | 1275 | { |
1277 | Group_c *g = get_group_c(g_c, groupnumber); | 1276 | const Group_c *g = get_group_c(g_c, groupnumber); |
1278 | 1277 | ||
1279 | if (!g) { | 1278 | if (!g) { |
1280 | return -1; | 1279 | return -1; |
@@ -1291,7 +1290,7 @@ int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen | |||
1291 | */ | 1290 | */ |
1292 | int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int peernumber) | 1291 | int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int peernumber) |
1293 | { | 1292 | { |
1294 | Group_c *g = get_group_c(g_c, groupnumber); | 1293 | const Group_c *g = get_group_c(g_c, groupnumber); |
1295 | 1294 | ||
1296 | if (!g) { | 1295 | if (!g) { |
1297 | return -1; | 1296 | return -1; |
@@ -1712,7 +1711,7 @@ static int group_name_send(const Group_Chats *g_c, uint32_t groupnumber, const u | |||
1712 | */ | 1711 | */ |
1713 | static bool group_leave(const Group_Chats *g_c, uint32_t groupnumber, bool permanent) | 1712 | static bool group_leave(const Group_Chats *g_c, uint32_t groupnumber, bool permanent) |
1714 | { | 1713 | { |
1715 | Group_c *g = get_group_c(g_c, groupnumber); | 1714 | const Group_c *g = get_group_c(g_c, groupnumber); |
1716 | 1715 | ||
1717 | if (!g) { | 1716 | if (!g) { |
1718 | return false; | 1717 | return false; |
@@ -1769,7 +1768,7 @@ int group_title_send(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t | |||
1769 | */ | 1768 | */ |
1770 | int group_title_get_size(const Group_Chats *g_c, uint32_t groupnumber) | 1769 | int group_title_get_size(const Group_Chats *g_c, uint32_t groupnumber) |
1771 | { | 1770 | { |
1772 | Group_c *g = get_group_c(g_c, groupnumber); | 1771 | const Group_c *g = get_group_c(g_c, groupnumber); |
1773 | 1772 | ||
1774 | if (!g) { | 1773 | if (!g) { |
1775 | return -1; | 1774 | return -1; |
@@ -1791,7 +1790,7 @@ int group_title_get_size(const Group_Chats *g_c, uint32_t groupnumber) | |||
1791 | */ | 1790 | */ |
1792 | int group_title_get(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *title) | 1791 | int group_title_get(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *title) |
1793 | { | 1792 | { |
1794 | Group_c *g = get_group_c(g_c, groupnumber); | 1793 | const Group_c *g = get_group_c(g_c, groupnumber); |
1795 | 1794 | ||
1796 | if (!g) { | 1795 | if (!g) { |
1797 | return -1; | 1796 | return -1; |
@@ -1929,7 +1928,7 @@ static void handle_friend_invite_packet(Messenger *m, uint32_t friendnumber, con | |||
1929 | * returns index on success | 1928 | * returns index on success |
1930 | * returns -1 on failure. | 1929 | * returns -1 on failure. |
1931 | */ | 1930 | */ |
1932 | static int friend_in_close(Group_c *g, int friendcon_id) | 1931 | static int friend_in_close(const Group_c *g, int friendcon_id) |
1933 | { | 1932 | { |
1934 | unsigned int i; | 1933 | unsigned int i; |
1935 | 1934 | ||
@@ -1950,7 +1949,7 @@ static int friend_in_close(Group_c *g, int friendcon_id) | |||
1950 | 1949 | ||
1951 | /* return number of connected close connections. | 1950 | /* return number of connected close connections. |
1952 | */ | 1951 | */ |
1953 | static unsigned int count_close_connected(Group_c *g) | 1952 | static unsigned int count_close_connected(const Group_c *g) |
1954 | { | 1953 | { |
1955 | unsigned int i, count = 0; | 1954 | unsigned int i, count = 0; |
1956 | 1955 | ||
@@ -1964,7 +1963,7 @@ static unsigned int count_close_connected(Group_c *g) | |||
1964 | } | 1963 | } |
1965 | 1964 | ||
1966 | static int send_packet_online(Friend_Connections *fr_c, int friendcon_id, uint16_t group_num, uint8_t type, | 1965 | static int send_packet_online(Friend_Connections *fr_c, int friendcon_id, uint16_t group_num, uint8_t type, |
1967 | uint8_t *id) | 1966 | const uint8_t *id) |
1968 | { | 1967 | { |
1969 | uint8_t packet[1 + ONLINE_PACKET_DATA_SIZE]; | 1968 | uint8_t packet[1 + ONLINE_PACKET_DATA_SIZE]; |
1970 | group_num = net_htons(group_num); | 1969 | group_num = net_htons(group_num); |
@@ -2045,7 +2044,7 @@ static int handle_packet_rejoin(Group_Chats *g_c, int friendcon_id, const uint8_ | |||
2045 | 2044 | ||
2046 | const int32_t groupnum = get_group_num(g_c, *data, data + 1); | 2045 | const int32_t groupnum = get_group_num(g_c, *data, data + 1); |
2047 | 2046 | ||
2048 | Group_c *g = get_group_c(g_c, groupnum); | 2047 | const Group_c *g = get_group_c(g_c, groupnum); |
2049 | 2048 | ||
2050 | if (!g) { | 2049 | if (!g) { |
2051 | return -1; | 2050 | return -1; |
@@ -2099,7 +2098,7 @@ static unsigned int send_peer_query(Group_Chats *g_c, int friendcon_id, uint16_t | |||
2099 | */ | 2098 | */ |
2100 | static unsigned int send_peers(Group_Chats *g_c, uint32_t groupnumber, int friendcon_id, uint16_t group_num) | 2099 | static unsigned int send_peers(Group_Chats *g_c, uint32_t groupnumber, int friendcon_id, uint16_t group_num) |
2101 | { | 2100 | { |
2102 | Group_c *g = get_group_c(g_c, groupnumber); | 2101 | const Group_c *g = get_group_c(g_c, groupnumber); |
2103 | 2102 | ||
2104 | if (!g) { | 2103 | if (!g) { |
2105 | return 0; | 2104 | return 0; |
@@ -2222,7 +2221,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u | |||
2222 | 2221 | ||
2223 | switch (data[0]) { | 2222 | switch (data[0]) { |
2224 | case PEER_INTRODUCED_ID: { | 2223 | case PEER_INTRODUCED_ID: { |
2225 | Group_c *g = get_group_c(g_c, groupnumber); | 2224 | const Group_c *g = get_group_c(g_c, groupnumber); |
2226 | 2225 | ||
2227 | if (!g) { | 2226 | if (!g) { |
2228 | return; | 2227 | return; |
@@ -2234,7 +2233,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u | |||
2234 | break; | 2233 | break; |
2235 | 2234 | ||
2236 | case PEER_QUERY_ID: { | 2235 | case PEER_QUERY_ID: { |
2237 | Group_c *g = get_group_c(g_c, groupnumber); | 2236 | const Group_c *g = get_group_c(g_c, groupnumber); |
2238 | 2237 | ||
2239 | if (!g) { | 2238 | if (!g) { |
2240 | return; | 2239 | return; |
@@ -2256,7 +2255,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u | |||
2256 | break; | 2255 | break; |
2257 | 2256 | ||
2258 | case PEER_TITLE_ID: { | 2257 | case PEER_TITLE_ID: { |
2259 | Group_c *g = get_group_c(g_c, groupnumber); | 2258 | const Group_c *g = get_group_c(g_c, groupnumber); |
2260 | 2259 | ||
2261 | if (!g) { | 2260 | if (!g) { |
2262 | break; | 2261 | break; |
@@ -2279,7 +2278,7 @@ static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const u | |||
2279 | static unsigned int send_message_all_close(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, | 2278 | static unsigned int send_message_all_close(const Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, |
2280 | uint16_t length, int receiver) | 2279 | uint16_t length, int receiver) |
2281 | { | 2280 | { |
2282 | Group_c *g = get_group_c(g_c, groupnumber); | 2281 | const Group_c *g = get_group_c(g_c, groupnumber); |
2283 | 2282 | ||
2284 | if (!g) { | 2283 | if (!g) { |
2285 | return 0; | 2284 | return 0; |
@@ -2314,7 +2313,7 @@ static unsigned int send_lossy_all_close(const Group_Chats *g_c, uint32_t groupn | |||
2314 | uint16_t length, | 2313 | uint16_t length, |
2315 | int receiver) | 2314 | int receiver) |
2316 | { | 2315 | { |
2317 | Group_c *g = get_group_c(g_c, groupnumber); | 2316 | const Group_c *g = get_group_c(g_c, groupnumber); |
2318 | 2317 | ||
2319 | if (!g) { | 2318 | if (!g) { |
2320 | return 0; | 2319 | return 0; |
@@ -2561,7 +2560,7 @@ static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber, | |||
2561 | return; | 2560 | return; |
2562 | } | 2561 | } |
2563 | 2562 | ||
2564 | Group_c *g = get_group_c(g_c, groupnumber); | 2563 | const Group_c *g = get_group_c(g_c, groupnumber); |
2565 | 2564 | ||
2566 | if (!g) { | 2565 | if (!g) { |
2567 | return; | 2566 | return; |
@@ -2741,7 +2740,7 @@ static int g_handle_packet(void *object, int friendcon_id, const uint8_t *data, | |||
2741 | uint16_t groupnumber; | 2740 | uint16_t groupnumber; |
2742 | memcpy(&groupnumber, data + 1, sizeof(uint16_t)); | 2741 | memcpy(&groupnumber, data + 1, sizeof(uint16_t)); |
2743 | groupnumber = net_ntohs(groupnumber); | 2742 | groupnumber = net_ntohs(groupnumber); |
2744 | Group_c *g = get_group_c(g_c, groupnumber); | 2743 | const Group_c *g = get_group_c(g_c, groupnumber); |
2745 | 2744 | ||
2746 | if (!g) { | 2745 | if (!g) { |
2747 | return -1; | 2746 | return -1; |
@@ -2781,7 +2780,7 @@ static int g_handle_packet(void *object, int friendcon_id, const uint8_t *data, | |||
2781 | * | 2780 | * |
2782 | * TODO(irungentoo): test this | 2781 | * TODO(irungentoo): test this |
2783 | */ | 2782 | */ |
2784 | static unsigned int lossy_packet_not_received(Group_c *g, int peer_index, uint16_t message_number) | 2783 | static unsigned int lossy_packet_not_received(const Group_c *g, int peer_index, uint16_t message_number) |
2785 | { | 2784 | { |
2786 | if (peer_index == -1) { | 2785 | if (peer_index == -1) { |
2787 | // TODO(sudden6): invalid return value | 2786 | // TODO(sudden6): invalid return value |
@@ -2852,7 +2851,7 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin | |||
2852 | peer_number = net_ntohs(peer_number); | 2851 | peer_number = net_ntohs(peer_number); |
2853 | message_number = net_ntohs(message_number); | 2852 | message_number = net_ntohs(message_number); |
2854 | 2853 | ||
2855 | Group_c *g = get_group_c(g_c, groupnumber); | 2854 | const Group_c *g = get_group_c(g_c, groupnumber); |
2856 | 2855 | ||
2857 | if (!g) { | 2856 | if (!g) { |
2858 | return -1; | 2857 | return -1; |
@@ -2921,7 +2920,7 @@ int group_set_object(const Group_Chats *g_c, uint32_t groupnumber, void *object) | |||
2921 | */ | 2920 | */ |
2922 | int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object) | 2921 | int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object) |
2923 | { | 2922 | { |
2924 | Group_c *g = get_group_c(g_c, groupnumber); | 2923 | const Group_c *g = get_group_c(g_c, groupnumber); |
2925 | 2924 | ||
2926 | if (!g) { | 2925 | if (!g) { |
2927 | return -1; | 2926 | return -1; |
@@ -2942,7 +2941,7 @@ int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peer | |||
2942 | */ | 2941 | */ |
2943 | void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber) | 2942 | void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber) |
2944 | { | 2943 | { |
2945 | Group_c *g = get_group_c(g_c, groupnumber); | 2944 | const Group_c *g = get_group_c(g_c, groupnumber); |
2946 | 2945 | ||
2947 | if (!g) { | 2946 | if (!g) { |
2948 | return nullptr; | 2947 | return nullptr; |
@@ -2958,7 +2957,7 @@ void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber) | |||
2958 | */ | 2957 | */ |
2959 | void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber) | 2958 | void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber) |
2960 | { | 2959 | { |
2961 | Group_c *g = get_group_c(g_c, groupnumber); | 2960 | const Group_c *g = get_group_c(g_c, groupnumber); |
2962 | 2961 | ||
2963 | if (!g) { | 2962 | if (!g) { |
2964 | return nullptr; | 2963 | return nullptr; |
@@ -3101,7 +3100,7 @@ static uint8_t *save_conf(const Group_c *g, uint8_t *data) | |||
3101 | host_to_lendian_bytes16(data, g->peer_number); | 3100 | host_to_lendian_bytes16(data, g->peer_number); |
3102 | data += sizeof(uint16_t); | 3101 | data += sizeof(uint16_t); |
3103 | 3102 | ||
3104 | uint8_t *numsaved_location = data; | 3103 | uint8_t *const numsaved_location = data; |
3105 | data += sizeof(uint32_t); | 3104 | data += sizeof(uint32_t); |
3106 | 3105 | ||
3107 | *data = g->title_len; | 3106 | *data = g->title_len; |
@@ -3133,7 +3132,7 @@ static uint32_t conferences_section_size(const Group_Chats *g_c) | |||
3133 | uint32_t len = 0; | 3132 | uint32_t len = 0; |
3134 | 3133 | ||
3135 | for (uint16_t i = 0; i < g_c->num_chats; ++i) { | 3134 | for (uint16_t i = 0; i < g_c->num_chats; ++i) { |
3136 | Group_c *g = get_group_c(g_c, i); | 3135 | const Group_c *g = get_group_c(g_c, i); |
3137 | 3136 | ||
3138 | if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) { | 3137 | if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) { |
3139 | continue; | 3138 | continue; |
@@ -3156,7 +3155,7 @@ uint8_t *conferences_save(const Group_Chats *g_c, uint8_t *data) | |||
3156 | data = state_write_section_header(data, STATE_COOKIE_TYPE, len, STATE_TYPE_CONFERENCES); | 3155 | data = state_write_section_header(data, STATE_COOKIE_TYPE, len, STATE_TYPE_CONFERENCES); |
3157 | 3156 | ||
3158 | for (uint16_t i = 0; i < g_c->num_chats; ++i) { | 3157 | for (uint16_t i = 0; i < g_c->num_chats; ++i) { |
3159 | Group_c *g = get_group_c(g_c, i); | 3158 | const Group_c *g = get_group_c(g_c, i); |
3160 | 3159 | ||
3161 | if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) { | 3160 | if (!g || g->status != GROUPCHAT_STATUS_CONNECTED) { |
3162 | continue; | 3161 | continue; |