From: Todd C. Miller Date: Sat, 27 Feb 2010 14:26:43 +0000 (-0500) Subject: Convert to ANSI C X-Git-Tag: SUDO_1_8_0~863 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=841807dd66d0619548c2827f80bdf6548de17995;p=sudo Convert to ANSI C --- diff --git a/include/alloc.h b/include/alloc.h index 7442fe8c1..ef9d7c27a 100644 --- a/include/alloc.h +++ b/include/alloc.h @@ -17,8 +17,8 @@ #ifndef _SUDO_ALLOC_H #define _SUDO_ALLOC_H -#ifdef __STDC__ -# include +#include + int easprintf(char **, const char *, ...) __printflike(2, 3); int evasprintf(char **, const char *, va_list) __printflike(2, 0); void efree(void *); @@ -27,16 +27,5 @@ void *emalloc2(size_t, size_t); void *erealloc(void *, size_t); void *erealloc3(void *, size_t, size_t); char *estrdup(const char *); -#else -# include -int easprintf(); -int evasprintf(); -void efree(); -void *emalloc(); -void *emalloc2(); -void *erealloc(); -void *erealloc3(); -char *estrdup(); -#endif /* __STDC__ */ #endif /* _SUDO_ALLOC_H */ diff --git a/include/compat.h b/include/compat.h index 808ada367..4641f3b96 100644 --- a/include/compat.h +++ b/include/compat.h @@ -26,15 +26,6 @@ * Macros that may be missing on some Operating Systems */ -/* Deal with ANSI stuff reasonably. */ -#ifndef __P -# if defined (__cplusplus) || defined (__STDC__) -# define __P(args) args -# else -# define __P(args) () -# endif -#endif /* __P */ - /* Define away __attribute__ for non-gcc or old gcc */ #if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5 # define __attribute__(x) @@ -154,7 +145,7 @@ * Simple isblank() macro and function for systems without it. */ #ifndef HAVE_ISBLANK -int isblank __P((int)); +int isblank(int); # define isblank(_x) ((_x) == ' ' || (_x) == '\t') #endif @@ -202,13 +193,13 @@ int isblank __P((int)); # define sa_flags sv_flags typedef struct sigvec sigaction_t; typedef int sigset_t; -int sigaction __P((int sig, const sigaction_t *act, sigaction_t *oact)); -int sigemptyset __P((sigset_t *)); -int sigfillset __P((sigset_t *)); -int sigaddset __P((sigset_t *, int)); -int sigdelset __P((sigset_t *, int)); -int sigismember __P((sigset_t *, int)); -int sigprocmask __P((int, const sigset_t *, sigset_t *)); +int sigaction(int sig, const sigaction_t *act, sigaction_t *oact); +int sigemptyset(sigset_t *); +int sigfillset(sigset_t *); +int sigaddset(sigset_t *, int); +int sigdelset(sigset_t *, int); +int sigismember(sigset_t *, int); +int sigprocmask(int, const sigset_t *, sigset_t *); #endif /* @@ -256,7 +247,7 @@ typedef struct sigaction sigaction_t; extern const char *__progname; # define getprogname() (__progname) # else -const char *getprogname __P((void)); +const char *getprogname(void); #endif /* HAVE___PROGNAME */ #endif /* !HAVE_GETPROGNAME */ diff --git a/include/error.h b/include/error.h index 5ac307600..563aeb81f 100644 --- a/include/error.h +++ b/include/error.h @@ -17,18 +17,11 @@ #ifndef _SUDO_ERROR_H_ #define _SUDO_ERROR_H_ -#ifdef __STDC__ -# include +#include + void error(int, const char *, ...) __attribute__((__noreturn__)); void errorx(int, const char *, ...) __attribute__((__noreturn__)); void warning(const char *, ...); void warningx(const char *, ...); -#else -# include -void error() __attribute__((__noreturn__)); -void errorx() __attribute__((__noreturn__)); -void warning(); -void warningx(); -#endif /* __STDC__ */ #endif /* _SUDO_ERROR_H_ */ diff --git a/include/lbuf.h b/include/lbuf.h index fbc9fdc00..76ca0f223 100644 --- a/include/lbuf.h +++ b/include/lbuf.h @@ -30,10 +30,10 @@ struct lbuf { int size; }; -void lbuf_init __P((struct lbuf *, char *, int, int)); -void lbuf_destroy __P((struct lbuf *)); -void lbuf_append __P((struct lbuf *, ...)); -void lbuf_append_quoted __P((struct lbuf *, const char *, ...)); -void lbuf_print __P((struct lbuf *)); +void lbuf_init (struct lbuf *, char *, int, int); +void lbuf_destroy (struct lbuf *); +void lbuf_append (struct lbuf *, ...); +void lbuf_append_quoted (struct lbuf *, const char *, ...); +void lbuf_print (struct lbuf *); #endif /* _SUDO_LBUF_H */ diff --git a/include/list.h b/include/list.h index 17aab415b..b2842ec65 100644 --- a/include/list.h +++ b/include/list.h @@ -20,19 +20,11 @@ /* * Convenience macro for declaring a list head. */ -#ifdef __STDC__ #define TQ_DECLARE(n) \ struct n##_list { \ struct n *first; \ struct n *last; \ }; -#else -#define TQ_DECLARE(n) \ -struct n/**/_list { \ - struct n *first; \ - struct n *last; \ -}; -#endif /* * Foreach loops: forward and reverse @@ -75,9 +67,9 @@ struct n/**/_list { \ /* * Prototypes for list.c */ -void *tq_pop __P((void *)); -void tq_append __P((void *, void *)); -void list_append __P((void *, void *)); -void list2tq __P((void *, void *)); +void *tq_pop (void *); +void tq_append (void *, void *); +void list_append (void *, void *); +void list2tq (void *, void *); #endif /* _SUDO_LIST_H */ diff --git a/include/missing.h b/include/missing.h index 5e38ede2e..7f276d72b 100644 --- a/include/missing.h +++ b/include/missing.h @@ -23,62 +23,58 @@ struct timeval; struct timespec; #ifndef HAVE_CLOSEFROM -void closefrom __P((int)); +void closefrom(int); #endif #ifndef HAVE_GETCWD -char *getcwd __P((char *, size_t size)); +char *getcwd(char *, size_t size); #endif #ifndef HAVE_GETLINE -ssize_t getline __P((char **, size_t *, FILE *)); +ssize_t getline(char **, size_t *, FILE *); #endif #ifndef HAVE_UTIMES -int utimes __P((const char *, const struct timeval *)); +int utimes(const char *, const struct timeval *); #endif #ifdef HAVE_FUTIME -int futimes __P((int, const struct timeval *)); +int futimes(int, const struct timeval *); #endif #ifndef HAVE_SNPRINTF -int snprintf __P((char *, size_t, const char *, ...)) - __printflike(3, 4); +int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); #endif #ifndef HAVE_VSNPRINTF -int vsnprintf __P((char *, size_t, const char *, va_list)) - __printflike(3, 0); +int vsnprintf(char *, size_t, const char *, va_list) __printflike(3, 0); #endif #ifndef HAVE_ASPRINTF -int asprintf __P((char **, const char *, ...)) - __printflike(2, 3); +int asprintf(char **, const char *, ...) __printflike(2, 3); #endif #ifndef HAVE_VASPRINTF -int vasprintf __P((char **, const char *, va_list)) - __printflike(2, 0); +int vasprintf(char **, const char *, va_list) __printflike(2, 0); #endif #ifndef HAVE_STRCASECMP -int strcasecmp __P((const char *, const char *)); +int strcasecmp(const char *, const char *); #endif #ifndef HAVE_STRLCAT -size_t strlcat __P((char *, const char *, size_t)); +size_t strlcat(char *, const char *, size_t); #endif #ifndef HAVE_STRLCPY -size_t strlcpy __P((char *, const char *, size_t)); +size_t strlcpy(char *, const char *, size_t); #endif #ifndef HAVE_MEMRCHR -void *memrchr __P((const void *, int, size_t)); +void *memrchr(const void *, int, size_t); #endif #ifndef HAVE_MKSTEMP -int mkstemp __P((char *)); +int mkstemp(char *); #endif #ifndef HAVE_NANOSLEEP -int nanosleep __P((const struct timespec *, struct timespec *)); +int nanosleep(const struct timespec *, struct timespec *); #endif #ifndef HAVE_SETENV -int setenv __P((const char *, const char *, int)); +int setenv(const char *, const char *, int); #endif #ifndef HAVE_UNSETENV -int unsetenv __P((const char *)); +int unsetenv(const char *); #endif #ifdef HAVE_SYS_SIGLIST -char *strsignal __P((int)); +char *strsignal(int); #endif #endif /* _SUDO_MISSING_H */