Fix pointer sign warnings and remove -Wno-pointer-sign.

This commit is contained in:
Gareth McMullin 2015-03-13 20:35:39 -07:00
parent f52a51403f
commit f5c856af3b
10 changed files with 30 additions and 36 deletions

View File

@ -9,7 +9,7 @@ endif
BUILDDATE := `date +"%Y%m%d"` BUILDDATE := `date +"%Y%m%d"`
CFLAGS += -Wall -Wextra -Wno-pointer-sign -Wno-char-subscripts\ CFLAGS += -Wall -Wextra -Wno-char-subscripts\
-Wno-sign-compare \ -Wno-sign-compare \
-O2 -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\ -O2 -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\
-I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) \ -I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) \

View File

@ -853,7 +853,8 @@ static int cortexm_hostio_request(target *t)
uint32_t pflag = flags[params[1] >> 1]; uint32_t pflag = flags[params[1] >> 1];
char filename[4]; char filename[4];
target_mem_read_bytes(t, filename, params[0], sizeof(filename)); target_mem_read_bytes(t, (uint8_t *)filename,
params[0], sizeof(filename));
/* handle requests for console i/o */ /* handle requests for console i/o */
if (!strcmp(filename, ":tt")) { if (!strcmp(filename, ":tt")) {
if (pflag == FILEIO_O_RDONLY) if (pflag == FILEIO_O_RDONLY)

View File

@ -41,7 +41,7 @@
#define ERROR_IF_NO_TARGET() \ #define ERROR_IF_NO_TARGET() \
if(!cur_target) { gdb_putpacketz("EFF"); break; } if(!cur_target) { gdb_putpacketz("EFF"); break; }
static unsigned char pbuf[BUF_SIZE]; static char pbuf[BUF_SIZE];
static target *cur_target; static target *cur_target;
static target *last_target; static target *last_target;
@ -287,7 +287,7 @@ handle_q_string_reply(const char *str, const char *param)
return; return;
} }
if (addr < strlen (str)) { if (addr < strlen (str)) {
uint8_t reply[len+2]; char reply[len+2];
reply[0] = 'm'; reply[0] = 'm';
strncpy (reply + 1, &str[addr], len); strncpy (reply + 1, &str[addr], len);
if(len > strlen(&str[addr])) if(len > strlen(&str[addr]))
@ -305,7 +305,7 @@ handle_q_packet(char *packet, int len)
uint32_t addr, alen; uint32_t addr, alen;
if(!strncmp(packet, "qRcmd,", 6)) { if(!strncmp(packet, "qRcmd,", 6)) {
unsigned char *data; char *data;
int datalen; int datalen;
/* calculate size and allocate buffer for command */ /* calculate size and allocate buffer for command */

View File

@ -29,8 +29,7 @@
#include <stdarg.h> #include <stdarg.h>
int int gdb_getpacket(char *packet, int size)
gdb_getpacket(unsigned char *packet, int size)
{ {
unsigned char c; unsigned char c;
unsigned char csum; unsigned char csum;
@ -89,7 +88,7 @@ gdb_getpacket(unsigned char *packet, int size)
return i; return i;
} }
void gdb_putpacket(unsigned char *packet, int size) void gdb_putpacket(const char *packet, int size)
{ {
int i; int i;
unsigned char csum; unsigned char csum;
@ -130,7 +129,7 @@ void gdb_putpacket(unsigned char *packet, int size)
} while((gdb_if_getchar_to(2000) != '+') && (tries++ < 3)); } while((gdb_if_getchar_to(2000) != '+') && (tries++ < 3));
} }
void gdb_putpacket_f(const unsigned char *fmt, ...) void gdb_putpacket_f(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *buf; char *buf;

View File

@ -24,15 +24,16 @@
#include "general.h" #include "general.h"
#include "hex_utils.h" #include "hex_utils.h"
static char hexdigits[] = "0123456789abcdef"; static const char hexdigits[] = "0123456789abcdef";
char * hexify(char *hex, const unsigned char *buf, int size) char * hexify(char *hex, const void *buf, size_t size)
{ {
char *tmp = hex; char *tmp = hex;
const uint8_t *b = buf;
while (size--) { while (size--) {
*tmp++ = hexdigits[*buf >> 4]; *tmp++ = hexdigits[*b >> 4];
*tmp++ = hexdigits[*buf++ & 0xF]; *tmp++ = hexdigits[*b++ & 0xF];
} }
*tmp++ = 0; *tmp++ = 0;
@ -49,11 +50,12 @@ static uint8_t unhex_digit(char hex)
return tmp; return tmp;
} }
char * unhexify(unsigned char *buf, const char *hex, int size) char * unhexify(void *buf, const char *hex, size_t size)
{ {
uint8_t *b = buf;
while (size--) { while (size--) {
*buf = unhex_digit(*hex++) << 4; *b = unhex_digit(*hex++) << 4;
*buf++ |= unhex_digit(*hex++); *b++ |= unhex_digit(*hex++);
} }
return buf; return buf;
} }

View File

@ -21,10 +21,10 @@
#ifndef __GDB_PACKET_H #ifndef __GDB_PACKET_H
#define __GDB_PACKET_H #define __GDB_PACKET_H
int gdb_getpacket(unsigned char *packet, int size); int gdb_getpacket(char *packet, int size);
void gdb_putpacket(unsigned char *packet, int size); void gdb_putpacket(const char *packet, int size);
#define gdb_putpacketz(packet) gdb_putpacket((packet), strlen(packet)) #define gdb_putpacketz(packet) gdb_putpacket((packet), strlen(packet))
void gdb_putpacket_f(const unsigned char *packet, ...); void gdb_putpacket_f(const char *packet, ...);
void gdb_out(const char *buf); void gdb_out(const char *buf);
void gdb_outf(const char *fmt, ...); void gdb_outf(const char *fmt, ...);

View File

@ -21,9 +21,8 @@
#ifndef __HEX_UTILS_H #ifndef __HEX_UTILS_H
#define __HEX_UTILS_H #define __HEX_UTILS_H
char * hexify(char *hex, const unsigned char *buf, int size); char * hexify(char *hex, const void *buf, size_t size);
char * unhexify(void *buf, const char *hex, size_t size);
char * unhexify(unsigned char *buf, const char *hex, int size);
#endif #endif

View File

@ -74,7 +74,7 @@ static struct jtag_dev_descr_s {
}; };
/* bucket of ones for don't care TDI */ /* bucket of ones for don't care TDI */
static const char ones[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"; static const uint8_t ones[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
/* Scan JTAG chain for devices, store IR length and IDCODE (if present). /* Scan JTAG chain for devices, store IR length and IDCODE (if present).
* Reset TAP state machine. * Reset TAP state machine.

View File

@ -97,7 +97,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks)
void void
jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks) jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
{ {
char *tmp; uint8_t *tmp;
int index = 0; int index = 0;
int rticks; int rticks;

View File

@ -45,7 +45,7 @@ int swdptap_init(void)
abort(); abort();
} }
assert(ftdi_write_data(ftdic, "\xAB\xA8", 2) == 2); assert(ftdi_write_data(ftdic, (void*)"\xAB\xA8", 2) == 2);
/* This must be investigated in more detail. /* This must be investigated in more detail.
* As described in STM32 Reference Manual... */ * As described in STM32 Reference Manual... */
@ -70,7 +70,6 @@ static void swdptap_turnaround(uint8_t dir)
{ {
static uint8_t olddir = 0; static uint8_t olddir = 0;
/*DEBUG("%s", dir ? "\n-> ":"\n<- ");*/
platform_buffer_flush(); platform_buffer_flush();
if(dir == olddir) return; if(dir == olddir) return;
@ -80,7 +79,7 @@ static void swdptap_turnaround(uint8_t dir)
assert(ftdi_set_bitmode(ftdic, 0xA3, BITMODE_BITBANG) == 0); assert(ftdi_set_bitmode(ftdic, 0xA3, BITMODE_BITBANG) == 0);
/* One clock cycle */ /* One clock cycle */
ftdi_write_data(ftdic, "\xAB\xA8", 2); ftdi_write_data(ftdic, (void *)"\xAB\xA8", 2);
if(!dir) /* SWDIO goes to output */ if(!dir) /* SWDIO goes to output */
assert(ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG) == 0); assert(ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG) == 0);
@ -90,12 +89,9 @@ static uint8_t swdptap_bit_in(void)
{ {
uint8_t ret; uint8_t ret;
//ftdi_read_data(ftdic, &ret, 1);
ftdi_read_pins(ftdic, &ret); ftdi_read_pins(ftdic, &ret);
ret &= 0x08; ret &= 0x08;
ftdi_write_data(ftdic, "\xA1\xA0", 2); ftdi_write_data(ftdic, (void *)"\xA1\xA0", 2);
//DEBUG("%d", ret?1:0);
return ret; return ret;
} }
@ -104,13 +100,10 @@ static void swdptap_bit_out(uint8_t val)
{ {
uint8_t buf[3] = "\xA0\xA1\xA0"; uint8_t buf[3] = "\xA0\xA1\xA0";
//DEBUG("%d", val);
if(val) { if(val) {
for(int i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
buf[i] |= 0x08; buf[i] |= 0x08;
} }
//ftdi_write_data(ftdic, buf, 3);
platform_buffer_write(buf, 3); platform_buffer_write(buf, 3);
} }