Fix esc_foe Wconversion warnings

- make "size" variables not reflecting hardware or protocol
  uint32_t or size_t.

- add excplcit typecaste for uint8_t and uint16_t that need it
  due to integer promotion
pull/149/head
Andreas Karlsson 2023-03-16 17:01:55 +01:00
parent 45d390a014
commit 3896a981ce
1 changed files with 19 additions and 19 deletions

View File

@ -50,7 +50,7 @@ static _FOEvar FOEvar;
* @return 0= if we succeed, FOE_ERR_NOTFOUND something wrong with filename or
* password
*/
static int FOE_fopen (char *name, uint8_t num_chars, uint32_t pass, uint8_t op)
static uint32_t FOE_fopen (char *name, uint8_t num_chars, uint32_t pass, uint8_t op)
{
uint32_t i;
@ -118,9 +118,9 @@ static int FOE_fopen (char *name, uint8_t num_chars, uint32_t pass, uint8_t op)
* @return Number of copied bytes.
*/
static uint16_t FOE_fread (uint8_t * data, uint16_t maxlength)
static uint32_t FOE_fread (uint8_t * data, uint32_t maxlength)
{
uint16_t ncopied = 0;
uint32_t ncopied = 0;
while (maxlength && (FOEvar.fend - FOEvar.fposition))
{
@ -144,9 +144,9 @@ static uint16_t FOE_fread (uint8_t * data, uint16_t maxlength)
* @return Number of copied bytes.
*/
static uint16_t FOE_fwrite (uint8_t *data, uint16_t length)
static uint32_t FOE_fwrite (uint8_t *data, uint32_t length)
{
uint16_t ncopied = 0;
uint32_t ncopied = 0;
uint32_t failed = 0;
DPRINT("FOE_fwrite\n");
@ -249,10 +249,10 @@ static void FOE_abort (uint32_t code)
* @return Number of data bytes written or an error number. Error numbers
* will be greater than FOE_DATA_SIZE.
*/
static int FOE_send_data_packet ()
static uint32_t FOE_send_data_packet ()
{
_FOE *foembx;
uint16_t data_len;
uint32_t data_len;
uint8_t mbxhandle;
mbxhandle = ESC_claimbuffer ();
@ -280,7 +280,7 @@ static int FOE_send_data_packet ()
* @return 0= or error number.
*/
static int FOE_send_ack ()
static uint32_t FOE_send_ack ()
{
_FOE *foembx;
uint8_t mbxhandle;
@ -316,9 +316,9 @@ static int FOE_send_ack ()
static void FOE_read ()
{
_FOE *foembx;
uint32_t data_len;
uint32_t password;
int res;
uint32_t res;
uint8_t data_len;
if (FOEvar.foestate != FOE_READY)
{
@ -329,7 +329,7 @@ static void FOE_read ()
FOE_init ();
foembx = (_FOE *) &MBX[0];
/* Get the length of the file name in octets. */
data_len = etohs (foembx->mbxheader.length) - ESC_FOEHSIZE;
data_len = (uint8_t)(etohs (foembx->mbxheader.length) - ESC_FOEHSIZE);
password = etohl (foembx->foeheader.password);
res = FOE_fopen (foembx->filename, data_len, password, FOE_OP_RRQ);
@ -340,7 +340,7 @@ static void FOE_read ()
* Attempt to send the packet
*/
res = FOE_send_data_packet ();
if (res <= (int)ESC_FOE_DATA_SIZE)
if (res <= ESC_FOE_DATA_SIZE)
{
FOEvar.foestate = FOE_WAIT_FOR_ACK;
}
@ -360,7 +360,7 @@ static void FOE_read ()
*/
static void FOE_ack ()
{
int res;
uint32_t res;
/* Make sure we're able to take this. */
if (FOEvar.foestate == FOE_WAIT_FOR_FINAL_ACK)
@ -375,7 +375,7 @@ static void FOE_ack ()
return;
}
res = FOE_send_data_packet ();
if (res < (int)ESC_FOE_DATA_SIZE)
if (res < ESC_FOE_DATA_SIZE)
{
FOEvar.foestate = FOE_WAIT_FOR_FINAL_ACK;
}
@ -393,9 +393,9 @@ static void FOE_ack ()
static void FOE_write ()
{
_FOE *foembx;
uint32_t data_len;
uint32_t password;
int res;
uint32_t res;
uint8_t data_len;
if (FOEvar.foestate != FOE_READY)
{
@ -405,7 +405,7 @@ static void FOE_write ()
FOE_init ();
foembx = (_FOE *) &MBX[0];
data_len = etohs (foembx->mbxheader.length) - ESC_FOEHSIZE;
data_len = (uint8_t)(etohs (foembx->mbxheader.length) - ESC_FOEHSIZE);
password = etohl (foembx->foeheader.password);
/* Get an address we can write the file to, if possible. */
@ -436,8 +436,8 @@ static void FOE_data ()
{
_FOE *foembx;
uint32_t packet;
uint16_t data_len, ncopied;
int res;
uint32_t data_len, ncopied;
uint32_t res;
if(FOEvar.foestate != FOE_WAIT_FOR_DATA)
{