From 29a37414d3378e6d69285f6ca850d439db4cf912 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 10 May 2018 19:28:24 +0200
Subject: [PATCH] WIP tcp_wrappers lto fixes

---
 contrib/tcp_wrappers/fakelog.c   | 11 +++++------
 contrib/tcp_wrappers/mystdarg.h  | 19 -------------------
 contrib/tcp_wrappers/myvsyslog.c |  4 +++-
 contrib/tcp_wrappers/percent_m.c |  3 +--
 contrib/tcp_wrappers/update.c    | 14 +++++++-------
 5 files changed, 16 insertions(+), 35 deletions(-)
 delete mode 100644 contrib/tcp_wrappers/mystdarg.h

diff --git a/contrib/tcp_wrappers/fakelog.c b/contrib/tcp_wrappers/fakelog.c
index d8ba998164..25c69c39dd 100644
--- a/contrib/tcp_wrappers/fakelog.c
+++ b/contrib/tcp_wrappers/fakelog.c
@@ -5,9 +5,10 @@
   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
   */
 
+#include <stdarg.h>
 #include <stdio.h>
 
-#include "mystdarg.h"
+extern char *percent_m();
 
 /* openlog - dummy */
 
@@ -42,15 +43,13 @@ va_list ap;
 /* VARARGS */
 
 void
-VARARGS(syslog, int, severity)
+syslog(int severity, const char *fmt, ...)
 {
     va_list ap;
-    char   *fmt;
 
-    VASTART(ap, int, severity);
-    fmt = va_arg(ap, char *);
+    va_start(ap, fmt);
     vsyslog(severity, fmt, ap);
-    VAEND(ap);
+    va_end(ap);
 }
 
 /* closelog - dummy */
diff --git a/contrib/tcp_wrappers/mystdarg.h b/contrib/tcp_wrappers/mystdarg.h
deleted file mode 100644
index 36bdf696f1..0000000000
--- a/contrib/tcp_wrappers/mystdarg.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
- /*
-  * What follows is an attempt to unify varargs.h and stdarg.h. I'd rather
-  * have this than #ifdefs all over the code.
-  */
-
-#ifdef __STDC__
-#include <stdarg.h>
-#define VARARGS(func,type,arg) func(type arg, ...)
-#define VASTART(ap,type,name)  va_start(ap,name)
-#define VAEND(ap)              va_end(ap)
-#else
-#include <varargs.h>
-#define VARARGS(func,type,arg) func(va_alist) va_dcl
-#define VASTART(ap,type,name)  {type name; va_start(ap); name = va_arg(ap, type)
-#define VAEND(ap)              va_end(ap);}
-#endif
-
-extern char *percent_m();
diff --git a/contrib/tcp_wrappers/myvsyslog.c b/contrib/tcp_wrappers/myvsyslog.c
index 20401f1f37..f46ad8051e 100644
--- a/contrib/tcp_wrappers/myvsyslog.c
+++ b/contrib/tcp_wrappers/myvsyslog.c
@@ -13,10 +13,12 @@ static char sccsid[] = "@(#) myvsyslog.c 1.1 94/12/28 17:42:33";
 
 #ifdef vsyslog
 
+#include <stdarg.h>
 #include <stdio.h>
 
 #include "tcpd.h"
-#include "mystdarg.h"
+
+extern char *percent_m();
 
 myvsyslog(severity, format, ap)
 int     severity;
diff --git a/contrib/tcp_wrappers/percent_m.c b/contrib/tcp_wrappers/percent_m.c
index 2a0a363562..25f444706b 100644
--- a/contrib/tcp_wrappers/percent_m.c
+++ b/contrib/tcp_wrappers/percent_m.c
@@ -6,6 +6,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <stdarg.h>
 #include <string.h>
 
 #ifndef SYS_ERRLIST_DEFINED
@@ -13,8 +14,6 @@ extern char *sys_errlist[];
 extern int sys_nerr;
 #endif
 
-#include "mystdarg.h"
-
 char   *percent_m(obuf, ibuf)
 char   *obuf;
 char   *ibuf;
diff --git a/contrib/tcp_wrappers/update.c b/contrib/tcp_wrappers/update.c
index 142820b948..1c18a7a3c6 100644
--- a/contrib/tcp_wrappers/update.c
+++ b/contrib/tcp_wrappers/update.c
@@ -17,6 +17,7 @@
 
 /* System libraries */
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <syslog.h>
 #include <string.h>
@@ -24,7 +25,6 @@
 
 /* Local stuff. */
 
-#include "mystdarg.h"
 #include "tcpd.h"
 
 /* request_fill - request update engine */
@@ -89,7 +89,7 @@ va_list ap;
 
 /* request_init - initialize request structure */
 
-struct request_info *VARARGS(request_init, struct request_info *, request)
+struct request_info *request_init(struct request_info *request, ...)
 {
     static struct request_info default_info;
     struct request_info *r;
@@ -100,7 +100,7 @@ struct request_info *VARARGS(request_init, struct request_info *, request)
      * members, to avoid pulling in the whole socket module when it is not
      * really needed.
      */
-    VASTART(ap, struct request_info *, request);
+    va_start(ap, request);
     *request = default_info;
     request->fd = -1;
     strcpy(request->daemon, unknown);
@@ -108,19 +108,19 @@ struct request_info *VARARGS(request_init, struct request_info *, request)
     request->client->request = request;
     request->server->request = request;
     r = request_fill(request, ap);
-    VAEND(ap);
+    va_end(ap);
     return (r);
 }
 
 /* request_set - update request structure */
 
-struct request_info *VARARGS(request_set, struct request_info *, request)
+struct request_info *request_set(struct request_info *request, ...)
 {
     struct request_info *r;
     va_list ap;
 
-    VASTART(ap, struct request_info *, request);
+    va_start(ap, request);
     r = request_fill(request, ap);
-    VAEND(ap);
+    va_end(ap);
     return (r);
 }
-- 
2.17.0

