Module Name: src
Committed By: lukem
Date: Wed Apr 15 08:26:35 UTC 2009
Modified Files:
src/usr.sbin/gspa/gspa: gsp_ass.h gsp_inst.c gsp_lex.c gsp_out.c
gsp_sym.c gspa.c
Log Message:
Fix WARNS=4 (-Wshadow -Wcast-qual -Wsign-compare)
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/gspa/gspa/gsp_ass.h
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/gspa/gspa/gsp_inst.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/gspa/gspa/gsp_lex.c \
src/usr.sbin/gspa/gspa/gsp_sym.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/gspa/gspa/gsp_out.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/gspa/gspa/gspa.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/gspa/gspa/gsp_ass.h
diff -u src/usr.sbin/gspa/gspa/gsp_ass.h:1.11 src/usr.sbin/gspa/gspa/gsp_ass.h:1.12
--- src/usr.sbin/gspa/gspa/gsp_ass.h:1.11 Sat Feb 2 17:16:14 2008
+++ src/usr.sbin/gspa/gspa/gsp_ass.h Wed Apr 15 08:26:34 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gsp_ass.h,v 1.11 2008/02/02 17:16:14 christos Exp $ */
+/* $NetBSD: gsp_ass.h,v 1.12 2009/04/15 08:26:34 lukem Exp $ */
/*
* GSP assembler - definitions
*
@@ -144,9 +144,9 @@
void listing(void);
symbol lookup(char *id, bool makeit);
expr num_expr(int);
-void p1err(char *fmt, ...)
+void p1err(const char *fmt, ...)
__attribute__((__format__(__printf__, 1, 2)));
-void perr(char *fmt, ...)
+void perr(const char *fmt, ...)
__attribute__((__format__(__printf__, 1, 2)));
void pseudo(int code, operand operands);
void push_input(char *fn);
@@ -162,14 +162,14 @@
void statement(char *opcode, operand operands);
operand string_op(char *);
void ucasify(char *);
-void yyerror(char *err);
+void yyerror(const char *err);
int yylex(void);
extern unsigned pc;
extern short pass2;
-extern int lineno;
+extern unsigned lineno;
extern int err_count;
extern char line[], *lineptr;
Index: src/usr.sbin/gspa/gspa/gsp_inst.c
diff -u src/usr.sbin/gspa/gspa/gsp_inst.c:1.10 src/usr.sbin/gspa/gspa/gsp_inst.c:1.11
--- src/usr.sbin/gspa/gspa/gsp_inst.c:1.10 Mon Dec 18 20:12:21 2006
+++ src/usr.sbin/gspa/gspa/gsp_inst.c Wed Apr 15 08:26:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gsp_inst.c,v 1.10 2006/12/18 20:12:21 christos Exp $ */
+/* $NetBSD: gsp_inst.c,v 1.11 2009/04/15 08:26:35 lukem Exp $ */
/*
* TMS34010 GSP assembler - Instruction encoding
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: gsp_inst.c,v 1.10 2006/12/18 20:12:21 christos Exp $");
+__RCSID("$NetBSD: gsp_inst.c,v 1.11 2009/04/15 08:26:35 lukem Exp $");
#endif
#include <string.h>
@@ -42,7 +42,7 @@
#include "gsp_code.h"
struct inst {
- char *opname;
+ const char *opname;
u_int16_t opcode;
u_char class; /* instruction class + flags */
u_char optypes[4]; /* permissible operand classes */
@@ -254,7 +254,7 @@
{NULL, 0, 0, {0, 0, 0, 0}}
};
-int check_spec(int spec, char *valid, char *what);
+int check_spec(int spec, const char *valid, const char *what);
void do_statement(char *opcode, operand operands);
int encode_instr(struct inst *ip, operand ops, int *spec, u_int16_t *iwords);
int specifier(operand op);
@@ -270,7 +270,8 @@
do_statement(char *opcode, operand operands)
{
struct inst *ip;
- int i, nop, req;
+ int i, req;
+ unsigned nop;
operand op;
int spec[3];
u_int16_t iwords[6];
@@ -300,7 +301,7 @@
if( req == 0 )
break;
if( (op->type & req) == 0 ){
- perr("Inappropriate type for operand %d", nop+1);
+ perr("Inappropriate type for operand %u", nop+1);
return;
}
if( (req & ~OPTOPRN) == SPEC ) {
@@ -336,12 +337,12 @@
putcode(iwords, i);
}
-char *specs[] = { "B", "L", "W", "XY", NULL };
+const char *specs[] = { "B", "L", "W", "XY", NULL };
int
specifier(operand op)
{
- char **sl;
+ const char **sl;
expr e;
char sp[4];
@@ -364,7 +365,7 @@
}
int
-check_spec(int spec, char *valid, char *what)
+check_spec(int spec, const char *valid, const char *what)
{
char *p;
@@ -444,7 +445,7 @@
int opc, nw, class, flags, ms, md, off;
int mask, file, bit, i;
operand op0, op1;
- unsigned line[2];
+ unsigned eline[2];
int32_t val[2];
rs = rd = 0;
@@ -453,10 +454,10 @@
op0 = ops;
if( op0 != NULL ){
if( spec[0] == 0 && USES_EXPR(op0) )
- eval_expr(op0->op_u.value, &val[0], &line[0]);
+ eval_expr(op0->op_u.value, &val[0], &eline[0]);
op1 = ops->next;
if( op1 != NULL && spec[1] == 0 && USES_EXPR(op1) )
- eval_expr(op1->op_u.value, &val[1], &line[1]);
+ eval_expr(op1->op_u.value, &val[1], &eline[1]);
} else
op1 = NULL;
class = ip->class & CLASS;
@@ -475,7 +476,7 @@
/* turn it into TWOREG, IMMREG or KREG */
if( op0->type == REG ){
class = TWOREG;
- } else if( (flags & K32) != 0 && line[0] <= lineno
+ } else if( (flags & K32) != 0 && eline[0] <= lineno
&& spec[2] == 0
&& 0 < val[0] && val[0] <= 32 ){
/* use 5-bit immediate */
@@ -531,7 +532,7 @@
val[0] = ~ val[0];
i = check_spec(spec[2], " WL", "length");
if( i == 1
- || (i == 0 && (flags & NOIMM16) == 0 && line[0] <= lineno
+ || (i == 0 && (flags & NOIMM16) == 0 && eline[0] <= lineno
&& (int16_t)val[0] == val[0] )){
if( (int16_t) val[0] != val[0] )
perr("Value truncated to 16 bits");
@@ -564,7 +565,7 @@
}
off = (int)(val[0] - pc - 0x20) >> 4;
if( opc == 0x0920 ){ /* CALL */
- if( line[0] <= lineno && (int16_t) off == off )
+ if( eline[0] <= lineno && (int16_t) off == off )
opc = 0x0D3F; /* CALLR */
else
opc = 0x0D5F; /* CALLA */
Index: src/usr.sbin/gspa/gspa/gsp_lex.c
diff -u src/usr.sbin/gspa/gspa/gsp_lex.c:1.8 src/usr.sbin/gspa/gspa/gsp_lex.c:1.9
--- src/usr.sbin/gspa/gspa/gsp_lex.c:1.8 Sat Aug 26 18:15:37 2006
+++ src/usr.sbin/gspa/gspa/gsp_lex.c Wed Apr 15 08:26:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gsp_lex.c,v 1.8 2006/08/26 18:15:37 christos Exp $ */
+/* $NetBSD: gsp_lex.c,v 1.9 2009/04/15 08:26:35 lukem Exp $ */
/*
* Lexical analyser for GSP assembler
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: gsp_lex.c,v 1.8 2006/08/26 18:15:37 christos Exp $");
+__RCSID("$NetBSD: gsp_lex.c,v 1.9 2009/04/15 08:26:35 lukem Exp $");
#endif
#include <stdio.h>
@@ -51,9 +51,9 @@
extern YYSTYPE yylval;
-int str_match(char *, char **);
+int str_match(const char *, const char **);
-char *regnames[] = {
+const char *regnames[] = {
"A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
"A8", "A9", "A10", "A11", "A12", "A13", "A14", "SP",
"B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
@@ -73,9 +73,9 @@
};
void
-lex_init(char *line)
+lex_init(char *lline)
{
- lineptr = line;
+ lineptr = lline;
idptr = idents;
}
@@ -183,9 +183,9 @@
}
int
-str_match(char *id, char **names)
+str_match(const char *id, const char **names)
{
- char **np;
+ const char **np;
for( np = names; *np != NULL; ++np )
if( strcmp(id, *np) == 0 )
Index: src/usr.sbin/gspa/gspa/gsp_sym.c
diff -u src/usr.sbin/gspa/gspa/gsp_sym.c:1.8 src/usr.sbin/gspa/gspa/gsp_sym.c:1.9
--- src/usr.sbin/gspa/gspa/gsp_sym.c:1.8 Sat Aug 26 18:15:37 2006
+++ src/usr.sbin/gspa/gspa/gsp_sym.c Wed Apr 15 08:26:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gsp_sym.c,v 1.8 2006/08/26 18:15:37 christos Exp $ */
+/* $NetBSD: gsp_sym.c,v 1.9 2009/04/15 08:26:35 lukem Exp $ */
/*
* GSP assembler - symbol table
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: gsp_sym.c,v 1.8 2006/08/26 18:15:37 christos Exp $");
+__RCSID("$NetBSD: gsp_sym.c,v 1.9 2009/04/15 08:26:35 lukem Exp $");
#endif
#include <stdio.h>
@@ -78,7 +78,7 @@
}
void
-define_sym(char *id, unsigned val, unsigned lineno, int flags)
+define_sym(char *id, unsigned val, unsigned lno, int flags)
{
symbol ptr;
@@ -95,7 +95,7 @@
ptr->flags = flags;
ptr->ndefn += 1;
ptr->value = val;
- ptr->lineno = lineno;
+ ptr->lineno = lno;
}
void
@@ -112,13 +112,13 @@
do_asg(char *name, expr value, int flags)
{
int32_t val;
- unsigned line;
+ unsigned lno;
- if( eval_expr(value, &val, &line) )
+ if( eval_expr(value, &val, &lno) )
flags |= DEFINED;
- if( line < lineno )
- line = lineno;
- define_sym(name, val, line, flags);
+ if( lno < lineno )
+ lno = lineno;
+ define_sym(name, val, lno, flags);
if( pass2 )
do_show_val(val);
}
Index: src/usr.sbin/gspa/gspa/gsp_out.c
diff -u src/usr.sbin/gspa/gspa/gsp_out.c:1.9 src/usr.sbin/gspa/gspa/gsp_out.c:1.10
--- src/usr.sbin/gspa/gspa/gsp_out.c:1.9 Sat Aug 26 18:15:37 2006
+++ src/usr.sbin/gspa/gspa/gsp_out.c Wed Apr 15 08:26:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gsp_out.c,v 1.9 2006/08/26 18:15:37 christos Exp $ */
+/* $NetBSD: gsp_out.c,v 1.10 2009/04/15 08:26:35 lukem Exp $ */
/*
* GSP assembler - binary & listing output
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: gsp_out.c,v 1.9 2006/08/26 18:15:37 christos Exp $");
+__RCSID("$NetBSD: gsp_out.c,v 1.10 2009/04/15 08:26:35 lukem Exp $");
#endif
#include <stdio.h>
@@ -131,7 +131,7 @@
void
c_dumpbuf()
{
- int i;
+ uint32_t i;
fprintf(objfile, "\n\n\t%d, 0x%04x, 0x%04x, /* new block */",
c_bufptr, (int)(c_binads >> 16), (int)(c_binads & 0xffff));
@@ -224,7 +224,7 @@
void
listing_line()
{
- int i;
+ unsigned i;
if( listfile == NULL ){
code_idx = 0;
Index: src/usr.sbin/gspa/gspa/gspa.c
diff -u src/usr.sbin/gspa/gspa/gspa.c:1.13 src/usr.sbin/gspa/gspa/gspa.c:1.14
--- src/usr.sbin/gspa/gspa/gspa.c:1.13 Mon Dec 18 20:12:21 2006
+++ src/usr.sbin/gspa/gspa/gspa.c Wed Apr 15 08:26:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gspa.c,v 1.13 2006/12/18 20:12:21 christos Exp $ */
+/* $NetBSD: gspa.c,v 1.14 2009/04/15 08:26:35 lukem Exp $ */
/*
* GSP assembler main program
*
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: gspa.c,v 1.13 2006/12/18 20:12:21 christos Exp $");
+__RCSID("$NetBSD: gspa.c,v 1.14 2009/04/15 08:26:35 lukem Exp $");
#endif
#include <sys/param.h>
@@ -56,7 +56,7 @@
int err_count;
char line[MAXLINE];
-int lineno;
+unsigned lineno;
extern int yydebug;
short pass2;
@@ -250,7 +250,7 @@
}
void
-perr(char *fmt, ...)
+perr(const char *fmt, ...)
{
va_list ap;
char error_string[256];
@@ -267,7 +267,7 @@
}
void
-p1err(char *fmt, ...)
+p1err(const char *fmt, ...)
{
va_list ap;
@@ -280,10 +280,10 @@
}
void
-yyerror(char *err)
+yyerror(const char *errs)
{
- perr("%s", err);
+ perr("%s", errs);
longjmp(synerrjmp, 1);
}