mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Improve readability of handle_request() in crypto_core.c
Moving 'return -1;' directly below the conditions improves readability and also better represents the coding style of other functions in crypt_core.c (and everywhere else).
This commit is contained in:
parent
6d883f488f
commit
ee1ab5f0c7
|
@ -235,9 +235,13 @@ int create_request(const uint8_t *send_public_key, const uint8_t *send_secret_ke
|
|||
int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_key, uint8_t *public_key, uint8_t *data,
|
||||
uint8_t *request_id, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
if (length > crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + crypto_box_MACBYTES &&
|
||||
length <= MAX_CRYPTO_REQUEST_SIZE) {
|
||||
if (memcmp(packet + 1, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) {
|
||||
if (length <= crypto_box_PUBLICKEYBYTES * 2 + crypto_box_NONCEBYTES + 1 + crypto_box_MACBYTES ||
|
||||
length > MAX_CRYPTO_REQUEST_SIZE)
|
||||
return -1;
|
||||
|
||||
if (memcmp(packet + 1, self_public_key, crypto_box_PUBLICKEYBYTES) != 0)
|
||||
return -1;
|
||||
|
||||
memcpy(public_key, packet + 1 + crypto_box_PUBLICKEYBYTES, crypto_box_PUBLICKEYBYTES);
|
||||
uint8_t nonce[crypto_box_NONCEBYTES];
|
||||
uint8_t temp[MAX_CRYPTO_REQUEST_SIZE];
|
||||
|
@ -254,7 +258,3 @@ int handle_request(const uint8_t *self_public_key, const uint8_t *self_secret_ke
|
|||
memcpy(data, temp + 1, len1);
|
||||
return len1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user