mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-06 04:03:38 +08:00
Fix compiling on MS VS 2022 (64-Bit) without type conversion warnings
This commit is contained in:
@@ -85,11 +85,11 @@ tftp_close(void* handle)
|
|||||||
static int
|
static int
|
||||||
tftp_read(void* handle, void* buf, int bytes)
|
tftp_read(void* handle, void* buf, int bytes)
|
||||||
{
|
{
|
||||||
int ret = fread(buf, 1, bytes, (FILE*)handle);
|
size_t ret = fread(buf, 1, bytes, (FILE*)handle);
|
||||||
if (ret <= 0) {
|
if ((ret == 0) || (ret > INT_MAX)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return (int)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ int process_sub(FILE *data_file, FILE *struct_file);
|
|||||||
int process_file(FILE *data_file, FILE *struct_file, const char *filename);
|
int process_file(FILE *data_file, FILE *struct_file, const char *filename);
|
||||||
int file_write_http_header(FILE *data_file, const char *filename, int file_size, u16_t *http_hdr_len,
|
int file_write_http_header(FILE *data_file, const char *filename, int file_size, u16_t *http_hdr_len,
|
||||||
u16_t *http_hdr_chksum, u8_t provide_content_len, int is_compressed);
|
u16_t *http_hdr_chksum, u8_t provide_content_len, int is_compressed);
|
||||||
int file_put_ascii(FILE *file, const char *ascii_string, int len, int *i);
|
int file_put_ascii(FILE *file, const char *ascii_string, size_t len, int *i);
|
||||||
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i);
|
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i);
|
||||||
void concat_files(const char *file1, const char *file2, const char *targetfile);
|
void concat_files(const char *file1, const char *file2, const char *targetfile);
|
||||||
int check_path(char *path, size_t size);
|
int check_path(char *path, size_t size);
|
||||||
@@ -590,7 +590,7 @@ static u8_t *get_file_data(const char *filename, int *file_size, int can_be_comp
|
|||||||
LWIP_ASSERT("buf != NULL", buf != NULL);
|
LWIP_ASSERT("buf != NULL", buf != NULL);
|
||||||
r = fread(buf, 1, fsize, inFile);
|
r = fread(buf, 1, fsize, inFile);
|
||||||
LWIP_ASSERT("r == fsize", r == fsize);
|
LWIP_ASSERT("r == fsize", r == fsize);
|
||||||
*file_size = fsize;
|
*file_size = rs;
|
||||||
*is_compressed = 0;
|
*is_compressed = 0;
|
||||||
#if MAKEFS_SUPPORT_DEFLATE
|
#if MAKEFS_SUPPORT_DEFLATE
|
||||||
overallDataBytes += fsize;
|
overallDataBytes += fsize;
|
||||||
@@ -715,6 +715,9 @@ static int write_checksums(FILE *struct_file, const char *varname,
|
|||||||
#if LWIP_TCP_TIMESTAMPS
|
#if LWIP_TCP_TIMESTAMPS
|
||||||
/* when timestamps are used, usable space is 12 bytes less per segment */
|
/* when timestamps are used, usable space is 12 bytes less per segment */
|
||||||
chunk_size -= 12;
|
chunk_size -= 12;
|
||||||
|
#if TCP_MSS <= 12
|
||||||
|
#error TCP_MSS <= 12
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf(struct_file, "#if HTTPD_PRECALCULATED_CHECKSUM" NEWLINE);
|
fprintf(struct_file, "#if HTTPD_PRECALCULATED_CHECKSUM" NEWLINE);
|
||||||
@@ -726,7 +729,7 @@ static int write_checksums(FILE *struct_file, const char *varname,
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
src_offset = 0;
|
src_offset = 0;
|
||||||
for (offset = hdr_len; ; offset += len) {
|
for (offset = hdr_len; ; offset += (int)len) {
|
||||||
unsigned short chksum;
|
unsigned short chksum;
|
||||||
const void *data = (const void *)&file_data[src_offset];
|
const void *data = (const void *)&file_data[src_offset];
|
||||||
len = LWIP_MIN(chunk_size, (int)file_size - src_offset);
|
len = LWIP_MIN(chunk_size, (int)file_size - src_offset);
|
||||||
@@ -1281,9 +1284,12 @@ int file_write_http_header(FILE *data_file, const char *filename, int file_size,
|
|||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_put_ascii(FILE *file, const char *ascii_string, int len, int *i)
|
int file_put_ascii(FILE *file, const char *ascii_string, size_t len, int *i)
|
||||||
{
|
{
|
||||||
int x;
|
if (len > INT_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
size_t x;
|
||||||
for (x = 0; x < len; x++) {
|
for (x = 0; x < len; x++) {
|
||||||
unsigned char cur = ascii_string[x];
|
unsigned char cur = ascii_string[x];
|
||||||
fprintf(file, "0x%02x,", cur);
|
fprintf(file, "0x%02x,", cur);
|
||||||
@@ -1291,7 +1297,7 @@ int file_put_ascii(FILE *file, const char *ascii_string, int len, int *i)
|
|||||||
fprintf(file, NEWLINE);
|
fprintf(file, NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i)
|
int s_put_ascii(char *buf, const char *ascii_string, int len, int *i)
|
||||||
|
|||||||
@@ -1919,7 +1919,7 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre
|
|||||||
}
|
}
|
||||||
|
|
||||||
MEMCPY(secret, pcb->settings.passwd, len);
|
MEMCPY(secret, pcb->settings.passwd, len);
|
||||||
*secret_len = len;
|
*secret_len = (int)len;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#if 0 /* UNUSED */
|
#if 0 /* UNUSED */
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ static void chap_respond(ppp_pcb *pcb, int id,
|
|||||||
memset(secret, 0, secret_len);
|
memset(secret, 0, secret_len);
|
||||||
|
|
||||||
clen = *outp;
|
clen = *outp;
|
||||||
nlen = strlen(pcb->chap_client.name);
|
nlen = (int)strlen(pcb->chap_client.name);
|
||||||
memcpy(outp + clen + 1, pcb->chap_client.name, nlen);
|
memcpy(outp + clen + 1, pcb->chap_client.name, nlen);
|
||||||
|
|
||||||
outp = (u_char*)p->payload + PPP_HDRLEN;
|
outp = (u_char*)p->payload + PPP_HDRLEN;
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) {
|
|||||||
if (fillch == '0' && prec >= 0) {
|
if (fillch == '0' && prec >= 0) {
|
||||||
n = prec;
|
n = prec;
|
||||||
} else {
|
} else {
|
||||||
n = strlen((const char *)p);
|
n = (int)strlen((const char *)p);
|
||||||
if (prec >= 0 && n > prec)
|
if (prec >= 0 && n > prec)
|
||||||
n = prec;
|
n = prec;
|
||||||
}
|
}
|
||||||
@@ -378,7 +378,7 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) {
|
|||||||
}
|
}
|
||||||
len = num + sizeof(num) - 1 - str;
|
len = num + sizeof(num) - 1 - str;
|
||||||
} else {
|
} else {
|
||||||
len = strlen(str);
|
len = (int)strlen(str);
|
||||||
if (prec >= 0 && len > prec)
|
if (prec >= 0 && len > prec)
|
||||||
len = prec;
|
len = prec;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user