aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/aic7xxx
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-06-01 18:42:16 +0000
committerXin LI <delphij@FreeBSD.org>2009-06-01 18:42:16 +0000
commitb18a2ef17fb5413906dc481c4b5d33e7d724a650 (patch)
treed60089441179c8a93d60d8318a1c79a5fcc57161 /sys/dev/aic7xxx
parentd363c617669ad4f89643211a9f47557c6ffbf1fb (diff)
downloadsrc-b18a2ef17fb5413906dc481c4b5d33e7d724a650.tar.gz
src-b18a2ef17fb5413906dc481c4b5d33e7d724a650.zip
Code cleanups to make this WARNS=6 clean.
PR: bin/96128
Notes
Notes: svn path=/head/; revision=193244
Diffstat (limited to 'sys/dev/aic7xxx')
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm.c12
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_gram.y26
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y5
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l9
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_scan.l18
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.c29
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.h2
7 files changed, 56 insertions, 45 deletions
diff --git a/sys/dev/aic7xxx/aicasm/aicasm.c b/sys/dev/aic7xxx/aicasm/aicasm.c
index ad010649c8b5..6ba57bcc29ec 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm.c
+++ b/sys/dev/aic7xxx/aicasm/aicasm.c
@@ -79,8 +79,8 @@ static void output_code(void);
static void output_listing(char *ifilename);
static void dump_scope(scope_t *scope);
static void emit_patch(scope_t *scope, int patch);
-static int check_patch(patch_t **start_patch, int start_instr,
- int *skip_addr, int *func_vals);
+static int check_patch(patch_t **start_patch, unsigned int start_instr,
+ unsigned int *skip_addr, int *func_vals);
struct path_list search_path;
int includes_search_curdir;
@@ -116,8 +116,6 @@ int main(int argc, char *argv[]);
int
main(int argc, char *argv[])
{
- extern char *optarg;
- extern int optind;
int ch;
int retval;
char *inputfilename;
@@ -530,7 +528,7 @@ output_listing(char *ifilename)
int *func_values;
int instrcount;
int instrptr;
- int line;
+ unsigned int line;
int func_count;
int skip_addr;
@@ -649,8 +647,8 @@ output_listing(char *ifilename)
}
static int
-check_patch(patch_t **start_patch, int start_instr,
- int *skip_addr, int *func_vals)
+check_patch(patch_t **start_patch, unsigned int start_instr,
+ unsigned int *skip_addr, int *func_vals)
{
patch_t *cur_patch;
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_gram.y b/sys/dev/aic7xxx/aicasm/aicasm_gram.y
index f60366c403f7..91ae8ea805bc 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_gram.y
+++ b/sys/dev/aic7xxx/aicasm/aicasm_gram.y
@@ -88,7 +88,7 @@ static int in_critical_section;
static u_int enum_increment;
static u_int enum_next_value;
-static void process_field(int field_type, symbol_t *sym, int mask);
+static void process_field(unsigned int field_type, symbol_t *sym, int mask);
static void initialize_symbol(symbol_t *symbol);
static void add_macro_arg(const char *argtext, int position);
static void add_macro_body(const char *bodytext);
@@ -107,6 +107,9 @@ static void add_conditional(symbol_t *symbol);
static void add_version(const char *verstring);
static int is_download_const(expression_t *immed);
+extern int yylex (void);
+extern int yyparse (void);
+
#define SRAM_SYMNAME "SRAM_BASE"
#define SCB_SYMNAME "SCB_BASE"
%}
@@ -867,7 +870,7 @@ reg_symbol:
stop("register offset must be a constant", EX_DATAERR);
/* NOTREACHED */
}
- if (($3->info.cinfo->value + 1) > $1->info.rinfo->size) {
+ if (($3->info.cinfo->value + 1) > (unsigned)$1->info.rinfo->size) {
stop("Accessing offset beyond range of register",
EX_DATAERR);
/* NOTREACHED */
@@ -878,7 +881,7 @@ reg_symbol:
| T_SYMBOL '[' T_NUMBER ']'
{
process_register(&$1);
- if (($3 + 1) > $1->info.rinfo->size) {
+ if (($3 + 1) > (unsigned)$1->info.rinfo->size) {
stop("Accessing offset beyond range of register",
EX_DATAERR);
/* NOTREACHED */
@@ -1379,7 +1382,7 @@ code:
%%
static void
-process_field(int field_type, symbol_t *sym, int value)
+process_field(unsigned int field_type, symbol_t *sym, int value)
{
/*
* Add the current register to its
@@ -1531,10 +1534,9 @@ initialize_symbol(symbol_t *symbol)
}
static void
-add_macro_arg(const char *argtext, int argnum)
+add_macro_arg(const char *argtext, int argnum __unused)
{
struct macro_arg *marg;
- int i;
int retval;
@@ -1553,7 +1555,7 @@ add_macro_arg(const char *argtext, int argnum)
retval = snprintf(regex_pattern, sizeof(regex_pattern),
"[^-/A-Za-z0-9_](%s)([^-/A-Za-z0-9_]|$)",
argtext);
- if (retval >= sizeof(regex_pattern)) {
+ if (retval >= (int)sizeof(regex_pattern)) {
stop("Regex text buffer too small for arg",
EX_SOFTWARE);
/* NOTREACHED */
@@ -1911,24 +1913,24 @@ add_conditional(symbol_t *symbol)
static void
add_version(const char *verstring)
{
- const char prefix[] = " * ";
+ const char verprefix[] = " * ";
int newlen;
int oldlen;
- newlen = strlen(verstring) + strlen(prefix);
+ newlen = strlen(verstring) + strlen(verprefix);
oldlen = 0;
if (versions != NULL)
oldlen = strlen(versions);
versions = realloc(versions, newlen + oldlen + 2);
if (versions == NULL)
stop("Can't allocate version string", EX_SOFTWARE);
- strcpy(&versions[oldlen], prefix);
- strcpy(&versions[oldlen + strlen(prefix)], verstring);
+ strcpy(&versions[oldlen], verprefix);
+ strcpy(&versions[oldlen + strlen(verprefix)], verstring);
versions[newlen + oldlen] = '\n';
versions[newlen + oldlen + 1] = '\0';
}
-void
+static void
yyerror(const char *string)
{
stop(string, EX_DATAERR);
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y b/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y
index 0d0fffeb56b6..95e20f18f8c7 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y
+++ b/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y
@@ -66,6 +66,9 @@ static symbol_t *macro_symbol;
static void add_macro_arg(const char *argtext, int position);
+extern int mmlex(void);
+extern int mmparse(void);
+
%}
%union {
@@ -157,7 +160,7 @@ add_macro_arg(const char *argtext, int argnum)
}
}
-void
+static void
mmerror(const char *string)
{
stop(string, EX_DATAERR);
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l b/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
index 49557a8837f8..b8700eb4adf3 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
+++ b/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
@@ -65,7 +65,9 @@
static char string_buf[MAX_STR_CONST];
static char *string_buf_ptr;
static int parren_count;
-static char buf[255];
+static char msgbuf[255];
+
+extern int mmlex(void);
%}
WORD [A-Za-z_][-A-Za-z_0-9]*
@@ -143,9 +145,9 @@ MCARG [^(), \t]+
return T_SYMBOL;
}
. {
- snprintf(buf, sizeof(buf), "Invalid character "
+ snprintf(msgbuf, sizeof(msgbuf), "Invalid character "
"'%c'", mmtext[0]);
- stop(buf, EX_DATAERR);
+ stop(msgbuf, EX_DATAERR);
}
%%
@@ -153,4 +155,5 @@ int
mmwrap()
{
stop("EOF encountered in macro call", EX_DATAERR);
+ return (1);
}
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_scan.l b/sys/dev/aic7xxx/aicasm/aicasm_scan.l
index ced09dc2b12b..2b9faf02e701 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+++ b/sys/dev/aic7xxx/aicasm/aicasm_scan.l
@@ -67,7 +67,13 @@ static char string_buf[MAX_STR_CONST];
static char *string_buf_ptr;
static int parren_count;
static int quote_count;
-static char buf[255];
+static char msgbuf[255];
+
+extern int yylex(void);
+extern int mmlex(void);
+extern int mmparse(void);
+extern void mm_switch_to_buffer(YY_BUFFER_STATE);
+extern void mm_delete_buffer(YY_BUFFER_STATE);
%}
PATH ([/]*[-A-Za-z0-9_.])+
@@ -315,10 +321,10 @@ else { return T_ELSE; }
return ')';
}
<MACROARGLIST>. {
- snprintf(buf, sizeof(buf), "Invalid character "
+ snprintf(msgbuf, sizeof(msgbuf), "Invalid character "
"'%c' in macro argument list",
yytext[0]);
- stop(buf, EX_DATAERR);
+ stop(msgbuf, EX_DATAERR);
}
<MACROCALLARGS>{SPACE} ;
<MACROCALLARGS>\( {
@@ -375,7 +381,7 @@ else { return T_ELSE; }
char c;
yptr = yytext;
- while (c = *yptr++) {
+ while ((c = *yptr++)) {
/*
* Strip carriage returns.
*/
@@ -430,9 +436,9 @@ else { return T_ELSE; }
}
}
. {
- snprintf(buf, sizeof(buf), "Invalid character "
+ snprintf(msgbuf, sizeof(msgbuf), "Invalid character "
"'%c'", yytext[0]);
- stop(buf, EX_DATAERR);
+ stop(msgbuf, EX_DATAERR);
}
%%
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
index 9770a71b8d09..e7bbb699bf63 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
+++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
@@ -49,6 +49,7 @@
#else
#include <db.h>
#endif
+#include <ctype.h>
#include <fcntl.h>
#include <inttypes.h>
#include <regex.h>
@@ -62,8 +63,8 @@
static DB *symtable;
-symbol_t *
-symbol_create(char *name)
+static symbol_t *
+symbol_create(const char *name)
{
symbol_t *new_symbol;
@@ -163,14 +164,14 @@ symtable_close()
* if a lookup fails.
*/
symbol_t *
-symtable_get(char *name)
+symtable_get(const char *name)
{
symbol_t *stored_ptr;
DBT key;
DBT data;
int retval;
- key.data = (void *)name;
+ key.data = strdup(name);
key.size = strlen(name);
if ((retval = symtable->get(symtable, &key, &data, /*flags*/0)) != 0) {
@@ -190,6 +191,7 @@ symtable_get(char *name)
perror("Symtable put failed");
exit(EX_SOFTWARE);
}
+ free(key.data);
return (new_symbol);
} else {
perror("Unexpected return value from db get routine");
@@ -198,6 +200,7 @@ symtable_get(char *name)
}
}
memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
+ free(key.data);
return (stored_ptr);
}
@@ -321,7 +324,7 @@ symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
SLIST_INIT(symlist_src2);
}
-void
+static void
aic_print_file_prologue(FILE *ofile)
{
@@ -337,16 +340,16 @@ aic_print_file_prologue(FILE *ofile)
versions);
}
-void
-aic_print_include(FILE *dfile, char *include_file)
+static void
+aic_print_include(FILE *dfile, char *header_file)
{
if (dfile == NULL)
return;
- fprintf(dfile, "\n#include \"%s\"\n\n", include_file);
+ fprintf(dfile, "\n#include \"%s\"\n\n", header_file);
}
-void
+static void
aic_print_reg_dump_types(FILE *ofile)
{
if (ofile == NULL)
@@ -586,10 +589,9 @@ symtable_dump(FILE *ofile, FILE *dfile)
/* Output generated #defines. */
while (SLIST_FIRST(&registers) != NULL) {
- symbol_node_t *curnode;
u_int value;
- char *tab_str;
- char *tab_str2;
+ const char *tab_str;
+ const char *tab_str2;
curnode = SLIST_FIRST(&registers);
SLIST_REMOVE_HEAD(&registers, links);
@@ -636,7 +638,6 @@ symtable_dump(FILE *ofile, FILE *dfile)
fprintf(ofile, "\n\n");
while (SLIST_FIRST(&constants) != NULL) {
- symbol_node_t *curnode;
curnode = SLIST_FIRST(&constants);
SLIST_REMOVE_HEAD(&constants, links);
@@ -650,7 +651,6 @@ symtable_dump(FILE *ofile, FILE *dfile)
fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {
- symbol_node_t *curnode;
curnode = SLIST_FIRST(&download_constants);
SLIST_REMOVE_HEAD(&download_constants, links);
@@ -664,7 +664,6 @@ symtable_dump(FILE *ofile, FILE *dfile)
fprintf(ofile, "\n\n/* Exported Labels */\n");
while (SLIST_FIRST(&exported_labels) != NULL) {
- symbol_node_t *curnode;
curnode = SLIST_FIRST(&exported_labels);
SLIST_REMOVE_HEAD(&exported_labels, links);
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
index 1496c3768c81..7cdace8805c2 100644
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
+++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
@@ -190,7 +190,7 @@ void symtable_open(void);
void symtable_close(void);
symbol_t *
- symtable_get(char *name);
+ symtable_get(const char *name);
symbol_node_t *
symlist_search(symlist_t *symlist, char *symname);