svn commit: r193244 - head/sys/dev/aic7xxx/aicasm

Xin LI delphij at FreeBSD.org
Mon Jun 1 18:42:18 UTC 2009


Author: delphij
Date: Mon Jun  1 18:42:16 2009
New Revision: 193244
URL: http://svn.freebsd.org/changeset/base/193244

Log:
  Code cleanups to make this WARNS=6 clean.
  
  PR:		bin/96128

Modified:
  head/sys/dev/aic7xxx/aicasm/aicasm.c
  head/sys/dev/aic7xxx/aicasm/aicasm_gram.y
  head/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y
  head/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
  head/sys/dev/aic7xxx/aicasm/aicasm_scan.l
  head/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
  head/sys/dev/aic7xxx/aicasm/aicasm_symbol.h

Modified: head/sys/dev/aic7xxx/aicasm/aicasm.c
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm.c	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm.c	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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;
 

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_gram.y
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_gram.y	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_gram.y	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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 *sy
 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 a
 	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);

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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 a
 	}
 }
 
-void
+static void
 mmerror(const char *string)
 {
 	stop(string, EX_DATAERR);

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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);
 }

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_scan.l
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_scan.l	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_scan.l	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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);
 			}
 %%
 

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_symbol.c	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_symbol.c	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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, s
 	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);

Modified: head/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
==============================================================================
--- head/sys/dev/aic7xxx/aicasm/aicasm_symbol.h	Mon Jun  1 18:38:36 2009	(r193243)
+++ head/sys/dev/aic7xxx/aicasm/aicasm_symbol.h	Mon Jun  1 18:42:16 2009	(r193244)
@@ -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);


More information about the svn-src-head mailing list