Skip to content

Commit

Permalink
refactor: Rename out parameters to out_$something.
Browse files Browse the repository at this point in the history
In preparation for supporting `out` as a type qualifier in parameters.
  • Loading branch information
iphydf committed Mar 8, 2024
1 parent 0199c0f commit 3e05824
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 115 deletions.
1 change: 1 addition & 0 deletions testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sh_test(
args = ["$(locations %s)" % f for f in CIMPLE_FILES] + [
"-Wno-boolean-return",
"-Wno-callback-names",
"-Wno-enum-from-int",
"+RTS",
"-N4",
"-RTS",
Expand Down
12 changes: 6 additions & 6 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,31 +775,31 @@ int m_set_statusmessage(Messenger *m, const uint8_t *status, uint16_t length)
}

non_null()
static bool userstatus_from_int(uint8_t status, Userstatus *out)
static bool userstatus_from_int(uint8_t status, Userstatus *out_enum)
{
switch (status) {
case USERSTATUS_NONE: {
*out = USERSTATUS_NONE;
*out_enum = USERSTATUS_NONE;
return true;
}

case USERSTATUS_AWAY: {
*out = USERSTATUS_AWAY;
*out_enum = USERSTATUS_AWAY;
return true;
}

case USERSTATUS_BUSY: {
*out = USERSTATUS_BUSY;
*out_enum = USERSTATUS_BUSY;
return true;
}

case USERSTATUS_INVALID: {
*out = USERSTATUS_INVALID;
*out_enum = USERSTATUS_INVALID;
return true;
}

default: {
*out = USERSTATUS_INVALID;
*out_enum = USERSTATUS_INVALID;
return false;
}
}
Expand Down
18 changes: 9 additions & 9 deletions toxcore/group_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@
#include "network.h"
#include "util.h"

bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out)
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum)
{
switch (value) {
case GI_PUBLIC: {
*out = GI_PUBLIC;
*out_enum = GI_PUBLIC;
return true;
}

case GI_PRIVATE: {
*out = GI_PRIVATE;
*out_enum = GI_PRIVATE;
return true;
}

default: {
*out = GI_PUBLIC;
*out_enum = GI_PUBLIC;
return false;
}
}
}

bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out)
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum)
{
switch (value) {
case GV_ALL: {
*out = GV_ALL;
*out_enum = GV_ALL;
return true;
}

case GV_MODS: {
*out = GV_MODS;
*out_enum = GV_MODS;
return true;
}

case GV_FOUNDER: {
*out = GV_FOUNDER;
*out_enum = GV_FOUNDER;
return true;
}

default: {
*out = GV_ALL;
*out_enum = GV_ALL;
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions toxcore/group_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ non_null()
bool gc_load_unpack_group(GC_Chat *chat, Bin_Unpack *bu);

non_null()
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out);
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum);
non_null()
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out);
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum);

#endif /* C_TOXCORE_TOXCORE_GROUP_PACK_H */
86 changes: 43 additions & 43 deletions toxcore/tox_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,216 +725,216 @@ bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
}

