aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGareth McMullin2015-03-13 20:35:39 -0700
committerGareth McMullin2015-03-13 20:35:39 -0700
commitf5c856af3b3b0155050e793f50c29965d2c8326d (patch)
treeaa3e96821c585cb8214bc5cd345a66edc1378596 /src
parentf52a51403f4b9e5d0264cc355bf2414634bb5500 (diff)
Fix pointer sign warnings and remove -Wno-pointer-sign.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rw-r--r--src/cortexm.c3
-rw-r--r--src/gdb_main.c6
-rw-r--r--src/gdb_packet.c7
-rw-r--r--src/hex_utils.c20
-rw-r--r--src/include/gdb_packet.h6
-rw-r--r--src/include/hex_utils.h5
-rw-r--r--src/jtag_scan.c2
-rw-r--r--src/platforms/libftdi/jtagtap.c2
-rw-r--r--src/platforms/libftdi/swdptap.c13
10 files changed, 30 insertions, 36 deletions
diff --git a/src/Makefile b/src/Makefile
index 7a1f141..7ea7865 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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) \
diff --git a/src/cortexm.c b/src/cortexm.c
index 71d0c6c..b3b657f 100644
--- a/src/cortexm.c
+++ b/src/cortexm.c
@@ -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)
diff --git a/src/gdb_main.c b/src/gdb_main.c
index 0c3dd77..ab4fc8a 100644
--- a/src/gdb_main.c
+++ b/src/gdb_main.c
@@ -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 */
diff --git a/src/gdb_packet.c b/src/gdb_packet.c
index 4dc934f..fb3335e 100644
--- a/src/gdb_packet.c
+++ b/src/gdb_packet.c
@@ -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;
diff --git a/src/hex_utils.c b/src/hex_utils.c
index 45382ff..e18df58 100644
--- a/src/hex_utils.c
+++ b/src/hex_utils.c
@@ -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;
}
diff --git a/src/include/gdb_packet.h b/src/include/gdb_packet.h
index 222b86d..aa1a654 100644
--- a/src/include/gdb_packet.h
+++ b/src/include/gdb_packet.h
@@ -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, ...);
diff --git a/src/include/hex_utils.h b/src/include/hex_utils.h
index 3aa210b..8a0d092 100644
--- a/src/include/hex_utils.h
+++ b/src/include/hex_utils.h
@@ -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
diff --git a/src/jtag_scan.c b/src/jtag_scan.c
index 208a1db..c4e80cf 100644
--- a/src/jtag_scan.c
+++ b/src/jtag_scan.c
@@ -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.
diff --git a/src/platforms/libftdi/jtagtap.c b/src/platforms/libftdi/jtagtap.c
index c9bc876..c416892 100644
--- a/src/platforms/libftdi/jtagtap.c
+++ b/src/platforms/libftdi/jtagtap.c
@@ -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;
diff --git a/src/platforms/libftdi/swdptap.c b/src/platforms/libftdi/swdptap.c
index eb6e65e..6aafa7d 100644
--- a/src/platforms/libftdi/swdptap.c
+++ b/src/platforms/libftdi/swdptap.c
@@ -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);
}