Hi Simon,

I am writing to suggest another compiler warning fix. The warning is only visible on systems that do not define HAVE_LINUX_NETWORK, f.i., FreeBSD.

Patch attached.


Cheers,
Matthias

From 37b83629e8933c8483d55f44041aaaaf86254662 Mon Sep 17 00:00:00 2001
From: Matthias Andree <[email protected]>
Date: Wed, 21 May 2025 20:41:33 +0200
Subject: [PATCH] Only define variable "a" if we HAVE_LINUX_NETWORK

Variable unsigned char a is defined unconditionally,
but it is only used if HAVE_LINUX_NETWORK is defined.
This triggers compiler warnings on, say, FreeBSD.

Fix by wrapping the definition in proper #ifdef.
---
 src/dnsmasq.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index ba5e459..bfdc913 100644
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -1939,11 +1939,14 @@ static void do_tcp_connection(struct listener *listener, time_t now, int slot)
   pid_t p;
   union mysockaddr tcp_addr;
   socklen_t tcp_len = sizeof(union mysockaddr);
-  unsigned char a = 0, *buff;
+  unsigned char *buff;
   struct server *s; 
   int flags, auth_dns;
   struct in_addr netmask;
   int pipefd[2];
+#ifdef HAVE_LINUX_NETWORK
+  unsigned char a = 0;
+#endif
 
   while ((confd = accept(listener->tcpfd, NULL, NULL)) == -1 && errno == EINTR);
   
@@ -2052,7 +2055,7 @@ static void do_tcp_connection(struct listener *listener, time_t now, int slot)
 	     single byte comes back up the pipe, which
 	     is sent by the child after it has closed the
 	     netlink socket. */
-	  
+
 	  read_write(pipefd[0], &a, 1, RW_READ);
 #endif
 	  
-- 
2.49.0

_______________________________________________
Dnsmasq-discuss mailing list
[email protected]
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to