Don Porges fixed c99 issues.
git-svn-id: svn://svn.berlios.de/openocd/trunk@553 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
@@ -142,10 +142,10 @@ command_t* register_command(command_context_t *context, command_t *parent, char
|
||||
|
||||
int unregister_command(command_context_t *context, char *name)
|
||||
{
|
||||
unique_length_dirty = 1;
|
||||
|
||||
command_t *c, *p = NULL, *c2;
|
||||
|
||||
unique_length_dirty = 1;
|
||||
|
||||
if ((!context) || (!name))
|
||||
return ERROR_INVALID_ARGUMENTS;
|
||||
|
||||
@@ -452,7 +452,11 @@ int command_run_file(command_context_t *context, FILE *file, enum command_mode m
|
||||
void command_print_help_line(command_context_t* context, struct command_s *command, int indent)
|
||||
{
|
||||
command_t *c;
|
||||
#ifdef HAVE_C_VARRAYS
|
||||
char indent_text[indent + 2];
|
||||
#else
|
||||
char indent_text[68];
|
||||
#endif
|
||||
char *help = "no help available";
|
||||
char name_buf[64];
|
||||
|
||||
@@ -578,12 +582,13 @@ int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
|
||||
|
||||
int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
|
||||
{
|
||||
if (argc<1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
duration_t duration;
|
||||
char *duration_text;
|
||||
int retval;
|
||||
float t;
|
||||
|
||||
if (argc<1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
duration_start_measure(&duration);
|
||||
|
||||
@@ -591,7 +596,7 @@ int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
|
||||
|
||||
duration_stop_measure(&duration, &duration_text);
|
||||
|
||||
float t=duration.duration.tv_sec;
|
||||
t=duration.duration.tv_sec;
|
||||
t+=((float)duration.duration.tv_usec / 1000000.0);
|
||||
command_print(cmd_ctx, "%s took %fs", args[0], t);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
int debug_level = -1;
|
||||
|
||||
@@ -61,6 +60,7 @@ static int count = 0;
|
||||
*/
|
||||
static void log_puts(enum log_levels level, const char *file, int line, const char *function, const char *string)
|
||||
{
|
||||
char *f;
|
||||
if (level == LOG_LVL_OUTPUT)
|
||||
{
|
||||
/* do not prepend any headers, just print out what we were given and return */
|
||||
@@ -69,7 +69,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
|
||||
return;
|
||||
}
|
||||
|
||||
char *f = strrchr(file, '/');
|
||||
f = strrchr(file, '/');
|
||||
if (f != NULL)
|
||||
file = f + 1;
|
||||
|
||||
@@ -112,12 +112,12 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
|
||||
void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
|
||||
{
|
||||
char *string;
|
||||
va_list ap;
|
||||
|
||||
count++;
|
||||
if (level > debug_level)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
string = alloc_vprintf(format, ap);
|
||||
@@ -133,12 +133,12 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f
|
||||
void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
|
||||
{
|
||||
char *string;
|
||||
va_list ap;
|
||||
|
||||
count++;
|
||||
if (level > debug_level)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
string = alloc_vprintf(format, ap);
|
||||
@@ -276,6 +276,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
|
||||
for (;;)
|
||||
{
|
||||
char *t = string;
|
||||
va_list ap_copy;
|
||||
int ret;
|
||||
string = realloc(string, size);
|
||||
if (string == NULL)
|
||||
{
|
||||
@@ -284,10 +286,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
va_list ap_copy;
|
||||
va_copy(ap_copy, ap);
|
||||
|
||||
int ret;
|
||||
ret = vsnprintf(string, size, fmt, ap_copy);
|
||||
/* NB! The result of the vsnprintf() might be an *EMPTY* string! */
|
||||
if ((ret >= 0) && ((ret + 1) < size))
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
/*
|
||||
* clear_malloc
|
||||
*
|
||||
|
||||
@@ -187,7 +187,7 @@ static __inline int close_socket(int sock)
|
||||
static __inline void socket_nonblock(int fd)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
long nonblock = 1;
|
||||
unsigned long nonblock = 1;
|
||||
ioctlsocket(fd, FIONBIO, &nonblock );
|
||||
#else
|
||||
int oldopts = fcntl(fd, F_GETFL, 0);
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "log.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
|
||||
int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
|
||||
|
||||
@@ -20,8 +20,16 @@
|
||||
#ifndef TIME_SUPPORT_H
|
||||
#define TIME_SUPPORT_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
|
||||
extern int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
|
||||
|
||||
Reference in New Issue
Block a user