[64bit] fix a few more 64bit warnings in newer code

This commit is contained in:
Travis Geiselbrecht
2015-09-20 13:11:51 -07:00
parent 9016e86d4f
commit 215b5ed07f
7 changed files with 24 additions and 22 deletions

View File

@@ -62,13 +62,13 @@ typedef struct {
} download_t;
static download_t* make_download(const char* name)
{
{
download_t* s = malloc(sizeof(download_t));
s->start = download_start;
s->end = s->start;
s->max = download_start + DOWNLOAD_SLOT_SIZE;
strncpy(s->name, name, FNAME_SIZE);
download_start = s->max;
memset(s->start, 0, DOWNLOAD_SLOT_SIZE);
return s;
@@ -78,7 +78,7 @@ static size_t output_result(const download_t* download)
{
size_t len = download->end - download->start;
unsigned long crc = crc32(0, download->start, len);
printf("[%s] done, start at: %p - %d bytes, crc32 = %lu\n",
printf("[%s] done, start at: %p - %zu bytes, crc32 = %lu\n",
download->name, download->start, len, crc);
return len;
}
@@ -88,8 +88,8 @@ static int run_elf(void* entry_point)
void (*elf_start)(void) = (void*)entry_point;
printf("elf (%p) running ...\n", entry_point);
thread_sleep(10);
elf_start();
printf("elf (%p) finished\n", entry_point);
elf_start();
printf("elf (%p) finished\n", entry_point);
return 0;
}
@@ -111,7 +111,7 @@ static void process_elf_blob(const void* start, size_t len)
printf("elf looks good\n");
thread_resume(thread_create("elf_runner", &run_elf, (void*)elf.entry,
DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
elf_close_handle(&elf);
}
@@ -164,7 +164,7 @@ usage:
} else if (strcmp(argv[1].str, "elf") == 0) {
download->type = DOWNLOAD_ELF;
} else {
goto usage;
goto usage;
}
tftp_set_write_client(download->name, &tftp_callback, download);

View File

@@ -451,7 +451,7 @@ status_t virtio_net_get_mac_addr(uint8_t mac_addr[6])
status_t virtio_net_send_minip_pkt(pktbuf_t *p)
{
LTRACEF("p %p, dlen %zu, flags 0x%x\n", p, p->dlen, p->flags);
LTRACEF("p %p, dlen %u, flags 0x%x\n", p, p->dlen, p->flags);
DEBUG_ASSERT(p && p->dlen);

View File

@@ -37,7 +37,7 @@ struct read_hook_memory_args {
size_t len;
};
static ssize_t elf_read_hook_memory(struct elf_handle *handle, void *buf, off_t offset, size_t len)
static ssize_t elf_read_hook_memory(struct elf_handle *handle, void *buf, uint64_t offset, size_t len)
{
LTRACEF("handle %p, buf %p, offset %lld, len %zu\n", handle, buf, offset, len);
@@ -193,7 +193,7 @@ status_t elf_load(elf_handle_t *handle)
}
LTRACEF("program headers:\n");
for (size_t i = 0; i < handle->eheader.e_phnum; i++) {
for (uint i = 0; i < handle->eheader.e_phnum; i++) {
// parse the program headers
struct Elf32_Phdr *pheader = &handle->pheaders[i];
@@ -204,8 +204,8 @@ status_t elf_load(elf_handle_t *handle)
if (pheader->p_type == PT_LOAD) {
// read the file portion of the segment into memory at vaddr
LTRACEF("reading segment at offset %u to address %p\n", pheader->p_offset, (void *)pheader->p_vaddr);
readerr = handle->read_hook(handle, (void *)pheader->p_vaddr, pheader->p_offset, pheader->p_filesz);
LTRACEF("reading segment at offset %u to address 0x%x\n", pheader->p_offset, pheader->p_vaddr);
readerr = handle->read_hook(handle, (void *)(uintptr_t)pheader->p_vaddr, pheader->p_offset, pheader->p_filesz);
if (readerr < (ssize_t)pheader->p_filesz) {
LTRACEF("error %ld reading program header %u\n", readerr, i);
return (readerr < 0) ? readerr : ERR_IO;
@@ -214,7 +214,7 @@ status_t elf_load(elf_handle_t *handle)
// zero out he difference between memsz and filesz
size_t tozero = pheader->p_memsz - pheader->p_filesz;
if (tozero > 0) {
uint8_t *ptr = (uint8_t *)pheader->p_vaddr + pheader->p_filesz;
uint8_t *ptr = (uint8_t *)(uintptr_t)pheader->p_vaddr + pheader->p_filesz;
LTRACEF("zeroing memory at %p, size %zu\n", ptr, tozero);
memset(ptr, 0, tozero);
}

View File

@@ -28,7 +28,7 @@
/* api */
struct elf_handle;
typedef ssize_t (*elf_read_hook_t)(struct elf_handle *, void *buf, off_t offset, size_t len);
typedef ssize_t (*elf_read_hook_t)(struct elf_handle *, void *buf, uint64_t offset, size_t len);
typedef struct elf_handle {
bool open;

View File

@@ -46,7 +46,7 @@ typedef struct pktbuf {
u8 *data;
u32 blen;
u32 dlen;
u32 phys_base;
paddr_t phys_base;
struct list_node list;
u32 flags;
pktbuf_free_callback cb;

View File

@@ -343,7 +343,7 @@ static void tcp_timer_cancel(tcp_socket_t *s, net_timer_t *timer)
void tcp_input(pktbuf_t *p, uint32_t src_ip, uint32_t dst_ip)
{
if (unlikely(tcp_debug))
TRACEF("p %p (len %zu), src_ip 0x%x, dst_ip 0x%x\n", p, p->dlen, src_ip, dst_ip);
TRACEF("p %p (len %u), src_ip 0x%x, dst_ip 0x%x\n", p, p->dlen, src_ip, dst_ip);
tcp_header_t *header = (tcp_header_t *)p->data;
@@ -504,7 +504,7 @@ void tcp_input(pktbuf_t *p, uint32_t src_ip, uint32_t dst_ip)
}
if (data_len > 0) {
LTRACEF("new data, len %u\n", data_len);
LTRACEF("new data, len %zu\n", data_len);
handle_data(s, p->data, p->dlen, header->seq_num);
}
@@ -665,7 +665,7 @@ static status_t tcp_socket_send(tcp_socket_t *s, const void *data, size_t len, t
// calculate the new right edge of the rx window
uint32_t rx_win_high = s->rx_win_low + s->rx_win_size - cbuf_space_used(&s->rx_buffer) - 1;
LTRACEF("rx_win_low %u rx_win_size %u read_buf_len %d, new win high %u\n",
LTRACEF("rx_win_low %u rx_win_size %u read_buf_len %zu, new win high %u\n",
s->rx_win_low, s->rx_win_size, cbuf_space_used(&s->rx_buffer), rx_win_high);
uint16_t win_size;
@@ -760,7 +760,7 @@ static void handle_ack(tcp_socket_t *s, uint32_t sequence, uint32_t win_size)
DEBUG_ASSERT(s);
DEBUG_ASSERT(is_mutex_held(&s->lock));
LTRACEF("s %p, tx_win_low %u tx_win_high %u tx_highest_seq %u bufsize %zu offset %zu\n",
LTRACEF("s %p, tx_win_low %u tx_win_high %u tx_highest_seq %u bufsize %u offset %u\n",
s, s->tx_win_low, s->tx_win_high, s->tx_highest_seq, s->tx_buffer_size, s->tx_buffer_offset);
if (SEQUENCE_LTE(sequence, s->tx_win_low)) {
/* they're acking stuff we've already received an ack for */
@@ -799,7 +799,7 @@ static void handle_ack(tcp_socket_t *s, uint32_t sequence, uint32_t win_size)
static ssize_t tcp_write_pending_data(tcp_socket_t *s)
{
LTRACEF("s %p, tx_win_low %u tx_win_high %u tx_highest_seq %u bufsize %zu offset %zu\n",
LTRACEF("s %p, tx_win_low %u tx_win_high %u tx_highest_seq %u bufsize %u offset %u\n",
s, s->tx_win_low, s->tx_win_high, s->tx_highest_seq, s->tx_buffer_size, s->tx_buffer_offset);
DEBUG_ASSERT(s);
@@ -1094,7 +1094,7 @@ ssize_t tcp_write(tcp_socket_t *socket, const void *buf, size_t len)
size_t off = 0;
while (off < len) {
LTRACEF("off %u, len %u\n", off, len);
LTRACEF("off %zu, len %zu\n", off, len);
/* wait for the tx buffer to open up */
event_wait(&s->tx_event);

View File

@@ -87,7 +87,7 @@ int udp_listen(uint16_t port, udp_callback_t cb, void *arg) {
status_t udp_open(uint32_t host, uint16_t sport, uint16_t dport, udp_socket_t **handle)
{
TRACEF("host %u.%u.%u.%u sport %u dport %u handle %p\n",
LTRACEF("host %u.%u.%u.%u sport %u dport %u handle %p\n",
IPV4_SPLIT(host), sport, dport, handle);
udp_socket_t *socket;
const uint8_t *dst_mac;
@@ -174,6 +174,8 @@ status_t udp_send(void *buf, size_t len, udp_socket_t *handle)
{
iovec_t iov;
LTRACEF("buf %p, len %zu, handle %p\n", buf, len, handle);
if (buf == NULL || len == 0) {
return -EINVAL;
}