From: Todd C. Miller Date: Sat, 27 Feb 2010 14:29:59 +0000 (-0500) Subject: Convert to ANSI C X-Git-Tag: SUDO_1_8_0~862 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ec040b541be08bc040f8e76787bc55d8ad3aa09;p=sudo Convert to ANSI C --- diff --git a/src/alloc.c b/src/alloc.c index d8bd857ce..83997f54d 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -171,22 +171,11 @@ estrdup(src) * returns -1 (out of memory). */ int -#ifdef __STDC__ easprintf(char **ret, const char *fmt, ...) -#else -easprintf(ret, fmt, va_alist) - char **ret; - const char *fmt; - va_dcl -#endif { int len; va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif len = vasprintf(ret, fmt, ap); va_end(ap); diff --git a/src/audit.c b/src/audit.c index 59ea5262e..0fc4a727a 100644 --- a/src/audit.c +++ b/src/audit.c @@ -26,11 +26,7 @@ # include # endif #endif /* STDC_HEADERS */ -#ifdef __STDC__ -# include -#else -# include -#endif +#include #include "compat.h" #include "logging.h" @@ -40,12 +36,7 @@ #endif void -#ifdef __STDC__ audit_success(char **exec_args) -#else -audit_success(exec_args) - const char **exec_args; -#endif { #ifdef HAVE_BSM_AUDIT bsm_audit_success(exec_args); @@ -53,22 +44,11 @@ audit_success(exec_args) } void -#ifdef __STDC__ audit_failure(char **exec_args, char const *const fmt, ...) -#else -audit_failure(exec_args, fmt, va_alist) - const char **exec_args; - char const *const fmt; - va_dcl -#endif { va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif #ifdef HAVE_BSM_AUDIT bsm_audit_failure(exec_args, fmt, ap); #endif diff --git a/src/error.c b/src/error.c index 317f10561..0f33cde49 100644 --- a/src/error.c +++ b/src/error.c @@ -23,25 +23,14 @@ #include #include "error.h" -static void _warning __P((int, const char *, va_list)); - void cleanup __P((int)); +static void _warning(int, const char *, va_list); + void cleanup(int); void -#ifdef __STDC__ error(int eval, const char *fmt, ...) -#else -error(eval, fmt, va_alist) - int eval; - const char *fmt; - va_dcl -#endif { va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif _warning(1, fmt, ap); va_end(ap); cleanup(0); @@ -49,21 +38,10 @@ error(eval, fmt, va_alist) } void -#ifdef __STDC__ errorx(int eval, const char *fmt, ...) -#else -errorx(eval, fmt, va_alist) - int eval; - const char *fmt; - va_dcl -#endif { va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif _warning(0, fmt, ap); va_end(ap); cleanup(0); @@ -71,39 +49,19 @@ errorx(eval, fmt, va_alist) } void -#ifdef __STDC__ warning(const char *fmt, ...) -#else -warning(fmt, va_alist) - const char *fmt; - va_dcl -#endif { va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif _warning(1, fmt, ap); va_end(ap); } void -#ifdef __STDC__ warningx(const char *fmt, ...) -#else -warningx(fmt, va_alist) - const char *fmt; - va_dcl -#endif { va_list ap; -#ifdef __STDC__ va_start(ap, fmt); -#else - va_start(ap); -#endif _warning(0, fmt, ap); va_end(ap); } diff --git a/src/lbuf.c b/src/lbuf.c index 72faf21d0..b9ef3eaff 100644 --- a/src/lbuf.c +++ b/src/lbuf.c @@ -107,24 +107,13 @@ lbuf_destroy(lbuf) * Append strings to the buffer, expanding it as needed. */ void -#ifdef __STDC__ lbuf_append_quoted(struct lbuf *lbuf, const char *set, ...) -#else -lbuf_append_quoted(lbuf, set, va_alist) - struct lbuf *lbuf; - const char *set; - va_dcl -#endif { va_list ap; int len = 0; char *cp, *s; -#ifdef __STDC__ va_start(ap, set); -#else - va_start(ap); -#endif while ((s = va_arg(ap, char *)) != NULL) { len += strlen(s); for (cp = s; (cp = strpbrk(cp, set)) != NULL; cp++) @@ -140,11 +129,7 @@ lbuf_append_quoted(lbuf, set, va_alist) lbuf->buf = erealloc(lbuf->buf, lbuf->size); } -#ifdef __STDC__ va_start(ap, set); -#else - va_start(ap); -#endif /* Append each string. */ while ((s = va_arg(ap, char *)) != NULL) { while ((cp = strpbrk(s, set)) != NULL) { @@ -169,23 +154,13 @@ lbuf_append_quoted(lbuf, set, va_alist) * Append strings to the buffer, expanding it as needed. */ void -#ifdef __STDC__ lbuf_append(struct lbuf *lbuf, ...) -#else -lbuf_append(lbuf, va_alist) - struct lbuf *lbuf; - va_dcl -#endif { va_list ap; int len = 0; char *s; -#ifdef __STDC__ va_start(ap, lbuf); -#else - va_start(ap); -#endif while ((s = va_arg(ap, char *)) != NULL) len += strlen(s); va_end(ap); @@ -198,11 +173,7 @@ lbuf_append(lbuf, va_alist) lbuf->buf = erealloc(lbuf->buf, lbuf->size); } -#ifdef __STDC__ va_start(ap, lbuf); -#else - va_start(ap); -#endif /* Append each string. */ while ((s = va_arg(ap, char *)) != NULL) { len = strlen(s); diff --git a/src/sudo_noexec.c b/src/sudo_noexec.c index eff07b9ee..fd2c0a771 100644 --- a/src/sudo_noexec.c +++ b/src/sudo_noexec.c @@ -20,11 +20,7 @@ #ifndef HAVE_TIMESPEC # include #endif -#ifdef __STDC__ -# include -#else -# include -#endif +#include #include @@ -46,8 +42,6 @@ extern int errno; return(-1); \ } -#ifdef __STDC__ - #define DUMMY2(fn, t1, t2) \ int \ fn(t1 a1, t2 a2) \ @@ -63,28 +57,6 @@ int \ fn(t1 a1, t2 a2, ...) \ DUMMY_BODY -#else /* !__STDC__ */ - -#define DUMMY2(fn, t1, t2) \ -int \ -fn(a1, a2) \ -t1 a1; t2 a2; \ -DUMMY_BODY - -#define DUMMY3(fn, t1, t2, t3) \ -int \ -fn(a1, a2, a3) \ -t1 a1; t2 a2; t3 a3; \ -DUMMY_BODY - -#define DUMMY_VA(fn, t1, t2) \ -int \ -fn(a1, a2, va_alist) \ -t1 a1; t2 a2; va_dcl \ -DUMMY_BODY - -#endif /* !__STDC__ */ - DUMMY_VA(execl, const char *, const char *) DUMMY_VA(_execl, const char *, const char *) DUMMY_VA(__execl, const char *, const char *)