summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2006-04-18 03:59:47 +0000
committerChad Loder <cloder@cvs.openbsd.org>2006-04-18 03:59:47 +0000
commit85414c5fc324296d0813ae0d3cbb73ddc8cf9931 (patch)
tree19392f8c4dc22993c1d8a3ebcbf2481eed30e989 /usr.bin
parent68c7e7f117826f0b39de48ccc0bb99a5fd91f9fa (diff)
For all warnings involving prototypes, print the function name and the
argument number.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xlint/lint1/err.c24
-rw-r--r--usr.bin/xlint/lint1/tree.c83
2 files changed, 57 insertions, 50 deletions
diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c
index 9f4d2ec613c..619887af43d 100644
--- a/usr.bin/xlint/lint1/err.c
+++ b/usr.bin/xlint/lint1/err.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: err.c,v 1.20 2006/03/13 21:12:32 moritz Exp $ */
+/* $OpenBSD: err.c,v 1.21 2006/04/18 03:59:46 cloder Exp $ */
/* $NetBSD: err.c,v 1.8 1995/10/02 17:37:00 jpo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: err.c,v 1.20 2006/03/13 21:12:32 moritz Exp $";
+static char rcsid[] = "$OpenBSD: err.c,v 1.21 2006/04/18 03:59:46 cloder Exp $";
#endif
/* number of errors found */
@@ -207,10 +207,10 @@ const char *msgs[] = {
"argument mismatch: %d arg%s passed, %d expected", /* 150 */
"void expressions may not be arguments, arg #%d", /* 151 */
"argument cannot have unknown size, arg #%d", /* 152 */
- "argument has incompatible pointer type, arg #%d", /* 153 */
- "illegal combination of pointer and integer, arg #%d", /* 154 */
- "argument is incompatible with prototype, arg #%d", /* 155 */
- "enum type mismatch, arg #%d", /* 156 */
+ "%s arg #%d: incompatible pointer type", /* 153 */
+ "%s arg #%d: illegal combination of pointer and integer", /* 154 */
+ "%s arg #%d: argument is incompatible with prototype", /* 155 */
+ "%s arg #%d: enum type mismatch", /* 156 */
"ANSI C treats constant as unsigned", /* 157 */
"%s may be used before set", /* 158 */
"assignment in conditional context", /* 159 */
@@ -313,7 +313,7 @@ const char *msgs[] = {
"unterminated comment", /* 256 */
"extra characters in lint comment", /* 257 */
"unterminated string constant", /* 258 */
- "arg #%d converted to '%s' by prototype", /* 259 */
+ "%s arg #%d: converted to '%s'", /* 259 */
"previous declaration of %s", /* 260 */
"previous definition of %s", /* 261 */
"\\\" inside character constants undefined in traditional C", /* 262 */
@@ -332,7 +332,7 @@ const char *msgs[] = {
"cast discards 'const' from pointer target type", /* 275 */
"", /* 276 */
"initialisation of '%s' with '%s'", /* 277 */
- "combination of '%s' and '%s', arg #%d", /* 278 */
+ "%s arg #%d: combination of '%s' and '%s'", /* 278 */
"combination of '%s' and '%s' in return", /* 279 */
"must be outside function: /* %s */", /* 280 */
"duplicate use of /* %s */", /* 281 */
@@ -349,10 +349,10 @@ const char *msgs[] = {
"cannot concatenate wide and regular string literals", /* 292 */
"argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE", /* 293 */
"multi-character character constant", /* 294 */
- "conversion of '%s' to '%s' is out of range, arg #%d", /* 295 */
- "conversion of negative constant to unsigned type, arg #%d", /* 296 */
- "conversion from '%s' to '%s' may sign-extend incorrectly, arg #%d", /* 297 */
- "conversion from '%s' to '%s' may lose accuracy, arg #%d", /* 298 */
+ "%s arg #%d: conversion of '%s' to '%s' is out of range", /* 295 */
+ "%s arg #%d: conversion of negative constant to unsigned type", /* 296 */
+ "%s arg #%d: conversion from '%s' to '%s' may sign-extend incorrectly", /* 297 */
+ "%s arg #%d: conversion from '%s' to '%s' may lose accuracy", /* 298 */
"prototype does not match old style definition, arg #%d", /* 299 */
"old style definition", /* 300 */
"array of incomplete type", /* 301 */
diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c
index 72c4ed799d7..857a907ad6d 100644
--- a/usr.bin/xlint/lint1/tree.c
+++ b/usr.bin/xlint/lint1/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.33 2006/04/18 03:10:27 cloder Exp $ */
+/* $OpenBSD: tree.c,v 1.34 2006/04/18 03:59:46 cloder Exp $ */
/* $NetBSD: tree.c,v 1.12 1995/10/02 17:37:57 jpo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: tree.c,v 1.33 2006/04/18 03:10:27 cloder Exp $";
+static char rcsid[] = "$OpenBSD: tree.c,v 1.34 2006/04/18 03:59:46 cloder Exp $";
#endif
#include <stdlib.h>
@@ -1256,8 +1256,8 @@ asgntypok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
warning(182);
break;
case FARG:
- /* argument has incompat. ptr. type, arg #%d */
- warning(153, arg);
+ /* %s arg #%d: incompatible ptr. type */
+ warning(153, funcname(farg->fa_func), arg);
break;
default:
/* operands have incompat. ptr. types, op %s */
@@ -1276,8 +1276,8 @@ asgntypok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
warning(183);
break;
case FARG:
- /* illegal comb. of ptr. and int., arg #%d */
- warning(154, arg);
+ /* %s arg #%d: illegal comb. of ptr. and int. */
+ warning(154, funcname(farg->fa_func), arg);
break;
default:
/* illegal comb. of ptr. and int., op %s */
@@ -1294,8 +1294,8 @@ asgntypok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
illptrc(NULL, ltp, rtp);
break;
case FARG:
- /* argument has incompatible pointer type, arg #%d */
- warning(153, arg);
+ /* %s arg #%d: incompatible pointer type */
+ warning(153, funcname(farg->fa_func), arg);
break;
default:
illptrc(mp, ltp, rtp);
@@ -1314,8 +1314,8 @@ asgntypok(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
error(211);
break;
case FARG:
- /* argument is incompatible with prototype, arg #%d */
- warning(155, arg);
+ /* %s arg #%d: argument is incompatible with prototype */
+ warning(155, funcname(farg->fa_func), arg);
break;
default:
incompat(op, lt, rt);
@@ -1377,8 +1377,8 @@ chkeop2(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
warning(210);
break;
case FARG:
- /* enum type mismatch, arg #%d */
- warning(156, arg);
+ /* %s arg #%d: enum type mismatch */
+ warning(156, funcname(farg->fa_func), arg);
break;
case RETURN:
/* return value type mismatch */
@@ -1425,8 +1425,8 @@ chkeop1(op_t op, farg_t *farg, tnode_t *ln, tnode_t *rn)
warning(277, tyname(ln->tn_type), tyname(rn->tn_type));
break;
case FARG:
- /* combination of '%s' and '%s', arg #%d */
- warning(278, tyname(ln->tn_type), tyname(rn->tn_type), arg);
+ /* %s arg #%d: combination of '%s' and '%s' */
+ warning(278, funcname(farg->fa_func), arg, tyname(ln->tn_type), tyname(rn->tn_type));
break;
case RETURN:
/* combination of '%s' and '%s' in return */
@@ -1707,8 +1707,8 @@ ptconv(farg_t *farg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
if (ptn->tn_op == CON) {
/* ok. promote() warns if constant out of range */
} else {
- /* arg #%d converted to '%s' by prototype */
- warning(259, arg, tyname(tp));
+ /* %s arg #%d: converted to '%s' */
+ warning(259, funcname(farg->fa_func), arg, tyname(tp));
}
}
} else if (hflag) {
@@ -1723,8 +1723,8 @@ ptconv(farg_t *farg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
msb(ptn->tn_val->v_quad, ot, -1) == 0) {
/* ok */
} else {
- /* arg #%d converted to '%s' by prototype */
- warning(259, arg, tyname(tp));
+ /* %s arg #%d: converted to '%s' */
+ warning(259, funcname(farg->fa_func), arg, tyname(tp));
}
}
}
@@ -1747,10 +1747,11 @@ iiconv(op_t op, farg_t *farg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
#if 0
if (psize(nt) > psize(ot) && isutyp(nt) != isutyp(ot)) {
- /* conversion to %s may sign-extend incorrectly (, arg #%d) */
+ /* conversion to %s may sign-extend incorrectly */
if (aflag && pflag) {
if (op == FARG) {
- warning(297, tyname(tp), arg);
+ warning(297, funcname(farg->fa_func), arg,
+ tyname(tp));
} else {
warning(131, tyname(tp));
}
@@ -1764,7 +1765,8 @@ iiconv(op_t op, farg_t *farg, tspec_t nt, tspec_t ot, type_t *tp, tnode_t *tn)
/* conversion from '%s' to '%s' may lose accuracy */
if (aflag) {
if (op == FARG) {
- warning(298, tyname(tn->tn_type), tyname(tp), arg);
+ warning(298, funcname(farg->fa_func), arg,
+ tyname(tn->tn_type), tyname(tp));
} else {
warning(132, tyname(tn->tn_type), tyname(tp));
}
@@ -1910,9 +1912,9 @@ cvtcon(op_t op, farg_t *farg, type_t *tp, val_t *nv, val_t *v)
if (nt == LDOUBLE)
lerror("cvtcon() 2");
if (op == FARG) {
- /* conv. of %s to %s is out of rng., arg #%d */
- warning(295, tyname(gettyp(ot)), tyname(tp),
- arg);
+ /* %s arg #%d: conv. of %s to %s is out of range */
+ warning(295, funcname(farg->fa_func), arg,
+ tyname(gettyp(ot)), tyname(tp));
} else {
/* conversion of %s to %s is out of range */
warning(119, tyname(gettyp(ot)), tyname(tp));
@@ -2017,8 +2019,8 @@ cvtcon(op_t op, farg_t *farg, type_t *tp, val_t *nv, val_t *v)
/* initialisation of unsigned with neg. ... */
warning(221);
} else if (op == FARG) {
- /* conversion of neg. const. to ..., arg #%d */
- warning(296, arg);
+ /* %s arg #%d: conversion of neg. const... */
+ warning(296, funcname(farg->fa_func), arg);
} else if (modtab[op].m_comp) {
/* we get this warning already in chkcomp() */
} else {
@@ -2067,9 +2069,9 @@ cvtcon(op_t op, farg_t *farg, type_t *tp, val_t *nv, val_t *v)
/* case label affected by conversion */
warning(196);
} else if (op == FARG) {
- /* conv. of %s to %s is out of rng., arg #%d */
- warning(295, tyname(gettyp(ot)), tyname(tp),
- arg);
+ /* %s arg #%d: conv. of %s to %s is out of rng. */
+ warning(295, funcname(farg->fa_func), arg,
+ tyname(gettyp(ot)), tyname(tp));
} else {
/* conversion of %s to %s is out of range */
warning(119, tyname(gettyp(ot)), tyname(tp));
@@ -2092,9 +2094,9 @@ cvtcon(op_t op, farg_t *farg, type_t *tp, val_t *nv, val_t *v)
/* case label affected by conversion */
warning(196);
} else if (op == FARG) {
- /* conv. of %s to %s is out of rng., arg #%d */
- warning(295, tyname(gettyp(ot)), tyname(tp),
- arg);
+ /* %s arg #%d: conv. of %s to %s is out of rng. */
+ warning(295, funcname(farg->fa_func), arg,
+ tyname(gettyp(ot)), tyname(tp));
} else {
/* conversion of %s to %s is out of range */
warning(119, tyname(gettyp(ot)), tyname(tp));
@@ -3920,12 +3922,17 @@ const char *
funcname(tnode_t *tn)
{
/* dereference function pointer */
- if (tn->tn_op == AMPER)
+ switch (tn->tn_op) {
+ case AMPER:
return funcname(tn->tn_left);
-
- if (tn->tn_op == CALL)
+ case LOAD:
+ /* called as (*fptr)(args) */
return funcname(tn->tn_left);
-
- // assume tn->tn_op == NAME
- return tn->tn_sym->s_name;
+ case CALL:
+ return funcname(tn->tn_left);
+ case NAME:
+ return tn->tn_sym->s_name;
+ default:
+ return "<unknown>";
+ }
}