add -Wextra: further code cleanup

please fix Wno-unused-parameter -Wno-missing-field-initializers in the future
This commit is contained in:
yparitcher 2019-01-06 11:41:56 -05:00
parent 400b37a96a
commit 1dd835d698
No known key found for this signature in database
GPG Key ID: FC78BE8055D48472
14 changed files with 35 additions and 32 deletions

View File

@ -309,7 +309,7 @@ static int is_matching_rk(CTAP_residentKey * rk, CTAP_residentKey * rk2)
} }
static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, int len, CTAP_userEntity * user, uint8_t credtype, int32_t algtype, int32_t * sz, int store) static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, unsigned int len, CTAP_userEntity * user, uint8_t credtype, int32_t algtype, int32_t * sz, int store)
{ {
CborEncoder cose_key; CborEncoder cose_key;
int auth_data_sz, ret; int auth_data_sz, ret;
@ -380,8 +380,8 @@ static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * au
memmove(&rk.id, &authData->attest.id, sizeof(CredentialId)); memmove(&rk.id, &authData->attest.id, sizeof(CredentialId));
memmove(&rk.user, user, sizeof(CTAP_userEntity)); memmove(&rk.user, user, sizeof(CTAP_userEntity));
int index = STATE.rk_stored; unsigned int index = STATE.rk_stored;
int i; unsigned int i;
for (i = 0; i < index; i++) for (i = 0; i < index; i++)
{ {
ctap_load_rk(i, &rk2); ctap_load_rk(i, &rk2);
@ -549,7 +549,8 @@ int ctap_authenticate_credential(struct rpId * rp, CTAP_credentialDescriptor * d
uint8_t ctap_make_credential(CborEncoder * encoder, uint8_t * request, int length) uint8_t ctap_make_credential(CborEncoder * encoder, uint8_t * request, int length)
{ {
CTAP_makeCredential MC; CTAP_makeCredential MC;
int ret, i; int ret;
unsigned int i;
uint8_t auth_data_buf[300]; uint8_t auth_data_buf[300];
CTAP_credentialDescriptor * excl_cred = (CTAP_credentialDescriptor *) auth_data_buf; CTAP_credentialDescriptor * excl_cred = (CTAP_credentialDescriptor *) auth_data_buf;
uint8_t * sigbuf = auth_data_buf + 32; uint8_t * sigbuf = auth_data_buf + 32;

View File

@ -79,7 +79,7 @@ uint8_t parse_user(CTAP_makeCredential * MC, CborValue * val)
size_t sz, map_length; size_t sz, map_length;
uint8_t key[24]; uint8_t key[24];
int ret; int ret;
int i; unsigned int i;
CborValue map; CborValue map;
@ -270,7 +270,7 @@ uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val)
uint8_t cred_type; uint8_t cred_type;
int32_t alg_type; int32_t alg_type;
int ret; int ret;
int i; unsigned int i;
CborValue arr; CborValue arr;
@ -319,7 +319,7 @@ uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val)
return CTAP2_ERR_UNSUPPORTED_ALGORITHM; return CTAP2_ERR_UNSUPPORTED_ALGORITHM;
} }
uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len) uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, unsigned int len)
{ {
size_t sz; size_t sz;
int ret; int ret;
@ -344,7 +344,7 @@ uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len)
uint8_t parse_verify_exclude_list(CborValue * val) uint8_t parse_verify_exclude_list(CborValue * val)
{ {
int i; unsigned int i;
int ret; int ret;
CborValue arr; CborValue arr;
size_t size; size_t size;
@ -393,7 +393,7 @@ uint8_t parse_rp(struct rpId * rp, CborValue * val)
size_t sz, map_length; size_t sz, map_length;
char key[8]; char key[8];
int ret; int ret;
int i; unsigned int i;
CborValue map; CborValue map;
@ -481,7 +481,7 @@ uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up)
size_t sz, map_length; size_t sz, map_length;
char key[8]; char key[8];
int ret; int ret;
int i; unsigned int i;
_Bool b; _Bool b;
CborValue map; CborValue map;
@ -559,7 +559,7 @@ uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up)
uint8_t ctap_parse_make_credential(CTAP_makeCredential * MC, CborEncoder * encoder, uint8_t * request, int length) uint8_t ctap_parse_make_credential(CTAP_makeCredential * MC, CborEncoder * encoder, uint8_t * request, int length)
{ {
int ret; int ret;
int i; unsigned int i;
int key; int key;
size_t map_length; size_t map_length;
CborParser parser; CborParser parser;
@ -775,7 +775,8 @@ uint8_t parse_allow_list(CTAP_getAssertion * GA, CborValue * it)
{ {
CborValue arr; CborValue arr;
size_t len; size_t len;
int i,ret; int ret;
unsigned int i;
CTAP_credentialDescriptor * cred; CTAP_credentialDescriptor * cred;
if (cbor_value_get_type(it) != CborArrayType) if (cbor_value_get_type(it) != CborArrayType)
@ -817,7 +818,7 @@ uint8_t parse_allow_list(CTAP_getAssertion * GA, CborValue * it)
uint8_t ctap_parse_get_assertion(CTAP_getAssertion * GA, uint8_t * request, int length) uint8_t ctap_parse_get_assertion(CTAP_getAssertion * GA, uint8_t * request, int length)
{ {
int ret; int ret;
int i; unsigned int i;
int key; int key;
size_t map_length; size_t map_length;
CborParser parser; CborParser parser;
@ -943,7 +944,8 @@ uint8_t parse_cose_key(CborValue * it, uint8_t * x, uint8_t * y, int * kty, int
{ {
CborValue map; CborValue map;
size_t map_length; size_t map_length;
int i,ret,key; int ret,key;
unsigned int i;
int xkey = 0,ykey = 0; int xkey = 0,ykey = 0;
*kty = 0; *kty = 0;
*crv = 0; *crv = 0;
@ -1038,7 +1040,7 @@ uint8_t parse_cose_key(CborValue * it, uint8_t * x, uint8_t * y, int * kty, int
uint8_t ctap_parse_client_pin(CTAP_clientPin * CP, uint8_t * request, int length) uint8_t ctap_parse_client_pin(CTAP_clientPin * CP, uint8_t * request, int length)
{ {
int ret; int ret;
int i; unsigned int i;
int key; int key;
size_t map_length; size_t map_length;
size_t sz; size_t sz;

View File

@ -24,7 +24,7 @@ const char * cbor_value_get_type_string(const CborValue *value);
uint8_t parse_user(CTAP_makeCredential * MC, CborValue * val); uint8_t parse_user(CTAP_makeCredential * MC, CborValue * val);
uint8_t parse_pub_key_cred_param(CborValue * val, uint8_t * cred_type, int32_t * alg_type); uint8_t parse_pub_key_cred_param(CborValue * val, uint8_t * cred_type, int32_t * alg_type);
uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val); uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val);
uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len); uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, unsigned int len);
uint8_t parse_rp_id(struct rpId * rp, CborValue * val); uint8_t parse_rp_id(struct rpId * rp, CborValue * val);
uint8_t parse_rp(struct rpId * rp, CborValue * val); uint8_t parse_rp(struct rpId * rp, CborValue * val);
uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up); uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up);

View File

@ -98,7 +98,7 @@ static uint32_t get_new_cid()
static int8_t add_cid(uint32_t cid) static int8_t add_cid(uint32_t cid)
{ {
int i; uint32_t i;
for(i = 0; i < CID_MAX-1; i++) for(i = 0; i < CID_MAX-1; i++)
{ {
if (!CIDS[i].busy) if (!CIDS[i].busy)
@ -114,7 +114,7 @@ static int8_t add_cid(uint32_t cid)
static int8_t cid_exists(uint32_t cid) static int8_t cid_exists(uint32_t cid)
{ {
int i; uint32_t i;
for(i = 0; i < CID_MAX-1; i++) for(i = 0; i < CID_MAX-1; i++)
{ {
if (CIDS[i].cid == cid) if (CIDS[i].cid == cid)
@ -127,7 +127,7 @@ static int8_t cid_exists(uint32_t cid)
static int8_t cid_refresh(uint32_t cid) static int8_t cid_refresh(uint32_t cid)
{ {
int i; uint32_t i;
for(i = 0; i < CID_MAX-1; i++) for(i = 0; i < CID_MAX-1; i++)
{ {
if (CIDS[i].cid == cid) if (CIDS[i].cid == cid)
@ -142,7 +142,7 @@ static int8_t cid_refresh(uint32_t cid)
static int8_t cid_del(uint32_t cid) static int8_t cid_del(uint32_t cid)
{ {
int i; uint32_t i;
for(i = 0; i < CID_MAX-1; i++) for(i = 0; i < CID_MAX-1; i++)
{ {
if (CIDS[i].cid == cid) if (CIDS[i].cid == cid)
@ -380,7 +380,7 @@ static int ctaphid_buffer_packet(uint8_t * pkt_raw, uint8_t * cmd, uint32_t * ci
printf1(TAG_HID, "Recv packet\n"); printf1(TAG_HID, "Recv packet\n");
printf1(TAG_HID, " CID: %08x \n", pkt->cid); printf1(TAG_HID, " CID: %08x \n", pkt->cid);
printf1(TAG_HID, " cmd: %02x\n", pkt->pkt.init.cmd); printf1(TAG_HID, " cmd: %02x\n", pkt->pkt.init.cmd);
if (!is_cont_pkt(pkt)) printf1(TAG_HID, " length: %d\n", ctaphid_packet_len(pkt)); if (!is_cont_pkt(pkt)) {printf1(TAG_HID, " length: %d\n", ctaphid_packet_len(pkt));}
int ret; int ret;
uint32_t oldcid; uint32_t oldcid;

View File

@ -46,7 +46,7 @@ void device_manage();
// sets status that's uses for sending status updates ~100ms. // sets status that's uses for sending status updates ~100ms.
// A timer should be set up to call `ctaphid_update_status` // A timer should be set up to call `ctaphid_update_status`
void device_set_status(int status); void device_set_status(uint32_t status);
// Returns if button is currently pressed // Returns if button is currently pressed
int device_is_button_pressed(); int device_is_button_pressed();

View File

@ -57,7 +57,7 @@ __attribute__((weak)) void set_logging_tag(uint32_t tag)
void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...) void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...)
{ {
int i; unsigned int i;
if (((tag & 0x7fffffff) & LOGMASK) == 0) if (((tag & 0x7fffffff) & LOGMASK) == 0)
{ {

View File

@ -19,7 +19,7 @@
#if !defined(TEST) #if !defined(TEST)
int main(int argc, char * argv[]) int main()
{ {
uint8_t hidmsg[64]; uint8_t hidmsg[64];
uint32_t t1 = 0; uint32_t t1 = 0;

View File

@ -26,7 +26,7 @@
void authenticator_initialize(); void authenticator_initialize();
uint32_t __device_status = 0; uint32_t __device_status = 0;
void device_set_status(int status) void device_set_status(uint32_t status)
{ {
if (status != CTAPHID_STATUS_IDLE && __device_status != status) if (status != CTAPHID_STATUS_IDLE && __device_status != status)
{ {

View File

@ -38,7 +38,7 @@ void BOOT_boot(void)
((pFunction)bootAddress[1])(); ((pFunction)bootAddress[1])();
} }
int main(int argc, char * argv[]) int main()
{ {
uint8_t hidmsg[64]; uint8_t hidmsg[64];
uint32_t t1 = 0; uint32_t t1 = 0;

View File

@ -43,7 +43,7 @@ endif
DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"app.h\" $(EXTRA_DEFINES) DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"app.h\" $(EXTRA_DEFINES)
# DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1
CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) CFLAGS=$(INC) -c $(DEFINES) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS)
LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -u _printf_float -lnosys LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -u _printf_float -lnosys
LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic -ltinycbor LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic -ltinycbor

View File

@ -41,7 +41,7 @@ endif
DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"bootloader.h\" $(EXTRA_DEFINES) DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"bootloader.h\" $(EXTRA_DEFINES)
# DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1
CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) CFLAGS=$(INC) -c $(DEFINES) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS)
LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -lnosys LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -lnosys
LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic

View File

@ -99,7 +99,7 @@ void crypto_sha256_final(uint8_t * hash)
void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac) void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac)
{ {
uint8_t buf[64]; uint8_t buf[64];
int i; unsigned int i;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (key == CRYPTO_MASTER_KEY) if (key == CRYPTO_MASTER_KEY)
@ -133,7 +133,7 @@ void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac)
void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac) void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac)
{ {
uint8_t buf[64]; uint8_t buf[64];
int i; unsigned int i;
crypto_sha256_final(hmac); crypto_sha256_final(hmac);
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (key == CRYPTO_MASTER_KEY) if (key == CRYPTO_MASTER_KEY)

View File

@ -63,7 +63,7 @@ uint32_t millis()
return (((uint32_t)TIM6->CNT) + (__90_ms * 90)); return (((uint32_t)TIM6->CNT) + (__90_ms * 90));
} }
void device_set_status(int status) void device_set_status(uint32_t status)
{ {
__disable_irq(); __disable_irq();
__last_update = millis(); __last_update = millis();

View File

@ -133,7 +133,7 @@ void flash_write_dword(uint32_t addr, uint64_t data)
void flash_write(uint32_t addr, uint8_t * data, size_t sz) void flash_write(uint32_t addr, uint8_t * data, size_t sz)
{ {
int i; unsigned int i;
uint8_t buf[8]; uint8_t buf[8];
while (FLASH->SR & (1<<16)) while (FLASH->SR & (1<<16))
; ;