Skip to content

Commit

Permalink
Unify return FIDO_OK in function comments
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Aug 31, 2022
1 parent c0b7c3d commit cbac029
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions include/cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef int cbor_parse_map_item(const cb0r_t key, const cb0r_t value, void *data
* @param cbor_map The map to iterate over.
* @param cb The callback to call for each entry.
* @param data User-supplied additional context data passed to the callback.
* @return int FIDO_OK if map could be iterated completely.
* @return int FIDO_OK if the map could be iterated completely.
*/
int cbor_iter_map(cb0r_t cbor_map, cbor_parse_map_item *cb, void *data);

Expand All @@ -38,7 +38,7 @@ int cbor_iter_map(cb0r_t cbor_map, cbor_parse_map_item *cb, void *data);
* @param cbor_array The array to iterate over.
* @param cb The callback to call for each entry.
* @param data User-supplied additional context data passed to the callback.
* @return int FIDO_OK if array could be iterated completely.
* @return int FIDO_OK if the array could be iterated completely.
*/
int cbor_iter_array(cb0r_t cbor_array, cbor_parse_array_item *cb, void* data);

Expand Down Expand Up @@ -88,7 +88,7 @@ void cbor_writer_reset(cbor_writer_t writer, uint8_t* buffer, const size_t buffe
* @brief Check a writer's status.
*
* @param writer The writer to check.
* @return true iff no error occurred and writer->buffer can be used.
* @return true if no error occurred and writer->buffer can be used.
*/
bool cbor_writer_is_ok(cbor_writer_t writer);

Expand Down
4 changes: 2 additions & 2 deletions include/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void fido_dev_set_transport(fido_dev_t *dev, const fido_dev_transport_t *transpo
* Initializes the connection and makes it ready for communication.
*
* @param dev A pointer to the FIDO device to be opened.
* @return intFIDO_OK when the operation was successful.
* @return intFIDO_OK if the operation was successful.
*/
int fido_dev_open(fido_dev_t *dev);

Expand All @@ -90,7 +90,7 @@ int fido_dev_open(fido_dev_t *dev);
* Closes the connection to the device.
*
* @param dev A pointer to the FIDO device to be closed.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
int fido_dev_close(fido_dev_t *dev);

Expand Down
8 changes: 4 additions & 4 deletions include/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @param cmd The CTAP command to receive data from.
* @param buf A pointer to the destination buffer.
* @param len The size of the destination buffer.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
int fido_rx(fido_dev_t *d, const uint8_t cmd, void *buf, const size_t len);

Expand All @@ -33,7 +33,7 @@ int fido_rx(fido_dev_t *d, const uint8_t cmd, void *buf, const size_t len);
* @param cmd The CTAP command to transmit.
* @param buf A pointer to the source buffer.
* @param len The size of the source buffer.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
int fido_tx(fido_dev_t *d, const uint8_t cmd, const void *buf, const size_t len);
int fido_get_random(void *buf, size_t len);
Expand All @@ -46,7 +46,7 @@ int fido_get_random(void *buf, size_t len);
* @param len The length of the memory area pointed to by buf.
* @param dst A pointer to the destination buffer.
* @param count The number of bytes to read.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
int fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t count);

Expand All @@ -58,6 +58,6 @@ int fido_buf_read(const unsigned char **buf, size_t *len, void *dst, size_t coun
* @param len The length of the memory area pointed to by buf.
* @param src The source buffer.
* @param count The number of bytes to write.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
int fido_buf_write(unsigned char **buf, size_t *len, const void *src, size_t count);
16 changes: 8 additions & 8 deletions src/assertion.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static const uint8_t KEY_ID[] PROGMEM_MARKER = "id";
* @param key The CBOR key.
* @param assert The CBOR value.
* @param arg The assert reply argument to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int cbor_assert_decode_credential(const cb0r_t key, const cb0r_t value, void *arg) {
if (!cbor_utf8string_is_definite(key)) {
Expand Down Expand Up @@ -156,7 +156,7 @@ static int cbor_assert_decode_credential(const cb0r_t key, const cb0r_t value, v
*
* @param auth_data_raw The raw auth data.
* @param ca The reply entry to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int cbor_assert_decode_auth_data_inner(void* auth_data_raw, fido_assert_reply_t *ca) {
uint8_t* auth_data_bytes = (uint8_t*) auth_data_raw;
Expand All @@ -183,7 +183,7 @@ static int cbor_assert_decode_auth_data_inner(void* auth_data_raw, fido_assert_r
*
* @param auth_data The CBOR encoded authentication data.
* @param ca The reply entry to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int cbor_assert_decode_auth_data(const cb0r_t auth_data, fido_assert_reply_t *ca) {
if (!cbor_bytestring_is_definite(auth_data)) {
Expand All @@ -204,7 +204,7 @@ static int cbor_assert_decode_auth_data(const cb0r_t auth_data, fido_assert_repl
*
* @param signature The CBOR encoded signature data.
* @param ca The reply entry to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int cbor_assert_decode_signature(const cb0r_t signature, fido_assert_reply_t *ca) {
if (!cbor_bytestring_is_definite(signature)) {
Expand All @@ -223,7 +223,7 @@ static int cbor_assert_decode_signature(const cb0r_t signature, fido_assert_repl
*
* @param large_blob_key The CBOR encoded signature data.
* @param ca The reply entry to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int cbor_assert_decode_large_blob_key(const cb0r_t large_blob_key, fido_assert_reply_t *ca) {
if (!cbor_bytestring_is_definite(large_blob_key)) {
Expand All @@ -244,7 +244,7 @@ static int cbor_assert_decode_large_blob_key(const cb0r_t large_blob_key, fido_a
* @param key The cb0r element representing the map key
* @param value The cb0r element representing the map value
* @param arg User-passed argument (here: assertion reply).
* @return int FIDO_OK if entry could be parsed.
* @return int FIDO_OK if the entry could be parsed.
*/
static int parse_get_assert_reply_entry(const cb0r_t key, const cb0r_t value, void *arg) {
if (key->type != CB0R_INT || key->value > UINT8_MAX) {
Expand Down Expand Up @@ -280,7 +280,7 @@ static int parse_get_assert_reply_entry(const cb0r_t key, const cb0r_t value, vo
*
* @param dev The device to communicate to.
* @param assert The assertion request data.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int fido_dev_get_assert_tx(
fido_dev_t *dev,
Expand Down Expand Up @@ -332,7 +332,7 @@ static int fido_dev_get_assert_tx(
* @param dev The device to communicate to.
* @param assert The assertion request data.
* @param reply A pointer to the structure to store the parsed data to.
* @return int FIDO_OK if performed successfully
* @return int FIDO_OK if the operation was successful.
*/
static int fido_dev_get_assert_rx(
fido_dev_t *dev,
Expand Down
8 changes: 4 additions & 4 deletions src/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ bool fido_dev_is_fido(fido_dev_t *dev) {
/**
* @brief Open a FIDO device sending an initialization command.
*
* @param dev
* @return int A FIDO_ERR
* @param dev The FIDO device to open.
* @return int FIDO_OK if the operation was successful.
*/
static int fido_dev_open_tx(fido_dev_t *dev) {
int r;
Expand Down Expand Up @@ -158,8 +158,8 @@ static int fido_dev_open_tx(fido_dev_t *dev) {
/**
* @brief Open a device and ensure that is a FIDO one by receiving an initialization response.
*
* @param dev
* @return int A FIDO_ERR
* @param dev The FIDO device to open.
* @return int FIDO_OK if the operation was successful.
*/
static int fido_dev_open_rx(fido_dev_t *dev) {
fido_cbor_info_t info = { 0 };
Expand Down
18 changes: 9 additions & 9 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void fido_cbor_info_reset(fido_cbor_info_t *ci) {
*
* @param value The value containing the AAGUID.
* @param ci The info to copy the ID to.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int copy_aaguid(const cb0r_t value, fido_cbor_info_t *ci) {
if (!cbor_bytestring_is_definite(value) || value->length != sizeof(ci->aaguid)) {
Expand All @@ -81,7 +81,7 @@ static int copy_aaguid(const cb0r_t value, fido_cbor_info_t *ci) {
*
* @param value The value to decode.
* @param target A pointer to a location to store the decoded value at.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int decode_uint64(const cb0r_t value, uint64_t *target) {
if (value->type != CB0R_INT) {
Expand Down Expand Up @@ -226,7 +226,7 @@ static int cbor_info_decode_options(const cb0r_t key, const cb0r_t value, void *
*
* @param element The cb0r element containing the byte representing the protocol
* @param arg User-passed argument (here: CBOR info).
* @return int FIDO_OK if protocol could be parsed.
* @return int FIDO_OK if the protocol could be parsed.
*/
static int cbor_info_decode_protocol(const cb0r_t element, void *arg) {
fido_cbor_info_t *ci = (fido_cbor_info_t*)arg;
Expand All @@ -253,7 +253,7 @@ static int cbor_info_decode_protocol(const cb0r_t element, void *arg) {
*
* @param element The cb0r element representing the transport
* @param arg User-passed argument (here: CBOR info).
* @return int FIDO_OK if transport could be parsed.
* @return int FIDO_OK if the transport could be parsed.
*/
static int cbor_info_decode_transport(const cb0r_t element, void *arg) {
fido_cbor_info_t *ci = (fido_cbor_info_t*)arg;
Expand Down Expand Up @@ -281,7 +281,7 @@ static int cbor_info_decode_transport(const cb0r_t element, void *arg) {
* @param key The cb0r element representing the algorithm key
* @param value The cb0r element representing the algorithm identifier
* @param arg User-passed argument (here: CBOR info).
* @return int FIDO_OK if algorithm could be parsed.
* @return int FIDO_OK if the algorithm could be parsed.
*/
static int cbor_info_decode_algorithm_entry(const cb0r_t key, const cb0r_t value, void *arg) {
fido_cbor_info_t *ci = (fido_cbor_info_t*)arg;
Expand Down Expand Up @@ -327,7 +327,7 @@ static int cbor_info_decode_algorithm_entry(const cb0r_t key, const cb0r_t value
*
* @param element The cb0r element representing the algorithm map
* @param arg User-passed argument (here: CBOR info).
* @return int FIDO_OK if map could be parsed.
* @return int FIDO_OK if the map could be parsed.
*/
static int cbor_info_decode_algorithm(const cb0r_t element, void *arg) {
if (element->type != CB0R_MAP) {
Expand All @@ -343,7 +343,7 @@ static int cbor_info_decode_algorithm(const cb0r_t element, void *arg) {
* @param key The cb0r element representing the map key
* @param value The cb0r element representing the map value
* @param arg User-passed argument (here: CBOR info).
* @return int FIDO_OK if entry could be parsed.
* @return int FIDO_OK if the entry could be parsed.
*/
static int parse_info_reply_entry(const cb0r_t key, const cb0r_t value, void *arg) {
if (key->type != CB0R_INT || key->value > UINT8_MAX) {
Expand Down Expand Up @@ -390,7 +390,7 @@ static int parse_info_reply_entry(const cb0r_t key, const cb0r_t value, void *ar
* @brief Send a CTAP authenticatorGetInfo command.
*
* @param dev The device to communicate to.
* @return int FIDO_OK if transmission succeeded.
* @return int FIDO_OK if the transmission succeeded.
*/
static int fido_dev_get_cbor_info_tx(fido_dev_t *dev) {
const unsigned char cbor[] = { CTAP_CBOR_GETINFO };
Expand All @@ -410,7 +410,7 @@ static int fido_dev_get_cbor_info_tx(fido_dev_t *dev) {
*
* @param dev The device to communicate to.
* @param ci The fido_cbor_info_t to write the parsed reply to.
* @return int FIDO_OK if transmission succeeded.
* @return int FIDO_OK if the transmission succeeded.
*/
static int fido_dev_get_cbor_info_rx(fido_dev_t *dev, fido_cbor_info_t *ci) {
unsigned char msg[dev->maxmsgsize];
Expand Down
10 changes: 5 additions & 5 deletions src/largeblob.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static bool largeblob_array_check(fido_blob_t *array) {
* @param dev The device to read the large blob from.
* @param offset The offset in the large blob to start reading from.
* @param count The amount of bytes to read.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int largeblob_get_tx(fido_dev_t *dev, size_t offset, size_t count) {
// 32 > 1 byte command + 1 byte map header + 1 byte get key + max. 9 byte get value + 1 byte offset key + max. 9 byte offset value
Expand Down Expand Up @@ -192,7 +192,7 @@ static int parse_largeblob_reply(const cb0r_t key, const cb0r_t value, void *arg
*
* @param dev The device to read the answer from.
* @param chunk The chunk to store the returned large blob chunk in. Must already be allocated.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int largeblob_get_rx(fido_dev_t *dev, fido_blob_t *chunk) {
uint8_t msg[dev->maxmsgsize];
Expand Down Expand Up @@ -285,7 +285,7 @@ typedef struct largeblob_array_entry {
* @param compressed Pointer to the compressed data.
* @param compressed_len Length of the compressed data.
* @param uncompressed_len_expected Expected length of the uncompressed data, to ensure that we got everything.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int fido_uncompress(fido_blob_t* out, uint8_t *compressed, size_t compressed_len, size_t uncompressed_len_expected) {
uint32_t uncompressed_len_actual = out->max_length;
Expand All @@ -306,7 +306,7 @@ static int fido_uncompress(fido_blob_t* out, uint8_t *compressed, size_t compres
* @param key The CBOR key value of the entry.
* @param value The CBOR encoded value.
* @param data The largeblob array entry object to store the parsed data to.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int largeblob_parse_array_entry(cb0r_t key, cb0r_t value, void *data) {
largeblob_array_entry_t *entry = (largeblob_array_entry_t*) data;
Expand Down Expand Up @@ -362,7 +362,7 @@ static int largeblob_parse_array_entry(cb0r_t key, cb0r_t value, void *data) {
*
* @param value The CBOR encoded value.
* @param data The largeblob array lookup parameters. This also contains the buffer where we write the uncompressed data to.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int largeblob_array_lookup(cb0r_t value, void* data) {
largeblob_array_lookup_param_t *param = (largeblob_array_lookup_param_t*) data;
Expand Down
16 changes: 8 additions & 8 deletions src/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const uint8_t fido_version_fido2[] PROGMEM_MARKER = "FIDO_2_0";
* @param dev The device to receive data from.
* @param buf The buffer to write the received data to.
* @param len The length of the buffer.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int rx_init(fido_dev_t *dev, unsigned char *buf, const size_t len)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ static int rx_init(fido_dev_t *dev, unsigned char *buf, const size_t len)
* @param sw The buffer to write the status word to.
* @param buf A pointer to a pointer to a buffer where the received data is located. The pointer to the buffer will be advanced.
* @param count The remaining length of the buffer, will be reduced.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int rx_apdu(fido_dev_t *dev, uint8_t sw[2], unsigned char **buf, size_t *count) {
uint8_t f[256 + 2];
Expand Down Expand Up @@ -99,7 +99,7 @@ static int rx_apdu(fido_dev_t *dev, uint8_t sw[2], unsigned char **buf, size_t *
*
* @param dev The device to transmit data to.
* @param count The amount of data expected to receive.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int tx_get_response(fido_dev_t *dev, uint8_t count)
{
Expand Down Expand Up @@ -165,7 +165,7 @@ static int rx_msg(fido_dev_t *dev, unsigned char *buf, const size_t len) {
* @param dev The device to receive data from.
* @param buf The buffer to write the received data to.
* @param len The length of the buffer.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int rx_cbor(fido_dev_t *dev, unsigned char *buf, const size_t count) {
int r;
Expand All @@ -183,7 +183,7 @@ static int rx_cbor(fido_dev_t *dev, unsigned char *buf, const size_t count) {
* @param cmd The CTAP command that was executed.
* @param buf The buffer to write the response to.
* @param len The length of the buffer.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int nfc_rx(struct fido_dev *dev, const uint8_t cmd, unsigned char *buf, const size_t len) {
switch (cmd) {
Expand All @@ -207,7 +207,7 @@ static int nfc_rx(struct fido_dev *dev, const uint8_t cmd, unsigned char *buf, c
* @param payload The payload to send.
* @param payload_len The length of the payload.
* @param cla_flags The ISO7816 class flags to use.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int tx_short_apdu(
fido_dev_t *dev,
Expand Down Expand Up @@ -260,7 +260,7 @@ static int tx_short_apdu(
*
* @param dev The device to receive data from.
* @param apdu The ISO7816 APDU to send.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int nfc_do_tx(fido_dev_t *dev, const iso7816_apdu_t *apdu) {
uint16_t apdu_len = apdu->payload_len;
Expand Down Expand Up @@ -291,7 +291,7 @@ static int nfc_do_tx(fido_dev_t *dev, const iso7816_apdu_t *apdu) {
* @param cmd The CTAP command.
* @param buf The payload to send.
* @param len The length of the payload.
* @return int FIDO_OK when the operation was successful.
* @return int FIDO_OK if the operation was successful.
*/
static int nfc_tx(struct fido_dev *dev, const uint8_t cmd, const unsigned char *buf, const size_t len) {
iso7816_apdu_t apdu;
Expand Down

0 comments on commit cbac029

Please sign in to comment.