2000-12-05 Ken Raeburn <raeburn@mit.edu>
+ * et_c.awk: Don't generate macros we won't use. Assume ANSI C
+ prototypes. Include com_err.h in output file, rather than
+ duplicating declarations.
+
+ * com_err.c: Assume ANSI C; drop conditional-prototype macros and
+ varargs.h support.
+
+ * com_err.h: Get rid of old 68k-Mac pragmas.
+ (GSS_DLLIMP, KRB5_EXPORTVAR, HAVE_STDARG_H, ET_P, NEAR,
+ ET_STDARG_P, ET_VARARGS): Don't define.
+ (struct et_list, _et_list): Declare, with annotations.
+ * error_table.h (struct et_list, _et_list): Don't declare here.
+
+ * error_message.c (_et_list): Annotate.
+ (error_message, add_error_table, remove_error_table): Check
+ 'table' field of et_list for null pointer.
+
+ * t_com_err.c: Include string.h.
+ (try_one): Check strcmp value against zero explicitly.
+ (main): Annotate arguments as unused. Cast add_error_table and
+ remove_error_table return values to void.
+
* Makefile.in (clean-unix): Clean up lclint files too.
(cleant-lclint): New target.
(et1.c, et2.c, et1.h, et2.h, test1.c, test1.h, test2.h, test2.c):
(rebuild, rebuild-c, rebuild-h): New targets: Rebuild perl
versions of awk scripts.
(clean-files): Get more generated files from test cases.
+ * et_c.perl, et_h.perl: Rebuilt.
2000-11-14 Ken Raeburn <raeburn@mit.edu>
static /*@null@*/ et_old_error_hook_func com_err_hook = 0;
-static void default_com_err_proc
-ET_P((const char FAR *whoami, errcode_t code,
- const char FAR *fmt, va_list ap));
+static void default_com_err_proc (const char FAR *whoami, errcode_t code,
+ const char FAR *fmt, va_list ap);
static void default_com_err_proc(whoami, code, fmt, ap)
const char FAR *whoami;
}
-#ifndef ET_VARARGS
KRB5_DLLIMP void KRB5_CALLCONV_C com_err(const char FAR *whoami,
errcode_t code,
const char FAR *fmt, ...)
-#else
-KRB5_DLLIMP void KRB5_CALLCONV_C com_err(whoami, code, fmt, va_alist)
- const char FAR *whoami;
- errcode_t code;
- const char FAR *fmt;
- va_dcl
-#endif
{
va_list ap;
-#ifdef ET_VARARGS
- va_start(ap);
-#else
va_start(ap, fmt);
-#endif
com_err_va(whoami, code, fmt, ap);
va_end(ap);
}
#if defined(_MSDOS) || defined(_WIN32) || defined(macintosh)
#include <win-mac.h>
-#if defined(macintosh) && defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
-#pragma import on
-#endif
#endif
#ifndef KRB5_CALLCONV
#define KRB5_CALLCONV
#define KRB5_CALLCONV_C
#define KRB5_DLLIMP
-#define GSS_DLLIMP
-#define KRB5_EXPORTVAR
#endif
#ifndef FAR
#define FAR
-#define NEAR
-#endif
-
-#if defined(__STDC__) || defined(__cplusplus) || defined(_MSDOS) || defined(_WIN32) || defined(macintosh)
-
-/* End-user programs may need this -- oh well */
-#ifndef HAVE_STDARG_H
-#define HAVE_STDARG_H 1
#endif
-#define ET_P(x) x
-
-#else
-#define ET_P(x) ()
-#endif /* __STDC__ */
-
-#ifdef HAVE_STDARG_H
#include <stdarg.h>
-#define ET_STDARG_P(x) x
-#else
-#include <varargs.h>
-#define ET_STDARG_P(x) ()
-#define ET_VARARGS
-#endif
typedef long errcode_t;
-typedef void (*et_old_error_hook_func) ET_P((const char FAR *, errcode_t,
- const char FAR *, va_list ap));
+typedef void (*et_old_error_hook_func) (const char FAR *, errcode_t,
+ const char FAR *, va_list ap);
struct error_table {
/*@shared@*/ char const FAR * const FAR * msgs;
unsigned int n_msgs;
};
+/* These are for INTERNAL USE ONLY! Don't rely on them, we're trying
+ to eliminate them. They're currently used for some internal stuff
+ in generated files. */
+struct et_list {
+ /*@dependent@*//*@null@*/ struct et_list *next;
+ /*@dependent@*//*@null@*/ const struct error_table FAR *table;
+};
+#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)
+/*@null@*//*@dependent@*/ extern struct et_list * _et_list;
+#endif
+/* end INTERNAL stuff */
+
#ifdef __cplusplus
extern "C" {
#endif
+/* Public interfaces */
KRB5_DLLIMP extern void KRB5_CALLCONV_C com_err
- ET_STDARG_P((const char FAR *, errcode_t, const char FAR *, ...));
+ (const char FAR *, errcode_t, const char FAR *, ...);
KRB5_DLLIMP extern void KRB5_CALLCONV com_err_va
- ET_P((const char FAR *whoami, errcode_t code, const char FAR *fmt,
- va_list ap));
+ (const char FAR *whoami, errcode_t code, const char FAR *fmt,
+ va_list ap);
KRB5_DLLIMP extern /*@observer@*//*@dependent@*/ const char FAR * KRB5_CALLCONV error_message
- ET_P((errcode_t))
+ (errcode_t)
/*@modifies internalState@*/;
KRB5_DLLIMP extern errcode_t KRB5_CALLCONV add_error_table
- ET_P((const struct error_table FAR *));
+ (/*@dependent@*/ const struct error_table FAR *);
KRB5_DLLIMP extern errcode_t KRB5_CALLCONV remove_error_table
- ET_P((const struct error_table FAR *));
+ (const struct error_table FAR *);
#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)
/*
* applications under non-Unix environments.
*/
-extern et_old_error_hook_func set_com_err_hook
- ET_P((et_old_error_hook_func));
-extern et_old_error_hook_func reset_com_err_hook
- ET_P((void));
+extern et_old_error_hook_func set_com_err_hook (et_old_error_hook_func);
+extern et_old_error_hook_func reset_com_err_hook (void);
#endif
#ifdef __cplusplus
}
#endif
-#if defined(macintosh) && defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
-#pragma import reset
-#endif
-
#define __COM_ERR_H
#endif /* ! defined(__COM_ERR_H) */
static char buffer[ET_EBUFSIZ];
#if (defined(_MSDOS) || defined(_WIN32) || defined(macintosh))
-static struct et_list * _et_list = (struct et_list *) NULL;
+/*@null@*/ static struct et_list * _et_list = (struct et_list *) NULL;
#else
/* Old interface compatibility */
-struct et_list * _et_list = (struct et_list *) NULL;
+/*@null@*/ struct et_list * _et_list = (struct et_list *) NULL;
#endif
/*@null@*//*@only@*/static struct dynamic_et_list * et_list_dynamic;
dprintf (("scanning static list for %x\n", table_num));
for (et = _et_list; et != NULL; et = et->next) {
+ if (et->table == NULL)
+ continue;
dprintf (("\t%x = %s\n", et->table->base & ERRCODE_MAX,
et->table->msgs[0]));
if ((et->table->base & ERRCODE_MAX) == table_num) {
wouldn't check the dynamically maintained list before adding an
entry to the static list. */
for (el = _et_list; el != NULL; el = el->next)
- if (el->table->base == et->base)
+ if (el->table != NULL && el->table->base == et->base)
return EEXIST;
for (del = et_list_dynamic; del != NULL; del = del->next)
if (del->table->base == et->base)
break;
}
for (el = &_et_list; *el; el = &(*el)->next)
- if ((*el)->table->base == et->base) {
+ if ((*el)->table != NULL && (*el)->table->base == et->base) {
struct et_list *old = *el;
*el = old->next;
old->next = NULL;
#define ET_EBUFSIZ 64
#endif
-struct et_list {
- /*@dependent@*//*@null@*/ struct et_list *next;
- /*@dependent@*/ const struct error_table FAR *table;
-};
-
struct dynamic_et_list {
/*@only@*//*@null@*/ struct dynamic_et_list *next;
/*@dependent@*/ const struct error_table FAR *table;
};
-#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)
-/*@null@*//*@dependent@*/ extern struct et_list * _et_list;
-#endif
-
#define ERRCODE_RANGE 8 /* # of bits to shift table number */
#define BITS_PER_CHAR 6 /* # bits to shift per character in name */
#define ERRCODE_MAX 0xFFFFFFFFUL /* Mask for maximum error table */
-extern /*@observer@*/ const char FAR *error_table_name ET_P((unsigned long))
+extern /*@observer@*/ const char FAR *error_table_name (unsigned long)
/*@modifies internalState@*/;
extern const char FAR *error_table_name_r (unsigned long,
- /*@out@*/ /*@returned@*/ char FAR *outbuf)
+ /*@out@*/ /*@returned@*/ char FAR *outbuf)
/*@modifies outbuf@*/;
#define _ET_H
print " */" > outfile
print "#if defined(_MSDOS) || defined(_WIN32)" > outfile
- print "#include \"win-mac.h\"" > outfile
+ print "# include \"win-mac.h\"" > outfile
print "#else" > outfile
- print "# ifndef KRB5_CALLCONV" > outfile
- print "# define KRB5_CALLCONV" > outfile
- print "# define KRB5_CALLCONV_C" > outfile
- print "# define KRB5_DLLIMP" > outfile
- print "# define KRB5_EXPORTVAR" > outfile
print "# define FAR" > outfile
- print "# define NEAR" > outfile
- print "# endif" > outfile
print "#endif" > outfile
print "" > outfile
-
- print "#if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32)" > outfile
- print "#define P(x) x" > outfile
- print "#define NOARGS void" > outfile
- print "#else" > outfile
- print "#define P(x) ()" > outfile
- print "#define NOARGS" > outfile
- print "#define const" > outfile
- print "#endif" > outfile
+ print "extern void initialize_" table_name "_error_table (void);" > outfile
print "" > outfile
- print "extern void initialize_" table_name "_error_table (NOARGS);" > outfile
+ print "/* Lclint doesn't handle null annotations on arrays" > outfile
+ print " properly, so we need this typedef in each" > outfile
+ print " generated .c file. */" > outfile
+ print "/*@-redef@*/" > outfile
+ print "typedef /*@null@*/ const char FAR *ncptr;" > outfile
+ print "/*@=redef@*/" > outfile
print "" > outfile
- print "static const char FAR * const text[] = {" > outfile
+ print "static ncptr const text[] = {" > outfile
table_item_count = 0
}
print " 0" > outfile
print "};" > outfile
print "" > outfile
- print "struct error_table {" > outfile
- print " char const FAR * const FAR * msgs;" > outfile
- print " long base;" > outfile
- print " int n_msgs;" > outfile
- print "};" > outfile
+ print "#include <com_err.h>" > outfile
print "" > outfile
if (tab_base_high == 0) {
print "const struct error_table et_" table_name "_error_table = { text, " \
}
print "" > outfile
print "#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)" > outfile
- print "struct et_list {" > outfile
- print " struct et_list *next;" > outfile
- print " const struct error_table * table;" > outfile
- print "};" > outfile
- print "extern struct et_list *_et_list;" > outfile
print "static struct et_list link = { 0, 0 };" > outfile
- print "void initialize_" table_name "_error_table (NOARGS) {" > outfile
+ print "void initialize_" table_name "_error_table (void) {" > outfile
print " if (!link.table) {" > outfile
print " link.next = _et_list;" > outfile
print " link.table = &et_" table_name "_error_table;" > outfile
-#!/afs/athena/contrib/perl5/p
-eval 'exec /afs/athena/contrib/perl5/arch/sun4x_55/bin/perl -S $0 ${1+"$@"}'
+#!/usr/athena/bin/perl
+eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)
$c2n{'_'} = 63;
line: while (<>) {
- chop; # strip record separator
- @Fld = split(' ', $_, 9999);
+ chomp; # strip record separator
+ @Fld = split($FS, $_, 9999);
if (/^#/) {
next line;
}
&Pick('>', $outfile) &&
(print $fh '#if defined(_MSDOS) || defined(_WIN32)');
&Pick('>', $outfile) &&
- (print $fh "#include \"win-mac.h\"");
+ (print $fh "# include \"win-mac.h\"");
&Pick('>', $outfile) &&
(print $fh '#else');
- &Pick('>', $outfile) &&
- (print $fh '# ifndef KRB5_CALLCONV');
- &Pick('>', $outfile) &&
- (print $fh '# define KRB5_CALLCONV');
- &Pick('>', $outfile) &&
- (print $fh '# define KRB5_CALLCONV_C');
- &Pick('>', $outfile) &&
- (print $fh '# define KRB5_DLLIMP');
- &Pick('>', $outfile) &&
- (print $fh '# define KRB5_EXPORTVAR');
&Pick('>', $outfile) &&
(print $fh '# define FAR');
- &Pick('>', $outfile) &&
- (print $fh '# define NEAR');
- &Pick('>', $outfile) &&
- (print $fh '# endif');
&Pick('>', $outfile) &&
(print $fh '#endif');
&Pick('>', $outfile) &&
(print $fh '');
-
&Pick('>', $outfile) &&
- (print $fh
+ (print $fh 'extern void initialize_' . $table_name .
- '#if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32)');
+ '_error_table (void);');
+ &Pick('>', $outfile) &&
+ (print $fh '');
&Pick('>', $outfile) &&
- (print $fh '#define P(x) x');
+ (print $fh "/* Lclint doesn't handle null annotations on arrays");
&Pick('>', $outfile) &&
- (print $fh '#else');
+ (print $fh ' properly, so we need this typedef in each');
&Pick('>', $outfile) &&
- (print $fh '#define P(x) ()');
+ (print $fh ' generated .c file. */');
&Pick('>', $outfile) &&
- (print $fh '#define const');
+ (print $fh '/*@-redef@*/');
&Pick('>', $outfile) &&
- (print $fh '#endif');
+ (print $fh 'typedef /*@null@*/ const char FAR *ncptr;');
+ &Pick('>', $outfile) &&
+ (print $fh '/*@=redef@*/');
&Pick('>', $outfile) &&
(print $fh '');
&Pick('>', $outfile) &&
- (print $fh 'static const char FAR * const text[] = {');
+ (print $fh 'static ncptr const text[] = {');
$table_item_count = 0;
}
&Pick('>', $outfile) &&
(print $fh '');
&Pick('>', $outfile) &&
- (print $fh 'struct error_table {');
-&Pick('>', $outfile) &&
- (print $fh ' char const FAR * const FAR * msgs;');
-&Pick('>', $outfile) &&
- (print $fh ' long base;');
-&Pick('>', $outfile) &&
- (print $fh ' int n_msgs;');
-&Pick('>', $outfile) &&
- (print $fh '};');
+ (print $fh '#include <com_err.h>');
&Pick('>', $outfile) &&
(print $fh '');
if ($tab_base_high == 0) {
&Pick('>', $outfile) &&
(print $fh '');
&Pick('>', $outfile) &&
- (print $fh '#if defined(unix) || defined(_AIX)');
-&Pick('>', $outfile) &&
- (print $fh 'struct et_list {');
-&Pick('>', $outfile) &&
- (print $fh ' struct et_list *next;');
-&Pick('>', $outfile) &&
- (print $fh ' const struct error_table * table;');
-&Pick('>', $outfile) &&
- (print $fh '};');
-&Pick('>', $outfile) &&
- (print $fh 'extern struct et_list *_et_list;');
+ (print $fh
+
+ '#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)');
&Pick('>', $outfile) &&
(print $fh 'static struct et_list link = { 0, 0 };');
&Pick('>', $outfile) &&
- (print $fh 'void initialize_' . $table_name . '_error_table (NOARGS) {');
+ (print $fh 'void initialize_' . $table_name . '_error_table (void) {');
&Pick('>', $outfile) &&
(print $fh ' if (!link.table) {');
&Pick('>', $outfile) &&
-#!/afs/athena/contrib/perl5/p
-eval 'exec /afs/athena/contrib/perl5/arch/sun4x_55/bin/perl -S $0 ${1+"$@"}'
+#!/usr/athena/bin/perl
+eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)
&Pick('>', $outfile) &&
(print $fh '');
&Pick('>', $outfile) &&
- (print $fh '#if defined(unix) || defined(_AIX)');
+ (print $fh
+
+ '#if !defined(_MSDOS) && !defined(_WIN32) && !defined(macintosh)');
&Pick('>', $outfile) &&
(print $fh '/* for compatibility with older versions... */');
&Pick('>', $outfile) &&
- (print $fh 'extern void initialize_' . $table_name . '_error_table ();');
+ (print $fh 'extern void initialize_' . $table_name .
+
+ '_error_table () /*@modifies internalState@*/;');
&Pick('>', $outfile) &&
(print $fh '#define init_' . $table_name . '_err_tbl initialize_' .
#include <stdio.h>
+#include <string.h>
#include "com_err.h"
#include "et1.h"
#include "et2.h"
char buffy[1024];
sprintf (buffy, "error table %d message %d", table, msgno);
- if (!strcmp (buffy, msg)) {
+ if (0 == strcmp (buffy, msg)) {
if (!known) {
known_err++;
}
}
#define try_em(A,B) try_em_1(A,B,__LINE__)
-int main (int argc, char *argv[])
+int main (/*@unused@*/ int argc, /*@unused@*/ char *argv[])
{
try_em (0, 0);
- add_error_table (&et_et1_error_table);
+ (void) add_error_table (&et_et1_error_table);
try_em (1, 0);
- add_error_table (&et_et2_error_table);
+ (void) add_error_table (&et_et2_error_table);
try_em (1, 1);
- remove_error_table (&et_et1_error_table);
+ (void) remove_error_table (&et_et1_error_table);
try_em (0, 1);
- remove_error_table (&et_et1_error_table);
+ (void) remove_error_table (&et_et1_error_table);
try_em (0, 1);
- remove_error_table (&et_et2_error_table);
+ (void) remove_error_table (&et_et2_error_table);
try_em (0, 0);
initialize_et1_error_table ();
try_em (1, 0);
- add_error_table (&et_et1_error_table);
+ (void) add_error_table (&et_et1_error_table);
try_em (1, 0);
- remove_error_table (&et_et1_error_table);
+ (void) remove_error_table (&et_et1_error_table);
try_em (0, 0);
initialize_et1_error_table ();
try_em (1, 0);
- add_error_table (&et_et1_error_table);
+ (void) add_error_table (&et_et1_error_table);
try_em (1, 0);
- add_error_table (&et_et2_error_table);
+ (void) add_error_table (&et_et2_error_table);
try_em (1, 1);
- remove_error_table (&et_et1_error_table);
+ (void) remove_error_table (&et_et1_error_table);
try_em (0, 1);
- remove_error_table (&et_et2_error_table);
+ (void) remove_error_table (&et_et2_error_table);
try_em (0, 0);
- remove_error_table (&et_et2_error_table);
+ (void) remove_error_table (&et_et2_error_table);
try_em (0, 0);
- add_error_table (&et_et2_error_table);
+ (void) add_error_table (&et_et2_error_table);
try_em (0, 1);
initialize_et2_error_table ();
try_em (0, 1);
- add_error_table (&et_et1_error_table);
+ (void) add_error_table (&et_et1_error_table);
try_em (1, 1);
- remove_error_table (&et_et1_error_table);
+ (void) remove_error_table (&et_et1_error_table);
try_em (0, 1);
- remove_error_table (&et_et2_error_table);
+ (void) remove_error_table (&et_et2_error_table);
try_em (0, 0);
return fail;