Subject: Re: CVS commit: basesrc
To: None <>
From: Christos Zoulas <>
List: source-changes
Date: 10/21/2000 02:16:34
In article <>,
Allen Briggs <> wrote:

> Add {__,}fmtcheck(), a function specified by Bill Sommerfeld to check
> a user-supplied format string against a fallback format string to ensure
> that they will consume arguments of the same type.

Very cool. Two questions:
1. why there is a /*NOTREACHED*/ at the end of the static functions?
2. It might be nice if there was code in it to log an error, and mention
   in the man page that it sets errno to EFTYPE if there are no matches?

#include <errno.h>
#ifdef __AUDIT__
#include <err.h>

__const char *
__fmtcheck(const char *f1, const char *f2)
	const char	*f1p, *f2p;
	EFT		f1t, f2t;

	if (!f1) return f2;
	f1p = f1;
	f2p = f2;
	while ((f1t = get_next_format(&f1p, f1t)) != FMTCHECK_DONE) {
		if (f1t == FMTCHECK_UNKNOWN)
			goto bad;
		f2t = get_next_format(&f2p, f2t);
		if (f1t != f2t)
			goto bad;
	return f1;
	errno = EFTYPE;
#ifdef __AUDIT__
	warn("Mismatched user format string `%s', does not match with `%s' ",
	    f1, f2);
	return f2;