afs: Define afs_warnall routine
authorPerry Ruiter <pruiter@sinenomine.net>
Sat, 22 Mar 2014 07:52:32 +0000 (00:52 -0700)
committerD Brashear <shadow@your-file-system.com>
Wed, 21 May 2014 11:05:36 +0000 (07:05 -0400)
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 <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: D Brashear <shadow@your-file-system.com>

src/afs/afs_prototypes.h
src/afs/afs_warn.c

index 42875d1..f9d1cf0 100644 (file)
@@ -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 */
index ca369bf..289593d 100644 (file)
@@ -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 */