swrap: Include the function name in the debug output.
authorAndreas Schneider <asn@samba.org>
Thu, 2 Oct 2014 05:23:53 +0000 (07:23 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 2 Oct 2014 07:35:11 +0000 (09:35 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/socket_wrapper/socket_wrapper.c

index 13b24a0f98390b3335d2f3b3001410882bd8ced8..e0942edf03aa31f5659fdbb348de9cf49d097e44 100644 (file)
@@ -272,10 +272,12 @@ void swrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 # define SWRAP_LOG(...)
 #else
 
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...) PRINTF_ATTRIBUTE(2, 3);
-# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __VA_ARGS__)
+static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+# define SWRAP_LOG(dbglvl, ...) swrap_log((dbglvl), __func__, __VA_ARGS__)
 
-static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
+static void swrap_log(enum swrap_dbglvl_e dbglvl,
+                     const char *func,
+                     const char *format, ...)
 {
        char buffer[1024];
        va_list va;
@@ -295,23 +297,23 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...)
                switch (dbglvl) {
                        case SWRAP_LOG_ERROR:
                                fprintf(stderr,
-                                       "SWRAP_ERROR(%d): %s\n",
-                                       (int)getpid(), buffer);
+                                       "SWRAP_ERROR(%d) - %s: %s\n",
+                                       (int)getpid(), func, buffer);
                                break;
                        case SWRAP_LOG_WARN:
                                fprintf(stderr,
-                                       "SWRAP_WARN(%d): %s\n",
-                                       (int)getpid(), buffer);
+                                       "SWRAP_WARN(%d) - %s: %s\n",
+                                       (int)getpid(), func, buffer);
                                break;
                        case SWRAP_LOG_DEBUG:
                                fprintf(stderr,
-                                       "SWRAP_DEBUG(%d): %s\n",
-                                       (int)getpid(), buffer);
+                                       "SWRAP_DEBUG(%d) - %s: %s\n",
+                                       (int)getpid(), func, buffer);
                                break;
                        case SWRAP_LOG_TRACE:
                                fprintf(stderr,
-                                       "SWRAP_TRACE(%d): %s\n",
-                                       (int)getpid(), buffer);
+                                       "SWRAP_TRACE(%d) - %s: %s\n",
+                                       (int)getpid(), func, buffer);
                                break;
                }
        }
@@ -2727,7 +2729,7 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 
        for (i = 0; i < SOCKET_MAX_SOCKETS; i++) {
                port = autobind_start + i;
-               snprintf(un_addr.sa.un.sun_path, un_addr.sa_socklen,
+               snprintf(un_addr.sa.un.sun_path, sizeof(un_addr.sa.un.sun_path),
                         "%s/"SOCKET_FORMAT, socket_wrapper_dir(),
                         type, socket_wrapper_default_iface(), port);
                if (stat(un_addr.sa.un.sun_path, &st) == 0) continue;