Minor code cleanup.

master
Wolfgang Denk 19 years ago committed by Wolfgang Denk
parent e11887a77d
commit 19973b6ad9
  1. 32
      common/main.c

@ -95,14 +95,12 @@ static __inline__ int abortboot(int bootdelay)
{ {
int abort = 0; int abort = 0;
uint64_t etime = endtick(bootdelay); uint64_t etime = endtick(bootdelay);
struct struct {
{
char* str; char* str;
u_int len; u_int len;
int retry; int retry;
} }
delaykey [] = delaykey [] = {
{
{ str: getenv ("bootdelaykey"), retry: 1 }, { str: getenv ("bootdelaykey"), retry: 1 },
{ str: getenv ("bootdelaykey2"), retry: 1 }, { str: getenv ("bootdelaykey2"), retry: 1 },
{ str: getenv ("bootstopkey"), retry: 0 }, { str: getenv ("bootstopkey"), retry: 0 },
@ -498,7 +496,7 @@ void main_loop (void)
#ifdef CONFIG_BOOT_RETRY_TIME #ifdef CONFIG_BOOT_RETRY_TIME
/*************************************************************************** /***************************************************************************
* initialise command line timeout * initialize command line timeout
*/ */
void init_cmd_timeout(void) void init_cmd_timeout(void)
{ {
@ -529,23 +527,9 @@ void reset_cmd_timeout(void)
* Author: Janghoon Lyu <nandy@mizi.com> * Author: Janghoon Lyu <nandy@mizi.com>
*/ */
#if 1 /* avoid redundand code -- wd */
#define putnstr(str,n) do { \ #define putnstr(str,n) do { \
printf ("%.*s", n, str); \ printf ("%.*s", n, str); \
} while (0) } while (0)
#else
void putnstr(const char *str, size_t n)
{
if (str == NULL)
return;
while (n && *str != '\0') {
putc(*str);
str++;
n--;
}
}
#endif
#define CTL_CH(c) ((c) - 'a' + 1) #define CTL_CH(c) ((c) - 'a' + 1)
@ -1141,13 +1125,15 @@ static void process_macros (const char *input, char *output)
int inputcnt = strlen (input); int inputcnt = strlen (input);
int outputcnt = CFG_CBSIZE; int outputcnt = CFG_CBSIZE;
int state = 0; /* 0 = waiting for '$' */ int state = 0; /* 0 = waiting for '$' */
/* 1 = waiting for '(' or '{' */ /* 1 = waiting for '(' or '{' */
/* 2 = waiting for ')' or '}' */ /* 2 = waiting for ')' or '}' */
/* 3 = waiting for ''' */ /* 3 = waiting for ''' */
#ifdef DEBUG_PARSER #ifdef DEBUG_PARSER
char *output_start = output; char *output_start = output;
printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen(input), input); printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input),
input);
#endif #endif
prev = '\0'; /* previous character */ prev = '\0'; /* previous character */
@ -1156,7 +1142,7 @@ static void process_macros (const char *input, char *output)
c = *input++; c = *input++;
inputcnt--; inputcnt--;
if (state!=3) { if (state != 3) {
/* remove one level of escape characters */ /* remove one level of escape characters */
if ((c == '\\') && (prev != '\\')) { if ((c == '\\') && (prev != '\\')) {
if (inputcnt-- == 0) if (inputcnt-- == 0)
@ -1198,7 +1184,7 @@ static void process_macros (const char *input, char *output)
if (c == ')' || c == '}') { if (c == ')' || c == '}') {
int i; int i;
char envname[CFG_CBSIZE], *envval; char envname[CFG_CBSIZE], *envval;
int envcnt = input-varname_start-1; /* Varname # of chars */ int envcnt = input - varname_start - 1; /* Varname # of chars */
/* Get the varname */ /* Get the varname */
for (i = 0; i < envcnt; i++) { for (i = 0; i < envcnt; i++) {
@ -1236,7 +1222,7 @@ static void process_macros (const char *input, char *output)
#ifdef DEBUG_PARSER #ifdef DEBUG_PARSER
printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n", printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n",
strlen(output_start), output_start); strlen (output_start), output_start);
#endif #endif
} }

Loading…
Cancel
Save