Date: Fri, 21 Apr 2006 09:34:11 GMT From: Xin LI <delphij@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/96128: [PATCH] Make aicasm WARNS=6 clean Message-ID: <200604210934.k3L9YBPB004187@beast.freebsd.org> Resent-Message-ID: <200604210940.k3L9eG5Y046077@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 96128 >Category: bin >Synopsis: [PATCH] Make aicasm WARNS=6 clean >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 21 09:40:15 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Xin LI >Release: FreeBSD 5.5-PRERELEASE alpha >Organization: N/A >Environment: System: FreeBSD beast.freebsd.org 5.5-PRERELEASE FreeBSD 5.5-PRERELEASE #967: Thu Apr 20 15:17:23 UTC 2006 root@beast.freebsd.org:/usr/src/sys/alpha/compile/BEAST alpha >Description: This is a low priority changeset that makes aicasm utility WARNS=6 clean. >How-To-Repeat: >Fix: --- patch-aicasm begins here --- Index: Makefile =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/Makefile,v retrieving revision 1.23 diff -u -r1.23 Makefile --- Makefile 21 Nov 2005 14:41:10 -0000 1.23 +++ Makefile 21 Apr 2006 09:24:29 -0000 @@ -15,6 +15,7 @@ CLEANFILES+= ${GENHDRS} ${YSRCS:R:C/(.*)/\1.output/g} DPADD= ${LIBL} LDADD= -ll +WARNS?= 6 # Correct path for kernel builds # Don't rely on the kernel's .depend file Index: aicasm.c =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm.c,v retrieving revision 1.38 diff -u -r1.38 aicasm.c --- aicasm.c 6 Jan 2005 01:42:27 -0000 1.38 +++ aicasm.c 20 Apr 2006 07:09:18 -0000 @@ -79,8 +79,8 @@ 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[]) { - extern char *optarg; - extern int optind; int ch; int retval; char *inputfilename; @@ -530,7 +528,7 @@ int *func_values; int instrcount; int instrptr; - int line; + unsigned int line; int func_count; int skip_addr; @@ -649,8 +647,8 @@ } 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; Index: aicasm_gram.y =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_gram.y,v retrieving revision 1.24 diff -u -r1.24 aicasm_gram.y --- aicasm_gram.y 6 Jan 2005 01:42:27 -0000 1.24 +++ aicasm_gram.y 20 Apr 2006 08:06:57 -0000 @@ -88,7 +88,7 @@ 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_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 @@ 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 @@ | 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 @@ %% 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 @@ } 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 @@ 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 @@ 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); Index: aicasm_macro_gram.y =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y,v retrieving revision 1.3 diff -u -r1.3 aicasm_macro_gram.y --- aicasm_macro_gram.y 6 Jan 2005 01:42:27 -0000 1.3 +++ aicasm_macro_gram.y 20 Apr 2006 08:09:43 -0000 @@ -66,6 +66,9 @@ static void add_macro_arg(const char *argtext, int position); +extern int mmlex(void); +extern int mmparse(void); + %} %union { @@ -157,7 +160,7 @@ } } -void +static void mmerror(const char *string) { stop(string, EX_DATAERR); Index: aicasm_macro_scan.l =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l,v retrieving revision 1.6 diff -u -r1.6 aicasm_macro_scan.l --- aicasm_macro_scan.l 6 Jan 2005 01:42:27 -0000 1.6 +++ aicasm_macro_scan.l 20 Apr 2006 08:38:39 -0000 @@ -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 @@ 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 @@ mmwrap() { stop("EOF encountered in macro call", EX_DATAERR); + return (1); } Index: aicasm_scan.l =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_scan.l,v retrieving revision 1.23 diff -u -r1.23 aicasm_scan.l --- aicasm_scan.l 6 Jan 2005 01:42:27 -0000 1.23 +++ aicasm_scan.l 20 Apr 2006 08:34:54 -0000 @@ -67,7 +67,13 @@ 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 @@ 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 @@ char c; yptr = yytext; - while (c = *yptr++) { + while ((c = *yptr++)) { /* * Strip carriage returns. */ @@ -430,9 +436,9 @@ } } . { - snprintf(buf, sizeof(buf), "Invalid character " + snprintf(msgbuf, sizeof(msgbuf), "Invalid character " "'%c'", yytext[0]); - stop(buf, EX_DATAERR); + stop(msgbuf, EX_DATAERR); } %% Index: aicasm_symbol.c =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_symbol.c,v retrieving revision 1.24 diff -u -r1.24 aicasm_symbol.c --- aicasm_symbol.c 6 Jan 2005 01:42:27 -0000 1.24 +++ aicasm_symbol.c 20 Apr 2006 07:23:49 -0000 @@ -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 @@ * 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 @@ 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 @@ } } memcpy(&stored_ptr, data.data, sizeof(stored_ptr)); + free(key.data); return (stored_ptr); } @@ -321,7 +324,7 @@ SLIST_INIT(symlist_src2); } -void +static void aic_print_file_prologue(FILE *ofile) { @@ -337,16 +340,16 @@ 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 @@ /* Output generated #defines. */ while (SLIST_FIRST(®isters) != 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(®isters); SLIST_REMOVE_HEAD(®isters, links); @@ -636,7 +638,6 @@ 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 @@ 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 @@ 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); Index: aicasm_symbol.h =================================================================== RCS file: /home/ncvs/src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v retrieving revision 1.17 diff -u -r1.17 aicasm_symbol.h --- aicasm_symbol.h 6 Jan 2005 01:42:27 -0000 1.17 +++ aicasm_symbol.h 20 Apr 2006 07:19:41 -0000 @@ -190,7 +190,7 @@ 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); --- patch-aicasm ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604210934.k3L9YBPB004187>