From a3fb0b05f76e22e59b57626ec38cc9d97645268e Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Fri, 22 Nov 2019 21:55:03 +0100 Subject: [PATCH] fix(serial): Make length parameter a size_t Make the length parameter a `size_t` instead of a `intptr_t`. A signed value does not make any sense here and just leads to weird behavior if a negative value is given nonetheless. See issue card10/firmware#192 Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/epicardium.h | 2 +- epicardium/modules/serial.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 13358966d..400ca00eb 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -317,7 +317,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 )); /** diff --git a/epicardium/modules/serial.c b/epicardium/modules/serial.c index ef5b65edd..befca3b50 100644 --- a/epicardium/modules/serial.c +++ b/epicardium/modules/serial.c @@ -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; -- GitLab