From a70f8e1a7e3fcbc13c9a60f8a7409dd01d014afb Mon Sep 17 00:00:00 2001 From: Perry Ruiter Date: Sat, 22 Mar 2014 00:52:32 -0700 Subject: [PATCH] afs: Define afs_warnall routine In a Linux environment afs_warn and afs_warnuser both go to the same spot, resulting in duplicated messages if both are invoked back to back. Define a new function afs_warnall for use when identical messages are directed to both warn and warnuser. In a Linux environment it will do the right thing and present only one copy of the message. Change-Id: I1abdc63adc74fe5b08d3872d48698ec9dcc7a40c Reviewed-on: http://gerrit.openafs.org/10943 Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot Reviewed-by: D Brashear --- src/afs/afs_prototypes.h | 3 +++ src/afs/afs_warn.c | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 42875d135..f9d1cf0b0 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1046,11 +1046,14 @@ extern afs_int32 afs_data_pointer_to_int32(const void *p); /* AIX doesn't have usable va_args support in its kernel */ extern void afs_warn(); extern void afs_warnuser(); +extern void afs_warnall(); #else extern void afs_warn(char *fmt, ...) AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); extern void afs_warnuser(char *fmt, ...) AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); +extern void afs_warnall(char *fmt, ...) + AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); #endif /* afs_vcache.c */ diff --git a/src/afs/afs_warn.c b/src/afs/afs_warn.c index ca369bfbb..289593d6b 100644 --- a/src/afs/afs_warn.c +++ b/src/afs/afs_warn.c @@ -208,3 +208,48 @@ afs_warnuser(char *fmt, ...) } #endif /* AFS_AIX_ENV */ + + +#ifdef AFS_AIX_ENV +void +afs_warnall(fmt, a, b, c, d, e, f, g, h, i) + char *fmt; + void *a, *b, *c, *d, *e, *f, *g, *h, *i; +{ + afs_warn(fmt, a, b, c, d, e, f, g, h, i); + afs_warnuser(fmt, a, b, c, d, e, f, g, h, i); + +} +#else /* AFS_AIX_ENV */ +/* On Linux both afs_warn and afs_warnuser go to the same + * place. Suppress one of them if we're running on Linux. + */ +void +afs_warnall(char *fmt, ...) +{ + va_list ap; + +# ifdef AFS_LINUX20_ENV + AFS_STATCNT(afs_warn); + if ((afs_showflags & GAGCONSOLE) || (afs_showflags & GAGUSER)) { + va_start(ap, fmt); + afs_vwarn(fmt, ap); + va_end(ap); + } +# else /* AFS_LINUX20_ENV */ + AFS_STATCNT(afs_warn); + if (afs_showflags & GAGCONSOLE) { + va_start(ap, fmt); + afs_vwarn(fmt, ap); + va_end(ap); + } + + AFS_STATCNT(afs_warnuser); + if (afs_showflags & GAGUSER) { + va_start(ap, fmt); + afs_vwarnuser(fmt, ap); + va_end(ap); + } +# endif /* AFS_LINUX20_ENV */ +} +#endif /* AFS_AIX_ENV */ -- 2.39.5