odhcpd: shrink binary size by creating a logging function
authorDavid Härdeman <[email protected]>
Fri, 17 Oct 2025 19:45:38 +0000 (21:45 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Sat, 18 Oct 2025 15:40:42 +0000 (17:40 +0200)
Moving the logging to a real function helps shrink the binary size back to what
it was before the logging patches.

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/273
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/odhcpd.c
src/odhcpd.h

index 1f3cd1b2d7ffadeb0f16a68d99faf282d1fe5f8c..4b17a161152c6e7f672b9b21bf9e0d4e5a984bd7 100644 (file)
 static int ioctl_sock = -1;
 static int urandom_fd = -1;
 
+void __iflog(int lvl, const char *fmt, ...)
+{
+       va_list ap;
+
+       if (lvl > config.log_level)
+               return;
+
+       va_start(ap, fmt);
+
+       if (config.log_syslog) {
+               vsyslog(lvl, fmt, ap);
+       } else {
+               vfprintf(stderr, fmt, ap);
+               fprintf(stderr, "\n");
+       }
+
+       va_end(ap);
+}
+
 static void sighandler(_unused int signal)
 {
        uloop_end();
index 9a41a59eaa9174236223d0edc8f026a2370cc61d..dc77c03a18ff0ee5bddd94b2356314153ae021d9 100644 (file)
@@ -69,16 +69,7 @@ struct nl_sock;
 extern struct vlist_tree leases;
 extern struct config config;
 
-#define __iflog(lvl, fmt, ...)                                                 \
-       do {                                                                    \
-               if (lvl > config.log_level)                                     \
-                       break;                                                  \
-               if (config.log_syslog)                                          \
-                       syslog(lvl, fmt __VA_OPT__(, ) __VA_ARGS__);            \
-               else                                                            \
-                       fprintf(stderr, fmt "\n" __VA_OPT__(, ) __VA_ARGS__);   \
-       } while(0)
-
+void __iflog(int lvl, const char *fmt, ...);
 #define debug(fmt, ...)     __iflog(LOG_DEBUG, fmt __VA_OPT__(, ) __VA_ARGS__)
 #define info(fmt, ...)      __iflog(LOG_INFO, fmt __VA_OPT__(, ) __VA_ARGS__)
 #define notice(fmt, ...)    __iflog(LOG_NOTICE, fmt __VA_OPT__(, ) __VA_ARGS__)