Fix all warnings
This commit is contained in:
2023-11-17 16:27:26 +01:00
parent 0da6b4a5ad
commit f82634daa0
2 changed files with 8 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ extern "C" {
#define TFTP_READ 0
#define UNUSED(x) (void)(x)
typedef struct tftp_custom_file_s {
char* data;
size_t len;

View File

@@ -116,6 +116,8 @@ size_t tftp_custom_fwrite(const void* buf, size_t bytes, tftp_custom_file_t* han
void* tftp_open(const char* fname, const char* mode, uint8_t write) {
LOG_INFO(TAG, "Opening %s", fname);
UNUSED(mode);
if (strcmp(fname, virt_file[0].name) == 0 && write == TFTP_READ) {
tftp_custom_fseek(&virt_file[0], 0, SEEK_SET);
return &virt_file[0];
@@ -182,7 +184,7 @@ int tftp_read(void* handle, void* buf, int bytes) {
FILE* file = (FILE*)handle;
if ((tftp_custom_file_t*)file == &virt_file[0]) {
ret = tftp_custom_fread(buf, bytes, (tftp_custom_file_t*)file);
ret = (int)tftp_custom_fread(buf, (size_t)bytes, (tftp_custom_file_t*)file);
return ret;
} else if ((tftp_custom_file_t*)file == &virt_file[1]) {
LOG_CRIT(TAG, "Exception: Trying to read a write only file");
@@ -191,8 +193,8 @@ int tftp_read(void* handle, void* buf, int bytes) {
LOG_CRIT(TAG, "Exception: Trying to read a write only file");
return -1;
}
// TODO: waiting on Lorentz to finish creating f* functions for LLFS
ret = fread(buf, sizeof(uint8_t), bytes, file);
ret = (int)fread(buf, sizeof(uint8_t), (size_t)bytes, file);
if (ret <= 0) {
return -1;
}
@@ -212,7 +214,7 @@ int tftp_write(void* handle, struct pbuf* p) {
LOG_DEBUG(TAG, "Not implemented yet");
tftp_custom_file_t* file = (tftp_custom_file_t*)handle;
if (file == &virt_file[1] || file == &virt_file[2]) {
return tftp_custom_fwrite(p->payload, p->len, file);
return (int)tftp_custom_fwrite(p->payload, (size_t)(p->len), file);
}
return -1;
}