cleanup: Replace a series of if statements with a switch.

This commit is contained in:
iphydf 2022-04-02 16:23:13 +00:00
parent 941026266e
commit 2c06ef6ad4
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 20 additions and 13 deletions

View File

@ -1 +1 @@
5796f74532156d61d5c715914b5013ae0544892f7d6dca237b1f6a828f49fc9c /usr/local/bin/tox-bootstrapd 139fe825b90c022bbefd3837c2a427ab9215be3ca62144ea7ff12ae7389c78ba /usr/local/bin/tox-bootstrapd

View File

@ -1266,21 +1266,28 @@ int file_control(const Messenger *m, int32_t friendnumber, uint32_t filenumber,
} }
if (send_file_control_packet(m, friendnumber, inbound, file_number, control, nullptr, 0)) { if (send_file_control_packet(m, friendnumber, inbound, file_number, control, nullptr, 0)) {
if (control == FILECONTROL_KILL) { switch (control) {
case FILECONTROL_KILL: {
if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) { if (!inbound && (ft->status == FILESTATUS_TRANSFERRING || ft->status == FILESTATUS_FINISHED)) {
// We are actively sending that file, remove from list // We are actively sending that file, remove from list
--m->friendlist[friendnumber].num_sending_files; --m->friendlist[friendnumber].num_sending_files;
} }
ft->status = FILESTATUS_NONE; ft->status = FILESTATUS_NONE;
} else if (control == FILECONTROL_PAUSE) { break;
}
case FILECONTROL_PAUSE: {
ft->paused |= FILE_PAUSE_US; ft->paused |= FILE_PAUSE_US;
} else if (control == FILECONTROL_ACCEPT) { break;
}
case FILECONTROL_ACCEPT: {
ft->status = FILESTATUS_TRANSFERRING; ft->status = FILESTATUS_TRANSFERRING;
if ((ft->paused & FILE_PAUSE_US) != 0) { if ((ft->paused & FILE_PAUSE_US) != 0) {
ft->paused ^= FILE_PAUSE_US; ft->paused ^= FILE_PAUSE_US;
} }
break;
}
} }
} else { } else {
return -8; return -8;