non_null()
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out_enum)
{
switch (value) {
case TOX_EVENT_SELF_CONNECTION_STATUS: {
*out = TOX_EVENT_SELF_CONNECTION_STATUS;
*out_enum = TOX_EVENT_SELF_CONNECTION_STATUS;
return true;
}

case TOX_EVENT_FRIEND_REQUEST: {
*out = TOX_EVENT_FRIEND_REQUEST;
*out_enum = TOX_EVENT_FRIEND_REQUEST;
return true;
}

case TOX_EVENT_FRIEND_CONNECTION_STATUS: {
*out = TOX_EVENT_FRIEND_CONNECTION_STATUS;
*out_enum = TOX_EVENT_FRIEND_CONNECTION_STATUS;
return true;
}

case TOX_EVENT_FRIEND_LOSSY_PACKET: {
*out = TOX_EVENT_FRIEND_LOSSY_PACKET;
*out_enum = TOX_EVENT_FRIEND_LOSSY_PACKET;
return true;
}

case TOX_EVENT_FRIEND_LOSSLESS_PACKET: {
*out = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
*out_enum = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
return true;
}

case TOX_EVENT_FRIEND_NAME: {
*out = TOX_EVENT_FRIEND_NAME;
*out_enum = TOX_EVENT_FRIEND_NAME;
return true;
}

case TOX_EVENT_FRIEND_STATUS: {
*out = TOX_EVENT_FRIEND_STATUS;
*out_enum = TOX_EVENT_FRIEND_STATUS;
return true;
}

case TOX_EVENT_FRIEND_STATUS_MESSAGE: {
*out = TOX_EVENT_FRIEND_STATUS_MESSAGE;
*out_enum = TOX_EVENT_FRIEND_STATUS_MESSAGE;
return true;
}

case TOX_EVENT_FRIEND_MESSAGE: {
*out = TOX_EVENT_FRIEND_MESSAGE;
*out_enum = TOX_EVENT_FRIEND_MESSAGE;
return true;
}

case TOX_EVENT_FRIEND_READ_RECEIPT: {
*out = TOX_EVENT_FRIEND_READ_RECEIPT;
*out_enum = TOX_EVENT_FRIEND_READ_RECEIPT;
return true;
}

case TOX_EVENT_FRIEND_TYPING: {
*out = TOX_EVENT_FRIEND_TYPING;
*out_enum = TOX_EVENT_FRIEND_TYPING;
return true;
}

case TOX_EVENT_FILE_CHUNK_REQUEST: {
*out = TOX_EVENT_FILE_CHUNK_REQUEST;
*out_enum = TOX_EVENT_FILE_CHUNK_REQUEST;
return true;
}

case TOX_EVENT_FILE_RECV: {
*out = TOX_EVENT_FILE_RECV;
*out_enum = TOX_EVENT_FILE_RECV;
return true;
}

case TOX_EVENT_FILE_RECV_CHUNK: {
*out = TOX_EVENT_FILE_RECV_CHUNK;
*out_enum = TOX_EVENT_FILE_RECV_CHUNK;
return true;
}

case TOX_EVENT_FILE_RECV_CONTROL: {
*out = TOX_EVENT_FILE_RECV_CONTROL;
*out_enum = TOX_EVENT_FILE_RECV_CONTROL;
return true;
}

case TOX_EVENT_CONFERENCE_INVITE: {
*out = TOX_EVENT_CONFERENCE_INVITE;
*out_enum = TOX_EVENT_CONFERENCE_INVITE;
return true;
}

case TOX_EVENT_CONFERENCE_CONNECTED: {
*out = TOX_EVENT_CONFERENCE_CONNECTED;
*out_enum = TOX_EVENT_CONFERENCE_CONNECTED;
return true;
}

case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED: {
*out = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
*out_enum = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
return true;
}

case TOX_EVENT_CONFERENCE_PEER_NAME: {
*out = TOX_EVENT_CONFERENCE_PEER_NAME;
*out_enum = TOX_EVENT_CONFERENCE_PEER_NAME;
return true;
}

case TOX_EVENT_CONFERENCE_TITLE: {
*out = TOX_EVENT_CONFERENCE_TITLE;
*out_enum = TOX_EVENT_CONFERENCE_TITLE;
return true;
}

case TOX_EVENT_CONFERENCE_MESSAGE: {
*out = TOX_EVENT_CONFERENCE_MESSAGE;
*out_enum = TOX_EVENT_CONFERENCE_MESSAGE;
return true;
}

case TOX_EVENT_GROUP_PEER_NAME: {
*out = TOX_EVENT_GROUP_PEER_NAME;
*out_enum = TOX_EVENT_GROUP_PEER_NAME;
return true;
}

case TOX_EVENT_GROUP_PEER_STATUS: {
*out = TOX_EVENT_GROUP_PEER_STATUS;
*out_enum = TOX_EVENT_GROUP_PEER_STATUS;
return true;
}

case TOX_EVENT_GROUP_TOPIC: {
*out = TOX_EVENT_GROUP_TOPIC;
*out_enum = TOX_EVENT_GROUP_TOPIC;
return true;
}

case TOX_EVENT_GROUP_PRIVACY_STATE: {
*out = TOX_EVENT_GROUP_PRIVACY_STATE;
*out_enum = TOX_EVENT_GROUP_PRIVACY_STATE;
return true;
}

case TOX_EVENT_GROUP_VOICE_STATE: {
*out = TOX_EVENT_GROUP_VOICE_STATE;
*out_enum = TOX_EVENT_GROUP_VOICE_STATE;
return true;
}

case TOX_EVENT_GROUP_TOPIC_LOCK: {
*out = TOX_EVENT_GROUP_TOPIC_LOCK;
*out_enum = TOX_EVENT_GROUP_TOPIC_LOCK;
return true;
}

case TOX_EVENT_GROUP_PEER_LIMIT: {
*out = TOX_EVENT_GROUP_PEER_LIMIT;
*out_enum = TOX_EVENT_GROUP_PEER_LIMIT;
return true;
}

case TOX_EVENT_GROUP_PASSWORD: {
*out = TOX_EVENT_GROUP_PASSWORD;
*out_enum = TOX_EVENT_GROUP_PASSWORD;
return true;
}

case TOX_EVENT_GROUP_MESSAGE: {
*out = TOX_EVENT_GROUP_MESSAGE;
*out_enum = TOX_EVENT_GROUP_MESSAGE;
return true;
}

case TOX_EVENT_GROUP_PRIVATE_MESSAGE: {
*out = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
*out_enum = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
return true;
}

case TOX_EVENT_GROUP_CUSTOM_PACKET: {
*out = TOX_EVENT_GROUP_CUSTOM_PACKET;
*out_enum = TOX_EVENT_GROUP_CUSTOM_PACKET;
return true;
}

case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET: {
*out = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
*out_enum = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
return true;
}

case TOX_EVENT_GROUP_INVITE: {
*out = TOX_EVENT_GROUP_INVITE;
*out_enum = TOX_EVENT_GROUP_INVITE;
return true;
}

case TOX_EVENT_GROUP_PEER_JOIN: {
*out = TOX_EVENT_GROUP_PEER_JOIN;
*out_enum = TOX_EVENT_GROUP_PEER_JOIN;
return true;
}

case TOX_EVENT_GROUP_PEER_EXIT: {
*out = TOX_EVENT_GROUP_PEER_EXIT;
*out_enum = TOX_EVENT_GROUP_PEER_EXIT;
return true;
}

case TOX_EVENT_GROUP_SELF_JOIN: {
*out = TOX_EVENT_GROUP_SELF_JOIN;
*out_enum = TOX_EVENT_GROUP_SELF_JOIN;
return true;
}

case TOX_EVENT_GROUP_JOIN_FAIL: {
*out = TOX_EVENT_GROUP_JOIN_FAIL;
*out_enum = TOX_EVENT_GROUP_JOIN_FAIL;
return true;
}

case TOX_EVENT_GROUP_MODERATION: {
*out = TOX_EVENT_GROUP_MODERATION;
*out_enum = TOX_EVENT_GROUP_MODERATION;
return true;
}

case TOX_EVENT_DHT_GET_NODES_RESPONSE: {
*out = TOX_EVENT_DHT_GET_NODES_RESPONSE;
*out_enum = TOX_EVENT_DHT_GET_NODES_RESPONSE;
return true;
}

case TOX_EVENT_INVALID: {
*out = TOX_EVENT_INVALID;
*out_enum = TOX_EVENT_INVALID;
return true;
}

default: {
*out = TOX_EVENT_INVALID;
*out_enum = TOX_EVENT_INVALID;
return false;
}
}
Expand Down
Loading

0 comments on commit 3e05824

Please sign in to comment.