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"`
CFLAGS += -Wall -Wextra -Wno-pointer-sign -Wno-char-subscripts\
CFLAGS += -Wall -Wextra -Wno-char-subscripts\
-Wno-sign-compare \
-O2 -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\
-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];
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 */
if (!strcmp(filename, ":tt")) {
if (pflag == FILEIO_O_RDONLY)

View File

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

View File

@ -29,8 +29,7 @@
#include <stdarg.h>
int
gdb_getpacket(unsigned char *packet, int size)
int gdb_getpacket(char *packet, int size)
{
unsigned char c;
unsigned char csum;
@ -89,7 +88,7 @@ gdb_getpacket(unsigned char *packet, int size)
return i;
}
void gdb_putpacket(unsigned char *packet, int size)
void gdb_putpacket(const char *packet, int size)
{
int i;
unsigned char csum;
@ -130,7 +129,7 @@ void gdb_putpacket(unsigned char *packet, int size)
} 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;
char *buf;

View File

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

View File

@ -21,10 +21,10 @@
#ifndef __GDB_PACKET_H
#define __GDB_PACKET_H
int gdb_getpacket(unsigned char *packet, int size);
void gdb_putpacket(unsigned char *packet, int size);
int gdb_getpacket(char *packet, int size);
void gdb_putpacket(const char *packet, int size);
#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_outf(const char *fmt, ...);

View File

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

View File

@ -74,7 +74,7 @@ static struct jtag_dev_descr_s {
};
/* 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).
* Reset TAP state machine.

View File

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

View File

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