aboutsummaryrefslogtreecommitdiff
path: root/src/libeinfo
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-10-08 15:56:47 +0000
committerRoy Marples <roy@marples.name>2008-10-08 15:56:47 +0000
commit8c8751fa60b529d190ca85857096cf741b0436de (patch)
tree4913d50a861ff45947d26fa75a29a97945536223 /src/libeinfo
parent5cdc4895733ce3a723a5a58686a4d92a3c69c953 (diff)
Clean up warnings regarding printf.
Diffstat (limited to 'src/libeinfo')
-rw-r--r--src/libeinfo/einfo.h66
-rw-r--r--src/libeinfo/libeinfo.c63
2 files changed, 63 insertions, 66 deletions
diff --git a/src/libeinfo/einfo.h b/src/libeinfo/einfo.h
index 3934b582..9c54e688 100644
--- a/src/libeinfo/einfo.h
+++ b/src/libeinfo/einfo.h
@@ -28,13 +28,11 @@
#define __EINFO_H__
#if defined(__GNUC__)
-# define __EINFO_PRINTF __attribute__ ((__format__ (__printf__, 1, 2)))
-# define __EINFO_XPRINTF __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)))
-# define __EEND_PRINTF __attribute__ ((__format__ (__printf__, 2, 3)))
+# define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
+# define EINFO_XPRINTF(a, b) __attribute__((__noreturn__,__format__(__printf__, a, b)))
#else
-# define __EINFO_PRINTF
-# define __EINFO_XPRINTF
-# define __EEND_PRINTF
+# define EINFO_PRINTF(a, b)
+# define EINFO_XPRINTF(a, b)
#endif
#include <sys/types.h>
@@ -42,12 +40,12 @@
/* Although OpenRC requires C99, linking to us should not. */
#ifdef restrict
-# define __EINFO_RESTRICT restrict
+# define EINFO_RESTRICT restrict
#else
# ifdef __restrict
-# define __EINFO_RESTRICT __restrict
+# define EINFO_RESTRICT __restrict
# else
-# define __EINFO_RESTRICT
+# define EINFO_RESTRICT
# endif
#endif
@@ -68,7 +66,7 @@ typedef enum
const char *ecolor(ECOLOR);
/*! @brief Writes to syslog. */
-void elog(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
+void elog(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
/*!
* @brief Display informational messages.
@@ -86,22 +84,22 @@ void elog(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
* The v suffix means only print if EINFO_VERBOSE is yes.
*/
/*@{*/
-int einfon(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ewarnn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int eerrorn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int einfo(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ewarn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-void ewarnx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF;
-int eerror(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-void eerrorx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF;
-
-int einfovn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ewarnvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ebeginvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int eendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
-int ewendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
-int einfov(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ewarnv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
+int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
+int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
+
+int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
+int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
+int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
/*@}*/
/*! @ingroup ebegin
@@ -109,8 +107,8 @@ int ewarnv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
*
* Similar to einfo, but we add ... to the end of the message */
/*@{*/
-int ebeginv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
-int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
+int ebeginv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
+int ebegin(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
/*@}*/
/*! @ingroup eend
@@ -122,12 +120,12 @@ int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
*
* ebracket allows you to specifiy the position, color and message */
/*@{*/
-int eend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
-int ewend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
-void ebracket(int, ECOLOR, const char * __EINFO_RESTRICT);
+int eend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
+int ewend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
+void ebracket(int, ECOLOR, const char * EINFO_RESTRICT);
-int eendv(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
-int ewendv(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
+int eendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
+int ewendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
/*@}*/
/*! @ingroup eindent
@@ -141,7 +139,7 @@ void eindentv(void);
void eoutdentv(void);
/*! @brief Prefix each einfo line with something */
-void eprefix(const char * __EINFO_RESTRICT);
+void eprefix(const char * EINFO_RESTRICT);
__END_DECLS
#endif
diff --git a/src/libeinfo/libeinfo.c b/src/libeinfo/libeinfo.c
index bef98a5d..66b6dbc2 100644
--- a/src/libeinfo/libeinfo.c
+++ b/src/libeinfo/libeinfo.c
@@ -316,7 +316,7 @@ tgoto(const char *cap, int a, int b)
#endif
static bool
-colour_terminal(FILE * __EINFO_RESTRICT f)
+colour_terminal(FILE * EINFO_RESTRICT f)
{
static int in_colour = -1;
char *e, *ee, *end, *d, *p;
@@ -460,7 +460,7 @@ colour_terminal(FILE * __EINFO_RESTRICT f)
}
static int
-get_term_columns(FILE * __EINFO_RESTRICT stream)
+get_term_columns(FILE * EINFO_RESTRICT stream)
{
struct winsize ws;
char *env = getenv("COLUMNS");
@@ -480,14 +480,14 @@ get_term_columns(FILE * __EINFO_RESTRICT stream)
}
void
-eprefix(const char *__EINFO_RESTRICT prefix)
+eprefix(const char *EINFO_RESTRICT prefix)
{
_eprefix = prefix;
}
hidden_def(eprefix)
-static void
-elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
+static void EINFO_PRINTF(2, 0)
+elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
{
char *e = getenv("EINFO_LOG");
va_list apc;
@@ -503,7 +503,7 @@ elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
}
void
-elog(int level, const char *__EINFO_RESTRICT fmt, ...)
+elog(int level, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -514,7 +514,7 @@ elog(int level, const char *__EINFO_RESTRICT fmt, ...)
hidden_def(elog)
static int
-_eindent(FILE * __EINFO_RESTRICT stream)
+_eindent(FILE * EINFO_RESTRICT stream)
{
char *env = getenv("EINFO_INDENT");
int amount = 0;
@@ -538,7 +538,7 @@ _eindent(FILE * __EINFO_RESTRICT stream)
}
static const char *
-_ecolor(FILE * __EINFO_RESTRICT f, ECOLOR color)
+_ecolor(FILE * EINFO_RESTRICT f, ECOLOR color)
{
unsigned int i;
@@ -575,9 +575,8 @@ ecolor(ECOLOR color)
setenv("EINFO_LASTCMD", _cmd, 1); \
}
-static int
-_einfo(FILE *f, ECOLOR color, const char *__EINFO_RESTRICT fmt, va_list va)
-
+static int EINFO_PRINTF(3, 0)
+_einfo(FILE *f, ECOLOR color, const char *EINFO_RESTRICT fmt, va_list va)
{
int retval = 0;
char *last = getenv("EINFO_LASTCMD");
@@ -605,7 +604,7 @@ _einfo(FILE *f, ECOLOR color, const char *__EINFO_RESTRICT fmt, va_list va)
#define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap)
int
-einfon(const char *__EINFO_RESTRICT fmt, ...)
+einfon(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -621,7 +620,7 @@ einfon(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(einfon)
int
-ewarnn(const char *__EINFO_RESTRICT fmt, ...)
+ewarnn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -637,7 +636,7 @@ ewarnn(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ewarnn)
int
-eerrorn(const char *__EINFO_RESTRICT fmt, ...)
+eerrorn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -651,7 +650,7 @@ eerrorn(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(eerrorn)
int
-einfo(const char *__EINFO_RESTRICT fmt, ...)
+einfo(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -668,7 +667,7 @@ einfo(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(einfo)
int
-ewarn(const char *__EINFO_RESTRICT fmt, ...)
+ewarn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -686,7 +685,7 @@ ewarn(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ewarn)
void
-ewarnx(const char *__EINFO_RESTRICT fmt, ...)
+ewarnx(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -703,7 +702,7 @@ ewarnx(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ewarnx)
int
-eerror(const char *__EINFO_RESTRICT fmt, ...)
+eerror(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -721,7 +720,7 @@ eerror(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(eerror)
void
-eerrorx(const char *__EINFO_RESTRICT fmt, ...)
+eerrorx(const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -737,7 +736,7 @@ eerrorx(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(eerrorx)
int
-ebegin(const char *__EINFO_RESTRICT fmt, ...)
+ebegin(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -756,7 +755,7 @@ ebegin(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ebegin)
static void
-_eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
+_eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
{
int i;
int cols;
@@ -793,8 +792,8 @@ _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
}
}
-static int
-_do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fmt, va_list ap)
+static int EINFO_PRINTF(3, 0)
+_do_eend(const char *cmd, int retval, const char *EINFO_RESTRICT fmt, va_list ap)
{
int col = 0;
FILE *fp = stdout;
@@ -817,7 +816,7 @@ _do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fmt, va_list
}
int
-eend(int retval, const char *__EINFO_RESTRICT fmt, ...)
+eend(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -832,7 +831,7 @@ eend(int retval, const char *__EINFO_RESTRICT fmt, ...)
hidden_def(eend)
int
-ewend(int retval, const char *__EINFO_RESTRICT fmt, ...)
+ewend(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -900,7 +899,7 @@ void eoutdent(void)
hidden_def(eoutdent)
int
-einfovn(const char *__EINFO_RESTRICT fmt, ...)
+einfovn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -916,7 +915,7 @@ einfovn(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(einfovn)
int
-ewarnvn(const char *__EINFO_RESTRICT fmt, ...)
+ewarnvn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -932,7 +931,7 @@ ewarnvn(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ewarnvn)
int
-einfov(const char *__EINFO_RESTRICT fmt, ...)
+einfov(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -949,7 +948,7 @@ einfov(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(einfov)
int
-ewarnv(const char *__EINFO_RESTRICT fmt, ...)
+ewarnv(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -966,7 +965,7 @@ ewarnv(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ewarnv)
int
-ebeginv(const char *__EINFO_RESTRICT fmt, ...)
+ebeginv(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -986,7 +985,7 @@ ebeginv(const char *__EINFO_RESTRICT fmt, ...)
hidden_def(ebeginv)
int
-eendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
+eendv(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -1001,7 +1000,7 @@ eendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
hidden_def(eendv)
int
-ewendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
+ewendv(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;