Merge pull request #776 from geertu/compiler-warning-fixes

Compiler warning fixes
This commit is contained in:
enjoy-digital 2021-01-22 09:28:23 +01:00 committed by GitHub
commit f22079dc94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 66 additions and 55 deletions

View file

@ -50,7 +50,7 @@ extern void boot_helper(unsigned long r1, unsigned long r2, unsigned long r3, un
static void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr) static void __attribute__((noreturn)) boot(unsigned long r1, unsigned long r2, unsigned long r3, unsigned long addr)
{ {
printf("Executing booted program at 0x%08x\n\n", addr); printf("Executing booted program at 0x%08lx\n\n", addr);
printf("--============= \e[1mLiftoff!\e[0m ===============--\n"); printf("--============= \e[1mLiftoff!\e[0m ===============--\n");
uart_sync(); uart_sync();
#ifdef CONFIG_CPU_HAS_INTERRUPT #ifdef CONFIG_CPU_HAS_INTERRUPT
@ -216,7 +216,7 @@ int serialboot(void)
char *writepointer; char *writepointer;
failed = 0; failed = 0;
writepointer = (char *) get_uint32(&frame.payload[0]); writepointer = (char *)(uintptr_t) get_uint32(&frame.payload[0]);
for(i=4;i<frame.payload_length;i++) for(i=4;i<frame.payload_length;i++)
*(writepointer++) = frame.payload[i]; *(writepointer++) = frame.payload[i];
if (frame.cmd == SFL_CMD_LOAD) if (frame.cmd == SFL_CMD_LOAD)
@ -277,7 +277,7 @@ static int copy_file_from_tftp_to_ram(unsigned int ip, unsigned short server_por
const char *filename, char *buffer) const char *filename, char *buffer)
{ {
int size; int size;
printf("Copying %s to 0x%08x... ", filename, buffer); printf("Copying %s to %p... ", filename, buffer);
size = tftp_get(ip, server_port, filename, buffer); size = tftp_get(ip, server_port, filename, buffer);
if(size > 0) if(size > 0)
printf("(%d bytes)", size); printf("(%d bytes)", size);
@ -432,7 +432,7 @@ static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned lon
length = check_image_in_flash(flash_address); length = check_image_in_flash(flash_address);
if(length > 0) { if(length > 0) {
printf("Copying 0x%08x to 0x%08x (%d bytes)...\n", flash_address, ram_address, length); printf("Copying 0x%08x to 0x%08lx (%d bytes)...\n", flash_address, ram_address, length);
offset = 0; offset = 0;
init_progression_bar(length); init_progression_bar(length);
while (length > 0) { while (length > 0) {
@ -504,7 +504,7 @@ static int copy_file_from_sdcard_to_ram(const char * filename, unsigned long ram
} }
length = f_size(&file); length = f_size(&file);
printf("Copying %s to 0x%08x (%d bytes)...\n", filename, ram_address, length); printf("Copying %s to 0x%08lx (%d bytes)...\n", filename, ram_address, length);
init_progression_bar(length); init_progression_bar(length);
offset = 0; offset = 0;
for (;;) { for (;;) {
@ -679,7 +679,7 @@ static int copy_file_from_sata_to_ram(const char * filename, unsigned long ram_a
} }
length = f_size(&file); length = f_size(&file);
printf("Copying %s to 0x%08x (%d bytes)...\n", filename, ram_address, length); printf("Copying %s to 0x%08lx (%d bytes)...\n", filename, ram_address, length);
init_progression_bar(length); init_progression_bar(length);
offset = 0; offset = 0;
for (;;) { for (;;) {

View file

@ -87,8 +87,8 @@ define_command(uptime, uptime_handler, "Uptime of the system since power-up", SY
static void crc_handler(int nb_params, char **params) static void crc_handler(int nb_params, char **params)
{ {
char *c; char *c;
unsigned int addr; uintptr_t addr;
unsigned int length; size_t length;
if (nb_params < 2) { if (nb_params < 2) {
printf("crc <address> <length>"); printf("crc <address> <length>");

View file

@ -40,7 +40,7 @@ static void i2c_write_handler(int nb_params, char **params)
} }
if (nb_params - 1 > sizeof(write_params)) { if (nb_params - 1 > sizeof(write_params)) {
printf("Max data length is %d", sizeof(write_params)); printf("Max data length is %zu", sizeof(write_params));
return; return;
} }
@ -98,7 +98,7 @@ static void i2c_read_handler(int nb_params, char **params)
return; return;
} }
if (len > sizeof(buf)) { if (len > sizeof(buf)) {
printf("Max data count is %d", sizeof(buf)); printf("Max data count is %zu", sizeof(buf));
return; return;
} }

View file

@ -25,7 +25,7 @@ void dump_bytes(unsigned int *ptr, int count, unsigned long addr)
(count > NUMBER_OF_BYTES_ON_A_LINE)? (count > NUMBER_OF_BYTES_ON_A_LINE)?
NUMBER_OF_BYTES_ON_A_LINE : count; NUMBER_OF_BYTES_ON_A_LINE : count;
printf("\n0x%08x ", addr); printf("\n0x%08lx ", addr);
for (i = 0; i < line_bytes; i++) for (i = 0; i < line_bytes; i++)
printf("%02x ", *(unsigned char *)(data+i)); printf("%02x ", *(unsigned char *)(data+i));

View file

@ -150,10 +150,10 @@ void hist_init(void)
} }
#endif #endif
static void cread_add_char(char ichar, int insert, unsigned long *num, static void cread_add_char(char ichar, int insert, unsigned int *num,
unsigned long *eol_num, char *buf, unsigned long len) unsigned int *eol_num, char *buf, unsigned int len)
{ {
unsigned long wlen; unsigned int wlen;
if (insert || *num == *eol_num) { if (insert || *num == *eol_num) {
if (*eol_num > len - 1) { if (*eol_num > len - 1) {
@ -186,9 +186,9 @@ static void cread_add_char(char ichar, int insert, unsigned long *num,
int readline(char *buf, int len) int readline(char *buf, int len)
{ {
unsigned long num = 0; unsigned int num = 0;
unsigned long eol_num = 0; unsigned int eol_num = 0;
unsigned long wlen; unsigned int wlen;
int insert = 1; int insert = 1;
char ichar; char ichar;
@ -254,7 +254,7 @@ int readline(char *buf, int len)
wlen = eol_num - num - 1; wlen = eol_num - num - 1;
if (wlen) { if (wlen) {
memmove(&buf[num], &buf[num+1], wlen); memmove(&buf[num], &buf[num+1], wlen);
putnstr(buf + num, (int)wlen); putnstr(buf + num, wlen);
} }
getcmd_putch(' '); getcmd_putch(' ');
@ -286,7 +286,7 @@ int readline(char *buf, int len)
num--; num--;
memmove(buf + num, buf + num + 1, wlen); memmove(buf + num, buf + num + 1, wlen);
getcmd_putch(CTL_BACKSPACE); getcmd_putch(CTL_BACKSPACE);
putnstr(buf + num, (int)wlen); putnstr(buf + num, wlen);
getcmd_putch(' '); getcmd_putch(' ');
do { do {
getcmd_putch(CTL_BACKSPACE); getcmd_putch(CTL_BACKSPACE);
@ -298,7 +298,7 @@ int readline(char *buf, int len)
if (num < eol_num) { if (num < eol_num) {
wlen = eol_num - num; wlen = eol_num - num;
memmove(buf + num, buf + num + 1, wlen); memmove(buf + num, buf + num + 1, wlen);
putnstr(buf + num, (int)(wlen - 1)); putnstr(buf + num, wlen - 1);
getcmd_putch(' '); getcmd_putch(' ');
do { do {
getcmd_putch(CTL_BACKSPACE); getcmd_putch(CTL_BACKSPACE);

View file

@ -72,7 +72,7 @@ struct esc_cmds {
#define REFRESH_TO_EOL() { \ #define REFRESH_TO_EOL() { \
if (num < eol_num) { \ if (num < eol_num) { \
wlen = eol_num - num; \ wlen = eol_num - num; \
putnstr(buf + num, (int)wlen); \ putnstr(buf + num, wlen); \
num = eol_num; \ num = eol_num; \
} \ } \
} }

View file

@ -24,7 +24,7 @@
#include <stdint.h> #include <stdint.h>
# if __WORDSIZE == 64 # ifdef __LP64__
# define __PRI64_PREFIX "l" # define __PRI64_PREFIX "l"
# define __PRIPTR_PREFIX "l" # define __PRIPTR_PREFIX "l"
# else # else

View file

@ -65,7 +65,7 @@ static inline unsigned long lfsr(unsigned long bits, unsigned long prev)
0x20000029, 0x20000029,
0x48000000, 0x48000000,
0x80200003, 0x80200003,
#if __WORDSIZE == 64 #ifdef __LP64__
0x100080000, 0x100080000,
0x204000003, 0x204000003,
0x500000000, 0x500000000,

View file

@ -5,17 +5,21 @@
extern "C" { extern "C" {
#endif #endif
#define ULONG_MAX 0xffffffff #ifdef __LP64__
#define ULONG_MAX 18446744073709551615UL
#else
#define ULONG_MAX 4294967295UL
#endif
#define UINT_MAX 0xffffffff #define UINT_MAX 4294967295U
#define INT_MIN 0x80000000 #define INT_MIN (-INT_MAX - 1)
#define INT_MAX 0x7fffffff #define INT_MAX 2147483647
#define USHRT_MAX 0xffff #define USHRT_MAX 65535
#define SHRT_MIN 0x8000 #define SHRT_MIN (-32768)
#define SHRT_MAX 0x7fff #define SHRT_MAX 32767
#define UCHAR_MAX 0xff #define UCHAR_MAX 255
#define CHAR_BIT 8 #define CHAR_BIT 8

View file

@ -11,8 +11,13 @@ extern "C" {
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#ifdef __LP64__
typedef unsigned long size_t; typedef unsigned long size_t;
typedef long ptrdiff_t; typedef long ptrdiff_t;
#else
typedef unsigned int size_t;
typedef int ptrdiff_t;
#endif
#define offsetof(type, member) __builtin_offsetof(type, member) #define offsetof(type, member) __builtin_offsetof(type, member)

View file

@ -5,8 +5,13 @@
extern "C" { extern "C" {
#endif #endif
#ifdef __LP64__
typedef long intptr_t;
typedef unsigned long uintptr_t;
#else
typedef int intptr_t; typedef int intptr_t;
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
#endif
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;

View file

@ -10,11 +10,11 @@ extern "C" {
int putchar(int c); int putchar(int c);
int puts(const char *s); int puts(const char *s);
int snprintf(char *buf, size_t size, const char *fmt, ...); int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
int scnprintf(char *buf, size_t size, const char *fmt, ...); int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
int sprintf(char *buf, const char *fmt, ...); int sprintf(char *buf, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
int printf(const char *fmt, ...); int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
/* Not sure this belongs here... */ /* Not sure this belongs here... */
typedef long long loff_t; typedef long long loff_t;
@ -53,7 +53,7 @@ extern FILE *stdin;
extern FILE *stdout; extern FILE *stdout;
extern FILE *stderr; extern FILE *stderr;
int fprintf(FILE *stream, const char *format, ...); int fprintf(FILE *stream, const char *format, ...) __attribute__((format(printf, 2, 3)));
int fflush(FILE *stream); int fflush(FILE *stream);
FILE *fopen(const char *path, const char *mode); FILE *fopen(const char *path, const char *mode);

View file

@ -76,9 +76,9 @@ static void gdb_stub(unsigned long pc, unsigned long sr,
case 'g': { case 'g': {
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x" "%08x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
"%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x" "%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx"
"%08x%08x%08x", "%08lx%08lx%08lx",
0, r1, regs[2], regs[3], regs[4], regs[5], regs[6], regs[7], 0, r1, regs[2], regs[3], regs[4], regs[5], regs[6], regs[7],
regs[8], regs[9], regs[10], regs[11], regs[12], regs[13], regs[14], regs[15], regs[8], regs[9], regs[10], regs[11], regs[12], regs[13], regs[14], regs[15],
regs[16], regs[17], regs[18], regs[19], regs[20], regs[21], regs[22], regs[23], regs[16], regs[17], regs[18], regs[19], regs[20], regs[21], regs[22], regs[23],
@ -120,7 +120,7 @@ static void gdb_stub(unsigned long pc, unsigned long sr,
snprintf(buf, sizeof(buf), "E01"); snprintf(buf, sizeof(buf), "E01");
break; break;
} }
snprintf(buf, sizeof(buf), "%08x", value); snprintf(buf, sizeof(buf), "%08lx", value);
break; break;
} }
@ -156,7 +156,6 @@ static void gdb_stub(unsigned long pc, unsigned long sr,
} }
default: default:
snprintf(buf, sizeof(buf), "");
break; break;
} }

View file

@ -53,7 +53,7 @@ int memtest_access(unsigned int *addr)
array[0] = ZEROONE; array[0] = ZEROONE;
array[1] = array[0]; array[1] = array[0];
if (ctrl_bus_errors_read() - bus_errors) { if (ctrl_bus_errors_read() - bus_errors) {
printf("memtest_access error @ 0x%0x, exiting memtest.\n", addr); printf("memtest_access error @ %p, exiting memtest.\n", addr);
return 1; return 1;
} }
@ -83,7 +83,7 @@ int memtest_bus(unsigned int *addr, unsigned long size)
if(rdata != ONEZERO) { if(rdata != ONEZERO) {
errors++; errors++;
#ifdef MEMTEST_BUS_DEBUG #ifdef MEMTEST_BUS_DEBUG
printf("memtest_bus error @ 0x%0x: 0x%08x vs 0x%08x\n", addr + i, rdata, ONEZERO); printf("memtest_bus error @ %p: 0x%08x vs 0x%08x\n", addr + i, rdata, ONEZERO);
#endif #endif
} }
} }
@ -103,7 +103,7 @@ int memtest_bus(unsigned int *addr, unsigned long size)
if(rdata != ZEROONE) { if(rdata != ZEROONE) {
errors++; errors++;
#ifdef MEMTEST_BUS_DEBUG #ifdef MEMTEST_BUS_DEBUG
printf("memtest_bus error @ 0x%0x:: 0x%08x vs 0x%08x\n", addr + i, rdata, ZEROONE); printf("memtest_bus error @ %p:: 0x%08x vs 0x%08x\n", addr + i, rdata, ZEROONE);
#endif #endif
} }
} }
@ -139,7 +139,7 @@ int memtest_addr(unsigned int *addr, unsigned long size, int random)
if(rdata != i) { if(rdata != i) {
errors++; errors++;
#ifdef MEMTEST_ADDR_DEBUG #ifdef MEMTEST_ADDR_DEBUG
printf("memtest_addr error @ 0x%0x: 0x%08x vs 0x%08x\n", addr + i, rdata, i); printf("memtest_addr error @ %p: 0x%08x vs 0x%08x\n", addr + i, rdata, i);
#endif #endif
} }
} }
@ -202,7 +202,7 @@ int memtest_data(unsigned int *addr, unsigned long size, int random)
if(rdata != seed_32) { if(rdata != seed_32) {
errors++; errors++;
#ifdef MEMTEST_DATA_DEBUG #ifdef MEMTEST_DATA_DEBUG
printf("memtest_data error @%0x: 0x%08x vs 0x%08x\n", addr + i, rdata, seed_32); printf("memtest_data error @%p: 0x%08x vs 0x%08x\n", addr + i, rdata, seed_32);
#endif #endif
} }
if (i%0x8000 == 0) if (i%0x8000 == 0)

View file

@ -61,6 +61,4 @@ void init_progression_bar(int max)
spin = 0; spin = 0;
if (progress_max && progress_max != FILESIZE_MAX) if (progress_max && progress_max != FILESIZE_MAX)
printf("[%*s]\r[", HASHES_PER_LINE, ""); printf("[%*s]\r[", HASHES_PER_LINE, "");
else
printf("");
} }

View file

@ -186,7 +186,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case 'p': case 'p':
if (field_width == -1) { if (field_width == -1) {
field_width = 2*sizeof(void *); field_width = 2*sizeof(void *);
flags |= PRINTF_ZEROPAD; flags |= PRINTF_ZEROPAD | PRINTF_SPECIAL;
} }
str = number(str, end, str = number(str, end,
(unsigned long) va_arg(args, void *), (unsigned long) va_arg(args, void *),

View file

@ -130,7 +130,7 @@ void sdram_bist_loop(uint32_t loop, uint32_t burst_length, uint32_t random) {
static uint32_t compute_speed_mibs(uint32_t length, uint32_t ticks) { static uint32_t compute_speed_mibs(uint32_t length, uint32_t ticks) {
uint32_t speed; uint32_t speed;
//printf("(%lu, %lu)", length, ticks); //printf("(%u, %u)", length, ticks);
speed = length*(CONFIG_CLOCK_FREQUENCY/(1024*1024))/ticks; speed = length*(CONFIG_CLOCK_FREQUENCY/(1024*1024))/ticks;
return speed; return speed;
} }

View file

@ -1013,7 +1013,7 @@ int sdram_init(void)
_sdram_write_leveling_cmd_scan = 0; _sdram_write_leveling_cmd_scan = 0;
_sdram_write_leveling_cmd_delay = SDRAM_PHY_CMD_DELAY; _sdram_write_leveling_cmd_delay = SDRAM_PHY_CMD_DELAY;
#endif #endif
printf("Initializing SDRAM @0x%08x...\n", MAIN_RAM_BASE); printf("Initializing SDRAM @0x%08lx...\n", MAIN_RAM_BASE);
sdram_software_control_on(); sdram_software_control_on();
#if CSR_DDRPHY_RST_ADDR #if CSR_DDRPHY_RST_ADDR
ddrphy_rst_write(1); ddrphy_rst_write(1);

View file

@ -51,7 +51,7 @@ void sata_read(uint32_t sector, uint32_t count, uint8_t* buf)
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
uint8_t done = 0; uint8_t done = 0;
while (done == 0) { while (done == 0) {
sata_sector2mem_base_write((uint64_t) buf); sata_sector2mem_base_write((uint64_t)(uintptr_t) buf);
sata_sector2mem_sector_write(sector + i); sata_sector2mem_sector_write(sector + i);
sata_sector2mem_start_write(1); sata_sector2mem_start_write(1);
while ((sata_sector2mem_done_read() & 0x1) == 0); while ((sata_sector2mem_done_read() & 0x1) == 0);
@ -80,7 +80,7 @@ void sata_write(uint32_t sector, uint32_t count, uint8_t* buf)
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
uint8_t done = 0; uint8_t done = 0;
while (done == 0) { while (done == 0) {
sata_mem2sector_base_write((uint64_t) buf); sata_mem2sector_base_write((uint64_t)(uintptr_t) buf);
sata_mem2sector_sector_write(sector + i); sata_mem2sector_sector_write(sector + i);
sata_mem2sector_start_write(1); sata_mem2sector_start_write(1);
while ((sata_sector2mem_done_read() & 0x1) == 0); while ((sata_sector2mem_done_read() & 0x1) == 0);

View file

@ -473,7 +473,7 @@ void sdcard_read(uint32_t block, uint32_t count, uint8_t* buf)
{ {
/* Initialize DMA Writer */ /* Initialize DMA Writer */
sdblock2mem_dma_enable_write(0); sdblock2mem_dma_enable_write(0);
sdblock2mem_dma_base_write((uint64_t) buf); sdblock2mem_dma_base_write((uint64_t)(uintptr_t) buf);
sdblock2mem_dma_length_write(512*count); sdblock2mem_dma_length_write(512*count);
sdblock2mem_dma_enable_write(1); sdblock2mem_dma_enable_write(1);
@ -504,7 +504,7 @@ void sdcard_write(uint32_t block, uint32_t count, uint8_t* buf)
while (count--) { while (count--) {
/* Initialize DMA Reader */ /* Initialize DMA Reader */
sdmem2block_dma_enable_write(0); sdmem2block_dma_enable_write(0);
sdmem2block_dma_base_write((uint64_t) buf); sdmem2block_dma_base_write((uint64_t)(uintptr_t) buf);
sdmem2block_dma_length_write(512); sdmem2block_dma_length_write(512);
sdmem2block_dma_enable_write(1); sdmem2block_dma_enable_write(1);