From 0cba0d4df3fe120f08945703506f8405760325c9 Mon Sep 17 00:00:00 2001 From: ntfreak Date: Sat, 13 Dec 2008 12:44:39 +0000 Subject: - remove target specific variant and use target->variant member - fix build warning in cortex_m3 - code cleanup - remove trailing lf and convert c++ comments git-svn-id: svn://svn.berlios.de/openocd/trunk@1238 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/helper/bin2char.c | 2 +- src/helper/binarybuffer.c | 54 +++++++++++++++++++++++----------------------- src/helper/command.c | 18 +++++++--------- src/helper/configuration.c | 1 - src/helper/fileio.h | 3 +-- src/helper/log.c | 1 - src/helper/log.h | 2 +- src/helper/options.c | 1 - src/helper/replacements.c | 14 ++++++------ src/helper/replacements.h | 18 ++++++++-------- src/helper/tclapi.c | 1 - src/helper/types.h | 27 +++++++++++------------ 12 files changed, 66 insertions(+), 76 deletions(-) (limited to 'src/helper') diff --git a/src/helper/bin2char.c b/src/helper/bin2char.c index f1c809c8..36198c7f 100644 --- a/src/helper/bin2char.c +++ b/src/helper/bin2char.c @@ -30,7 +30,7 @@ int main(int argc, char **argv) if (argc == 1) { fprintf(stderr, "bin2char \n"); fprintf(stderr, "read from standard input and write a char" - " array out to standard output\n"); + " array out to standard output\n"); exit(1); } diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index f3ef11ce..4a43d1c0 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -210,7 +210,7 @@ char* buf_to_str(const u8 *buf, int buf_len, int radix) else if (radix == 10) { factor = 2.40824; /* log(256) / log(10) = 2.40824 */ - } + } else if (radix == 8) { factor = 2.66667; /* log(256) / log(8) = 2.66667 */ @@ -222,20 +222,20 @@ char* buf_to_str(const u8 *buf, int buf_len, int radix) str = calloc(str_len + 1, 1); for (i = b256_len - 1; i >= 0; i--) - { - tmp = buf[i]; - if ((i == (buf_len / 8)) && (buf_len % 8)) - tmp &= (0xff >> (8 - (buf_len % 8))); - - for (j = str_len; j > 0; j--) - { - tmp += (u32)str[j-1] * 256; - str[j-1] = (u8)(tmp % radix); - tmp /= radix; - } - } - - for (j = 0; j < str_len; j++) + { + tmp = buf[i]; + if ((i == (buf_len / 8)) && (buf_len % 8)) + tmp &= (0xff >> (8 - (buf_len % 8))); + + for (j = str_len; j > 0; j--) + { + tmp += (u32)str[j-1] * 256; + str[j-1] = (u8)(tmp % radix); + tmp /= radix; + } + } + + for (j = 0; j < str_len; j++) str[j] = DIGITS[(int)str[j]]; return str; @@ -295,23 +295,23 @@ int str_to_buf(const char *str, int str_len, u8 *buf, int buf_len, int radix) for (i = 0; charbuf[i]; i++) { tmp = charbuf[i]; - if ((tmp >= '0') && (tmp <= '9')) - tmp = (tmp - '0'); - else if ((tmp >= 'a') && (tmp <= 'f')) - tmp = (tmp - 'a' + 10); - else if ((tmp >= 'A') && (tmp <= 'F')) - tmp = (tmp - 'A' + 10); - else continue; /* skip characters other than [0-9,a-f,A-F] */ + if ((tmp >= '0') && (tmp <= '9')) + tmp = (tmp - '0'); + else if ((tmp >= 'a') && (tmp <= 'f')) + tmp = (tmp - 'a' + 10); + else if ((tmp >= 'A') && (tmp <= 'F')) + tmp = (tmp - 'A' + 10); + else continue; /* skip characters other than [0-9,a-f,A-F] */ if (tmp >= radix) continue; /* skip digits invalid for the current radix */ for (j = 0; j < b256_len; j++) - { - tmp += (u32)b256_buf[j] * radix; - b256_buf[j] = (u8)(tmp & 0xFF); - tmp >>= 8; - } + { + tmp += (u32)b256_buf[j] * radix; + b256_buf[j] = (u8)(tmp & 0xFF); + tmp >>= 8; + } } diff --git a/src/helper/command.c b/src/helper/command.c index cba05f16..23d00041 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -229,9 +229,9 @@ command_t* register_command(command_context_t *context, command_t *parent, char free((void *)override_name); /* accumulate help text in Tcl helptext list. */ - Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); - if (Jim_IsShared(helptext)) - helptext = Jim_DuplicateObj(interp, helptext); + Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); + if (Jim_IsShared(helptext)) + helptext = Jim_DuplicateObj(interp, helptext); Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0); Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0); @@ -356,8 +356,8 @@ void command_print_n(command_context_t *context, char *format, ...) * The latter bit isn't precisely neat, but will do for now. */ LOG_USER_N("%s", string); - // We already printed it above - //command_output_text(context, string); + /* We already printed it above */ + /* command_output_text(context, string); */ free(string); } @@ -381,8 +381,8 @@ void command_print(command_context_t *context, char *format, ...) * The latter bit isn't precisely neat, but will do for now. */ LOG_USER_N("%s", string); - // We already printed it above - //command_output_text(context, string); + /* We already printed it above */ + /* command_output_text(context, string); */ free(string); } @@ -644,7 +644,6 @@ static char* openocd_jim_fgets(char *s, int size, void *cookie) return NULL; } - static int jim_capture(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { if (argc != 2) @@ -801,7 +800,7 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd Jim_CreateCommand(interp, name, cmd, NULL, NULL); /* FIX!!! it would be prettier to invoke add_help_text... - accumulate help text in Tcl helptext list. */ + * accumulate help text in Tcl helptext list. */ Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG); if (Jim_IsShared(helptext)) helptext = Jim_DuplicateObj(interp, helptext); @@ -816,7 +815,6 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd Jim_ListAppendElement(interp, helptext, cmd_entry); } - /* return global variable long value or 0 upon failure */ long jim_global_long(const char *variable) { diff --git a/src/helper/configuration.c b/src/helper/configuration.c index be6f5662..e33a2e16 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -91,7 +91,6 @@ char *find_file(const char *file) return NULL; } - FILE *open_file_from_path (char *file, char *mode) { if (mode[0]!='r') diff --git a/src/helper/fileio.h b/src/helper/fileio.h index a81f98ea..1dfff51e 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -44,7 +44,6 @@ enum fileio_type FILEIO_BINARY, }; - enum fileio_access { FILEIO_READ, /* open for reading, position at beginning */ @@ -71,7 +70,7 @@ extern int fileio_close(fileio_t *fileio); extern int fileio_open(fileio_t *fileio, char *url, enum fileio_access access, enum fileio_type type); extern int fileio_read_u32(fileio_t *fileio, u32 *data); extern int fileio_write_u32(fileio_t *fileio, u32 data); - + #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200) #define ERROR_FILEIO_NOT_FOUND (-1201) #define ERROR_FILEIO_OPERATION_FAILED (-1202) diff --git a/src/helper/log.c b/src/helper/log.c index 7ea2a6cb..d21b8e9f 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -413,7 +413,6 @@ void alive_sleep(int ms) } } - void busy_sleep(int ms) { long long then; diff --git a/src/helper/log.h b/src/helper/log.h index aeb47dbb..a790018f 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -124,6 +124,6 @@ extern int debug_level; /* see "Error:" log entry for meaningful message to the user. The caller should * make no assumptions about what went wrong and try to handle the problem. */ -#define ERROR_FAIL (-4) +#define ERROR_FAIL (-4) #endif /* LOG_H */ diff --git a/src/helper/options.c b/src/helper/options.c index 04419569..cce77e5a 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -163,6 +163,5 @@ int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[] exit(-1); } - return ERROR_OK; } diff --git a/src/helper/replacements.c b/src/helper/replacements.c index ebeae17d..b6ddfd7c 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -82,19 +82,19 @@ void *fill_malloc(size_t size) int gettimeofday(struct timeval *tv, struct timezone *tz) { - FILETIME ft; - LARGE_INTEGER li; - __int64 t; - static int tzflag; + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + static int tzflag; if (tv) { GetSystemTimeAsFileTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; - t = li.QuadPart; /* In 100-nanosecond intervals */ - t -= EPOCHFILETIME; /* Offset to the Epoch time */ - t /= 10; /* In microseconds */ + t = li.QuadPart; /* In 100-nanosecond intervals */ + t -= EPOCHFILETIME; /* Offset to the Epoch time */ + t /= 10; /* In microseconds */ tv->tv_sec = (long)(t / 1000000); tv->tv_usec = (long)(t % 1000000); } diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 069519d1..a1500d79 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -87,7 +87,7 @@ struct timeval { #ifdef _WIN32 struct timezone { - int tz_minuteswest; + int tz_minuteswest; int tz_dsttime; }; #endif @@ -181,27 +181,27 @@ static __inline void outb(unsigned char value, unsigned short int port) static __inline int write_socket( int handle, const void *buffer, unsigned int count ) { #ifdef _WIN32 - return send(handle, buffer, count, 0); + return send(handle, buffer, count, 0); #else - return write(handle, buffer, count); + return write(handle, buffer, count); #endif } static __inline int read_socket( int handle, void *buffer, unsigned int count ) { #ifdef _WIN32 - return recv(handle, buffer, count, 0); + return recv(handle, buffer, count, 0); #else - return read(handle, buffer, count); + return read(handle, buffer, count); #endif } static __inline int close_socket(int sock) { #ifdef _WIN32 - return closesocket(sock); + return closesocket(sock); #else - return close(sock); + return close(sock); #endif } @@ -229,9 +229,9 @@ typedef struct u32 e_shoff; /* Section header table file offset */ u32 e_flags; /* Processor-specific flags */ u16 e_ehsize; /* ELF header size in bytes */ - u16 e_phentsize; /* Program header table entry size */ + u16 e_phentsize; /* Program header table entry size */ u16 e_phnum; /* Program header table entry count */ - u16 e_shentsize; /* Section header table entry size */ + u16 e_shentsize; /* Section header table entry size */ u16 e_shnum; /* Section header table entry count */ u16 e_shstrndx; /* Section header string table index */ } Elf32_Ehdr; diff --git a/src/helper/tclapi.c b/src/helper/tclapi.c index e07388ff..2857cb49 100644 --- a/src/helper/tclapi.c +++ b/src/helper/tclapi.c @@ -525,7 +525,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } - int tclapi_register_commands() { register_jim("ocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing"); diff --git a/src/helper/types.h b/src/helper/types.h index d87c10a2..641190d8 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -43,10 +43,8 @@ typedef unsigned int u32; typedef unsigned long long u64; #endif - typedef struct jtag_tap_s jtag_tap_t; - /* DANGER!!!! here be dragons! Note that the pointer in * memory might be unaligned. On some CPU's, i.e. ARM7, * the 2 lsb are ignored for 32 bit access, on others @@ -59,26 +57,25 @@ typedef struct jtag_tap_s jtag_tap_t; #define be_to_h_u16(x) ((u16)((x)[1] | (x)[0] << 8)) #define h_u32_to_le(buf, val) do {\ -(buf)[3] = ((val) & 0xff000000) >> 24;\ -(buf)[2] = ((val) & 0x00ff0000) >> 16;\ -(buf)[1] = ((val) & 0x0000ff00) >> 8;\ -(buf)[0] = ((val) & 0x000000ff);\ + (buf)[3] = ((val) & 0xff000000) >> 24;\ + (buf)[2] = ((val) & 0x00ff0000) >> 16;\ + (buf)[1] = ((val) & 0x0000ff00) >> 8;\ + (buf)[0] = ((val) & 0x000000ff);\ } while (0) #define h_u32_to_be(buf, val) do {\ -(buf)[0] = ((val) & 0xff000000) >> 24;\ -(buf)[1] = ((val) & 0x00ff0000) >> 16;\ -(buf)[2] = ((val) & 0x0000ff00) >> 8;\ -(buf)[3] = ((val) & 0x000000ff);\ + (buf)[0] = ((val) & 0xff000000) >> 24;\ + (buf)[1] = ((val) & 0x00ff0000) >> 16;\ + (buf)[2] = ((val) & 0x0000ff00) >> 8;\ + (buf)[3] = ((val) & 0x000000ff);\ } while (0) #define h_u16_to_le(buf, val) do {\ -(buf)[1] = ((val) & 0xff00) >> 8;\ -(buf)[0] = ((val) & 0x00ff) >> 0;\ + (buf)[1] = ((val) & 0xff00) >> 8;\ + (buf)[0] = ((val) & 0x00ff) >> 0;\ } while (0) #define h_u16_to_be(buf, val) do {\ -(buf)[0] = ((val) & 0xff00) >> 8;\ -(buf)[1] = ((val) & 0x00ff) >> 0;\ + (buf)[0] = ((val) & 0xff00) >> 8;\ + (buf)[1] = ((val) & 0x00ff) >> 0;\ } while (0) - #endif /* TYPES_H */ -- cgit v1.2.3