Make error() printflike instead of using sprintf before calling it.
This commit is contained in:
parent
98fbb52a77
commit
90a10bbb8a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc_parse.c,v 1.19 2015/05/09 23:12:57 dholland Exp $ */
|
||||
/* $NetBSD: rpc_parse.c,v 1.20 2015/05/09 23:28:43 dholland Exp $ */
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
|
||||
#else
|
||||
__RCSID("$NetBSD: rpc_parse.c,v 1.19 2015/05/09 23:12:57 dholland Exp $");
|
||||
__RCSID("$NetBSD: rpc_parse.c,v 1.20 2015/05/09 23:28:43 dholland Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -377,21 +377,16 @@ static void
|
|||
check_type_name(const char *name, int new_type)
|
||||
{
|
||||
int i;
|
||||
char tmp[100];
|
||||
|
||||
for (i = 0; reserved_words[i] != NULL; i++) {
|
||||
if (strcmp(name, reserved_words[i]) == 0) {
|
||||
sprintf(tmp,
|
||||
"Illegal (reserved) name '%s' in type definition", name);
|
||||
error(tmp);
|
||||
error("Illegal (reserved) name '%s' in type definition", name);
|
||||
}
|
||||
}
|
||||
if (new_type) {
|
||||
for (i = 0; reserved_types[i] != NULL; i++) {
|
||||
if (strcmp(name, reserved_types[i]) == 0) {
|
||||
sprintf(tmp,
|
||||
"Illegal (reserved) name '%s' in type definition", name);
|
||||
error(tmp);
|
||||
error("Illegal (reserved) name '%s' in type definition", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc_scan.c,v 1.14 2015/05/09 23:12:57 dholland Exp $ */
|
||||
/* $NetBSD: rpc_scan.c,v 1.15 2015/05/09 23:28:43 dholland Exp $ */
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
|
||||
#else
|
||||
__RCSID("$NetBSD: rpc_scan.c,v 1.14 2015/05/09 23:12:57 dholland Exp $");
|
||||
__RCSID("$NetBSD: rpc_scan.c,v 1.15 2015/05/09 23:28:43 dholland Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -283,17 +283,11 @@ get_token(token *tokp)
|
|||
|
||||
default:
|
||||
if (!(isalpha((unsigned char)*where) || *where == '_')) {
|
||||
char buf[100];
|
||||
char *p;
|
||||
|
||||
s_print(buf, "Illegal character in file: ");
|
||||
p = buf + strlen(buf);
|
||||
if (isprint((unsigned char)*where)) {
|
||||
s_print(p, "%c", *where);
|
||||
error("Illegal character '%c' in file", *where);
|
||||
} else {
|
||||
s_print(p, "%d", *where);
|
||||
error("Illegal character %d in file", *where);
|
||||
}
|
||||
error(buf);
|
||||
}
|
||||
findkind(&where, tokp);
|
||||
break;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc_util.c,v 1.16 2015/05/09 23:16:51 dholland Exp $ */
|
||||
/* $NetBSD: rpc_util.c,v 1.17 2015/05/09 23:28:43 dholland Exp $ */
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
|
||||
#else
|
||||
__RCSID("$NetBSD: rpc_util.c,v 1.16 2015/05/09 23:16:51 dholland Exp $");
|
||||
__RCSID("$NetBSD: rpc_util.c,v 1.17 2015/05/09 23:28:43 dholland Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -254,11 +254,17 @@ pvname(const char *pname, const char *vnum)
|
|||
/*
|
||||
* print a useful (?) error message, and then die
|
||||
*/
|
||||
void
|
||||
error(const char *msg)
|
||||
__printflike(1, 2) void
|
||||
error(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
printwhere();
|
||||
f_print(stderr, "%s:%d: %s", infilename, linenum, msg);
|
||||
fprintf(stderr, "%s:%d: ", infilename, linenum);
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, msg, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, "\n");
|
||||
errx(EXIT_FAILURE, "Cannot recover from this error");
|
||||
}
|
||||
/*
|
||||
|
@ -288,17 +294,13 @@ record_open(const char *file)
|
|||
}
|
||||
}
|
||||
|
||||
static char expectbuf[100];
|
||||
|
||||
/*
|
||||
* error, token encountered was not the expected one
|
||||
*/
|
||||
void
|
||||
expected1(tok_kind exp1)
|
||||
{
|
||||
s_print(expectbuf, "Expected '%s'",
|
||||
toktostr(exp1));
|
||||
error(expectbuf);
|
||||
error("Expected '%s'", toktostr(exp1));
|
||||
}
|
||||
/*
|
||||
* error, token encountered was not one of two expected ones
|
||||
|
@ -306,10 +308,9 @@ expected1(tok_kind exp1)
|
|||
void
|
||||
expected2(tok_kind exp1, tok_kind exp2)
|
||||
{
|
||||
s_print(expectbuf, "Expected '%s' or '%s'",
|
||||
error("Expected '%s' or '%s'",
|
||||
toktostr(exp1),
|
||||
toktostr(exp2));
|
||||
error(expectbuf);
|
||||
}
|
||||
/*
|
||||
* error, token encountered was not one of 3 expected ones
|
||||
|
@ -317,11 +318,10 @@ expected2(tok_kind exp1, tok_kind exp2)
|
|||
void
|
||||
expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
|
||||
{
|
||||
s_print(expectbuf, "Expected '%s', '%s', or '%s'",
|
||||
error("Expected '%s', '%s', or '%s'",
|
||||
toktostr(exp1),
|
||||
toktostr(exp2),
|
||||
toktostr(exp3));
|
||||
error(expectbuf);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpc_util.h,v 1.10 2015/05/09 23:19:34 dholland Exp $ */
|
||||
/* $NetBSD: rpc_util.h,v 1.11 2015/05/09 23:28:43 dholland Exp $ */
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
|
@ -114,7 +114,7 @@ int isvectordef(const char *, relation);
|
|||
char *locase(const char *);
|
||||
void pvname_svc(const char *, const char *);
|
||||
void pvname(const char *, const char *);
|
||||
void error(const char *);
|
||||
__printflike(1, 2) void error(const char *, ...);
|
||||
void crash(void);
|
||||
void record_open(const char *);
|
||||
void expected1(tok_kind) __dead;
|
||||
|
|
Loading…
Reference in New Issue