From: Perry Ruiter Date: Sat, 22 Mar 2014 06:31:21 +0000 (-0700) Subject: afs: restructure afs_warn and afs_warnuser X-Git-Tag: upstream/1.6.10_pre1^2~75 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=6f9038dcbe01370e275cc2391397841e93d86eb2;p=packages%2Fo%2Fopenafs.git afs: restructure afs_warn and afs_warnuser Restructure afs_warn.c to provide an afs_vwarn and afs_vwarnuser that accepts a va_list rather than a variadic parameter specification. afs_warn and afs_warnuser continue to be variadic functions but now call afs_vwarn and afs_vwarnuser. This is a preparatory change. A subsequent update will further exploit afs_vwarn and afs_vwarnuser. Reviewed-on: http://gerrit.openafs.org/10942 Reviewed-by: Chas Williams - CONTRACTOR Tested-by: BuildBot Reviewed-by: D Brashear (cherry picked from commit c3d4c109305b2db8a63b754c1894ad37326dc340) Change-Id: Ica9c3c8a0ae2c5b680b2e11bc85c747cfd11d30a Reviewed-on: http://gerrit.openafs.org/11181 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Benjamin Kaduk Reviewed-by: Stephan Wiesand --- diff --git a/src/afs/afs_warn.c b/src/afs/afs_warn.c index a04a98b7e..1127e3d36 100644 --- a/src/afs/afs_warn.c +++ b/src/afs/afs_warn.c @@ -79,15 +79,10 @@ void afs_warn(fmt, a, b, c, d, e, f, g, h, i) char *fmt; void *a, *b, *c, *d, *e, *f, *g, *h, *i; -#else -void -afs_warn(char *fmt, ...) -#endif { AFS_STATCNT(afs_warn); if (afs_showflags & GAGCONSOLE) { -#if defined(AFS_AIX_ENV) struct file *fd; /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */ @@ -103,76 +98,115 @@ afs_warn(char *fmt, ...) fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count); fp_close(fd); } -#else + } +} +#else /* AFS_AIX_ENV */ +static_inline void +afs_vwarn(char *fmt, va_list ap) +{ + afs_vprintf(fmt, ap); +} + + +void +afs_warn(char *fmt, ...) +{ + AFS_STATCNT(afs_warn); + + if (afs_showflags & GAGCONSOLE) { va_list ap; va_start(ap, fmt); - afs_vprintf(fmt, ap); + afs_vwarn(fmt, ap); va_end(ap); -#endif } } +#endif /* AFS_AIX_ENV */ + #ifdef AFS_AIX_ENV void afs_warnuser(fmt, a, b, c, d, e, f, g, h, i) char *fmt; void *a, *b, *c, *d, *e, *f, *g, *h, *i; -#else -void -afs_warnuser(char *fmt, ...) -#endif { -#if defined(AFS_WARNUSER_MARINER_ENV) - char buf[256]; -#endif AFS_STATCNT(afs_warnuser); if (afs_showflags & GAGUSER) { -#if !defined(AFS_AIX_ENV) - va_list ap; -#endif -#ifdef AFS_GLOBAL_SUNLOCK +# ifdef AFS_GLOBAL_SUNLOCK int haveGlock = ISAFS_GLOCK(); -#if defined(AFS_WARNUSER_MARINER_ENV) - /* gain GLOCK for mariner */ - if (!haveGlock) - AFS_GLOCK(); -#else /* drop GLOCK for uprintf */ if (haveGlock) AFS_GUNLOCK(); -#endif -#endif /* AFS_GLOBAL_SUNLOCK */ - -#if defined(AFS_AIX_ENV) +# endif /* AFS_GLOBAL_SUNLOCK */ uprintf(fmt, a, b, c, d, e, f, g, h, i); -#else - va_start(ap, fmt); -#if defined(AFS_WARNUSER_MARINER_ENV) +# ifdef AFS_GLOBAL_SUNLOCK + /* regain GLOCK we dropped for uprintf */ + if (haveGlock) + AFS_GLOCK(); +# endif /* AFS_GLOBAL_SUNLOCK */ + } +} +#else /* AFS_AIX_ENV */ +# ifdef AFS_WARNUSER_MARINER_ENV +static void +afs_vwarnuser (char *fmt, va_list ap) +{ +# ifdef AFS_GLOBAL_SUNLOCK + int haveGlock = ISAFS_GLOCK(); + /* gain GLOCK for mariner */ + if (!haveGlock) + AFS_GLOCK(); +# endif /* AFS_GLOBAL_SUNLOCK */ + + if (afs_mariner) { + char buf[256]; + va_list aq; + va_copy(aq, ap); /* mariner log the warning */ snprintf(buf, sizeof(buf), "warn$"); - vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, ap); - if (afs_mariner) - afs_MarinerLog(buf, NULL); - va_end(ap); + vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, aq); + afs_MarinerLog(buf, NULL); + } + vprintf(fmt, ap); + +# ifdef AFS_GLOBAL_SUNLOCK + /* drop GLOCK we got for mariner */ + if (!haveGlock) + AFS_GUNLOCK(); +# endif /* AFS_GLOBAL_SUNLOCK */ +} +# else /* AFS_WARNUSER_MARINER_ENV */ +static void +afs_vwarnuser (char *fmt, va_list ap) +{ +# ifdef AFS_GLOBAL_SUNLOCK + int haveGlock = ISAFS_GLOCK(); + /* drop GLOCK */ + if (haveGlock) + AFS_GUNLOCK(); +# endif /* AFS_GLOBAL_SUNLOCK */ + + afs_vprintf(fmt, ap); + +# ifdef AFS_GLOBAL_SUNLOCK + /* regain GLOCK we dropped */ + if (haveGlock) + AFS_GLOCK(); +# endif /* AFS_GLOBAL_SUNLOCK */ +} +# endif /* AFS_WARNUSER_MARINER_ENV */ + +void +afs_warnuser(char *fmt, ...) +{ + AFS_STATCNT(afs_warnuser); + if (afs_showflags & GAGUSER) { + va_list ap; + va_start(ap, fmt); - vprintf(fmt, ap); -#else - afs_vprintf(fmt, ap); -#endif + afs_vwarnuser(fmt, ap); va_end(ap); -#endif - -#ifdef AFS_GLOBAL_SUNLOCK -#if defined(AFS_WARNUSER_MARINER_ENV) - /* drop GLOCK we got for mariner */ - if (!haveGlock) - AFS_GUNLOCK(); -#else - /* regain GLOCK we dropped for uprintf */ - if (haveGlock) - AFS_GLOCK(); -#endif -#endif /* AFS_GLOBAL_SUNLOCK */ } } + +#endif /* AFS_AIX_ENV */