Skip to content
Snippets Groups Projects
Commit 4b872b56 authored by rahix's avatar rahix
Browse files

Merge 'Increase warning level & Fix all warnings'

Closes #192

See merge request card10/firmware!360
parents 1eef5c51 24985020
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 41 deletions
......@@ -4,7 +4,7 @@ image: "derq3k/card10-build-env:20190806-195837Z-f95b541-dirty"
build:
stage: build
script:
- ./bootstrap.sh
- ./bootstrap.sh --werror
- ninja -C build/
- arm-none-eabi-size build/bootloader/bootloader.elf build/epicardium/epicardium.elf build/pycardium/pycardium.elf
only:
......@@ -14,7 +14,7 @@ build:
release:
stage: build
script:
- ./bootstrap.sh
- ./bootstrap.sh --werror
- ninja -C build/
- arm-none-eabi-size build/bootloader/bootloader.elf build/epicardium/epicardium.elf build/pycardium/pycardium.elf
only:
......
#!/usr/bin/env python3
import sys
import warnings
warnings.simplefilter("ignore")
try:
import crc16
......
......@@ -109,7 +109,7 @@ int api_fetch_args(char *buf, size_t cnt)
return 0;
}
int i;
size_t i;
for (i = 0; i < cnt && API_CALL_MEM->buffer[i + 0x20] != '\0'; i++) {
buf[i] = API_CALL_MEM->buffer[i + 0x20];
}
......
......@@ -86,7 +86,7 @@ void api_prepare_args(char *args)
* collide with any integer return value of API calls like epic_exec().
*/
API_CALL_MEM->id = 0;
for (int i = 0; i <= strlen(args); i++) {
for (size_t i = 0; i <= strlen(args); i++) {
API_CALL_MEM->buffer[i + 0x20] = args[i];
}
}
......@@ -11,7 +11,7 @@ int api_interrupt_trigger(api_int_id_t id)
}
if (int_enabled[id]) {
while (API_CALL_MEM->int_id != (-1))
while (API_CALL_MEM->int_id != (api_int_id_t)(-1))
;
API_CALL_MEM->int_id = id;
......
......@@ -122,6 +122,11 @@ static const smpCfg_t bleSmpCfg =
16, /*! Maximum encryption key length */
3, /*! Attempts to trigger 'repeated attempts' timeout */
DM_AUTH_MITM_FLAG, /*! Device authentication requirements */
/* TODO: The following three parameters should probably get proper values */
0, /*! Maximum 'Repeated attempts' timeout in msec */
0, /*! Time msec before attemptExp decreases */
0, /*! Exponent to raise attemptTimeout on maxAttempts */
};
/* Configuration structure */
......
......@@ -320,7 +320,7 @@ API(API_THERMISTOR_VOLTAGE, int epic_read_thermistor_voltage(float *result));
* :param length: Amount of bytes to print.
*/
API(API_UART_WRITE_STR, void epic_uart_write_str(
const char *str, intptr_t length
const char *str, size_t length
));
/**
......
......@@ -119,7 +119,7 @@ static int _seek_and_read(int fd, uint32_t address, void *data, size_t count)
return res;
}
if ((res = epic_file_read(fd, data, count)) != count) {
if ((size_t)(res = epic_file_read(fd, data, count)) != count) {
LOG_ERR("l0der", "_seek_and_read: could not read: %d", res);
return res;
}
......@@ -149,7 +149,7 @@ static int _read_section_header(int fd, uint32_t shdr_addr, Elf32_Shdr *shdr)
* This function ensures basic memory sanity of a program header / segment.
* It ensures that it points to a file region that is contained within the file fully.
*/
static int _check_program_header(int fd, int size, Elf32_Phdr *phdr)
static int _check_program_header(int fd, size_t size, Elf32_Phdr *phdr)
{
// Check file size/offset.
uint32_t file_start = phdr->p_offset;
......@@ -191,7 +191,7 @@ static int _check_program_header(int fd, int size, Elf32_Phdr *phdr)
* This function ensures basic memory sanity of a section header.
* It ensures that it points to a file region that is contained within the file fully.
*/
static int _check_section_header(int fd, int size, Elf32_Shdr *shdr)
static int _check_section_header(int fd, size_t size, Elf32_Shdr *shdr)
{
// Check file size/offset.
uint32_t file_start = shdr->sh_offset;
......@@ -329,7 +329,7 @@ static int _load_segment(int fd, struct _pie_load_info *li, Elf32_Phdr *phdr)
* Parse dynamic symbol sections.
*/
static int _parse_dynamic_symbols(
int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr
int fd, size_t size, struct _pie_load_info *li, Elf32_Ehdr *hdr
) {
int res;
Elf32_Shdr shdr;
......@@ -366,7 +366,7 @@ static int _parse_dynamic_symbols(
return res;
}
for (int j = 0; j < sym_count; j++) {
for (uint32_t j = 0; j < sym_count; j++) {
if ((res = epic_file_read(
fd, &sym, sizeof(Elf32_Sym))) !=
sizeof(Elf32_Sym)) {
......@@ -402,9 +402,9 @@ static int _parse_dynamic_symbols(
* the only one used when making 'standard' PIE binaries on RAM. However, other
* kinds might have to be implemented in the future.
*/
static int
_run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr)
{
static int _run_relocations(
int fd, size_t size, struct _pie_load_info *li, Elf32_Ehdr *hdr
) {
int res;
Elf32_Shdr shdr;
Elf32_Rel rel;
......@@ -447,7 +447,7 @@ _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr)
return res;
}
for (int j = 0; j < reloc_count; j++) {
for (uint32_t j = 0; j < reloc_count; j++) {
if ((res = epic_file_read(
fd, &rel, sizeof(Elf32_Rel))) !=
sizeof(Elf32_Rel)) {
......@@ -464,7 +464,7 @@ _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr)
// (ie., do not resolve relocation - they default to a safe NULL)
uint8_t skip = 0;
if (sym != 0) {
for (int k = 0; k < li->weak_symbol_count;
for (uint32_t k = 0; k < li->weak_symbol_count;
k++) {
if (li->weak_symbols[k] == sym) {
skip = 1;
......@@ -513,7 +513,7 @@ _run_relocations(int fd, int size, struct _pie_load_info *li, Elf32_Ehdr *hdr)
* Load a l0dable PIE binary.
*/
static int
_load_pie(int fd, int size, Elf32_Ehdr *hdr, struct l0dable_info *info)
_load_pie(int fd, size_t size, Elf32_Ehdr *hdr, struct l0dable_info *info)
{
int res;
struct _pie_load_info li = { 0 };
......@@ -647,7 +647,10 @@ int l0der_load_path(const char *path, struct l0dable_info *info)
return res;
}
int size = epic_file_tell(fd);
if ((res = epic_file_tell(fd)) < 0) {
return res;
}
size_t size = res;
if ((res = epic_file_seek(fd, 0, SEEK_SET)) != 0) {
return res;
......
......@@ -227,7 +227,7 @@ out_free_i2c:
void epic_bhi160_disable_all_sensors()
{
for (int i = 0; i < sizeof(bhi160_sensor_active); i++) {
for (size_t i = 0; i < sizeof(bhi160_sensor_active); i++) {
if (bhi160_sensor_active[i]) {
epic_bhi160_disable_sensor(i);
}
......
......@@ -14,7 +14,7 @@
#define MAX_LINE_LENGTH 80
#define KEYS_PER_BLOCK 16
#define KEY_LENGTH 16
#define NOT_INT_MAGIC 0x80000000
#define NOT_INT_MAGIC ((int)0x80000000)
// one key-value pair representing a line in the config
typedef struct {
......
......@@ -95,7 +95,7 @@ int hardware_early_init(void)
;
/* If we don't have a valid time yet, set it to 2019-01-01 */
if (RTC_GetSecond() < 1546300800UL) {
if (RTC_GetSecond() < 1546300800L) {
epic_rtc_set_milliseconds(1546300800UL * 1000);
}
......
......@@ -310,11 +310,11 @@ static int max30001_fetch_fifo(void)
uint32_t ecgFIFO, readECGSamples, ETAG[32], status;
int16_t ecgSample[32];
const int EINT_STATUS_MASK = 1 << 23;
const int FIFO_OVF_MASK = 0x7;
const int FIFO_VALID_SAMPLE_MASK = 0x0;
const int FIFO_FAST_SAMPLE_MASK = 0x1;
const int ETAG_BITS_MASK = 0x7;
const uint32_t EINT_STATUS_MASK = 1 << 23;
const uint32_t FIFO_OVF_MASK = 0x7;
const uint32_t FIFO_VALID_SAMPLE_MASK = 0x0;
const uint32_t FIFO_FAST_SAMPLE_MASK = 0x1;
const uint32_t ETAG_BITS_MASK = 0x7;
status = ecg_read_reg(STATUS); // Read the STATUS register
......
......@@ -18,7 +18,7 @@ int personal_state_enabled()
int epic_personal_state_set(uint8_t state, bool persistent)
{
if (state < STATE_NONE || state > STATE_CAMP)
if (state > STATE_CAMP)
return -EINVAL;
led_animation_state = 0;
......
......@@ -54,7 +54,7 @@ void serial_return_to_synchronous()
/*
* API-call to write a string. Output goes to both CDCACM and UART
*/
void epic_uart_write_str(const char *str, intptr_t length)
void epic_uart_write_str(const char *str, size_t length)
{
if (length == 0) {
return;
......@@ -161,7 +161,7 @@ static void serial_flush_from_isr(void)
taskEXIT_CRITICAL_FROM_ISR(basepri);
portYIELD_FROM_ISR(&resched);
portYIELD_FROM_ISR(resched);
}
static void serial_flush_from_thread(void)
......
......@@ -142,8 +142,7 @@ static void gpio_low_power(void)
const unsigned int num_pins =
(sizeof(pins_low_power) / sizeof(gpio_cfg_t));
int i;
for (i = 0; i < num_pins; i++) {
for (size_t i = 0; i < num_pins; i++) {
GPIO_OutClr(&pins_low_power[i]);
GPIO_Config(&pins_low_power[i]);
}
......
......@@ -401,11 +401,11 @@ int main(void)
uint32_t ecgFIFO, readECGSamples, idx, ETAG[32], status;
int16_t ecgSample[32];
const int EINT_STATUS_MASK = 1 << 23;
const int FIFO_OVF_MASK = 0x7;
const int FIFO_VALID_SAMPLE_MASK = 0x0;
const int FIFO_FAST_SAMPLE_MASK = 0x1;
const int ETAG_BITS_MASK = 0x7;
const uint32_t EINT_STATUS_MASK = 1 << 23;
const uint32_t FIFO_OVF_MASK = 0x7;
const uint32_t FIFO_VALID_SAMPLE_MASK = 0x0;
const uint32_t FIFO_FAST_SAMPLE_MASK = 0x1;
const uint32_t ETAG_BITS_MASK = 0x7;
while (1) {
#if 1
......
......@@ -69,7 +69,7 @@ void card10_init(void)
)
;
/* If we don't have a valid time yet, set it to 2019-01-01 */
if (RTC_GetSecond() < 1546300800UL) {
if (RTC_GetSecond() < 1546300800L) {
while (RTC_Init(MXC_RTC, 1546300800UL, 0, NULL) == E_BUSY)
;
}
......
......@@ -100,7 +100,7 @@ int portexpander_init(void)
// Enable pull-ups for buttons
// Enable outputs for the transistors, the LED and the LCD reset
for (int i = 0; i < sizeof(pe_pin_config) / sizeof(pe_pin_config[0]);
for (size_t i = 0; i < sizeof(pe_pin_config) / sizeof(pe_pin_config[0]);
i++) {
ret = portexpander_config(&pe_pin_config[i]);
MXC_ASSERT(ret == E_NO_ERROR);
......
......@@ -16,6 +16,7 @@ lib = static_library(
sources,
include_directories: includes,
dependencies: [periphdriver, mx25lba],
c_args: '-w',
)
libff13 = declare_dependency(
......
......@@ -2,8 +2,8 @@
void fb_clear_to_color(struct framebuffer *fb, Color c)
{
for (int y = 0; y < fb->height; y++) {
for (int x = 0; x < fb->width; x++)
for (size_t y = 0; y < fb->height; y++) {
for (size_t x = 0; x < fb->width; x++)
fb_setpixel(fb, x, y, c);
}
}
......@@ -77,7 +77,7 @@ void *fb_pixel(struct framebuffer *fb, int x, int y)
if (xo < 0 || yo < 0)
return NULL;
if (xo >= fb->width || yo >= fb->height)
if (xo >= (int)fb->width || yo >= (int)fb->height)
return NULL;
const size_t bpp = fb_bytes_per_pixel(fb);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment