remove unused(?) #includes from snmpd

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

remove unused(?) #includes from snmpd

Stefan Sperling-5
I was looking for ifmedia bits to fix in here, but found nothing
except a few unused if_media.h includes.

Turns out snmpd compiles (on i386) without warnings with a lot
less headers included.

Is this a safe change?

I've left sys/types.h alone since I guess removing it might
break builds using older compilers.

Index: snmpctl/parser.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpctl/parser.c,v
retrieving revision 1.15
diff -u -p -r1.15 parser.c
--- snmpctl/parser.c 14 Apr 2014 12:56:21 -0000 1.15
+++ snmpctl/parser.c 26 Sep 2015 19:12:02 -0000
@@ -20,16 +20,11 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/queue.h>
-#include <sys/tree.h>
-#include <sys/uio.h>
 
-#include <netinet/in.h>
 #include <net/if.h>
 #include <arpa/inet.h>
 
 #include <err.h>
-#include <errno.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: snmpctl/snmpclient.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpctl/snmpclient.c,v
retrieving revision 1.13
diff -u -p -r1.13 snmpclient.c
--- snmpctl/snmpclient.c 16 Jan 2015 06:40:21 -0000 1.13
+++ snmpctl/snmpclient.c 26 Sep 2015 19:13:59 -0000
@@ -16,15 +16,10 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -32,9 +27,7 @@
 #include <netdb.h>
 #include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <string.h>
-#include <ctype.h>
 #include <poll.h>
 #include <err.h>
 #include <pwd.h>
Index: snmpctl/snmpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpctl/snmpctl.c,v
retrieving revision 1.20
diff -u -p -r1.20 snmpctl.c
--- snmpctl/snmpctl.c 14 Apr 2014 12:56:21 -0000 1.20
+++ snmpctl/snmpctl.c 26 Sep 2015 19:15:31 -0000
@@ -21,16 +21,9 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/queue.h>
 #include <sys/un.h>
-#include <sys/tree.h>
-#include <sys/uio.h>
 
-#include <netinet/in.h>
-#include <arpa/inet.h>
 #include <net/if.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
 
 #include <err.h>
 #include <errno.h>
Index: snmpd/agentx.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/agentx.c,v
retrieving revision 1.9
diff -u -p -r1.9 agentx.c
--- snmpd/agentx.c 19 Jul 2015 01:08:07 -0000 1.9
+++ snmpd/agentx.c 26 Sep 2015 19:09:30 -0000
@@ -18,12 +18,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
-#include <sys/uio.h>
 #include <sys/un.h>
 
-#include <arpa/inet.h>
-
-#include <err.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
Index: snmpd/control.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/control.c,v
retrieving revision 1.29
diff -u -p -r1.29 control.c
--- snmpd/control.c 28 May 2015 17:08:09 -0000 1.29
+++ snmpd/control.c 26 Sep 2015 18:47:45 -0000
@@ -17,21 +17,17 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
 
 #include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <signal.h>
 
 #include "snmpd.h"
 
Index: snmpd/kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/kroute.c,v
retrieving revision 1.31
diff -u -p -r1.31 kroute.c
--- snmpd/kroute.c 18 Jul 2015 00:27:32 -0000 1.31
+++ snmpd/kroute.c 26 Sep 2015 18:57:39 -0000
@@ -21,22 +21,13 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
-#include <sys/tree.h>
-#include <sys/uio.h>
 #include <sys/ioctl.h>
 
 #include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-#include <net/route.h>
 #include <netinet/in.h>
-#include <netinet/if_ether.h>
 #include <arpa/inet.h>
 
-#include <err.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
Index: snmpd/log.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/log.c,v
retrieving revision 1.8
diff -u -p -r1.8 log.c
--- snmpd/log.c 8 Feb 2015 23:28:48 -0000 1.8
+++ snmpd/log.c 26 Sep 2015 18:58:00 -0000
@@ -17,21 +17,12 @@
  */
 
 #include <sys/types.h>
-#include <sys/queue.h>
 #include <sys/socket.h>
-#include <sys/tree.h>
 
 #include <netinet/in.h>
-#include <netinet/ip.h>
 #include <net/if.h>
 
-#include <arpa/inet.h>
-
 #include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 #include <syslog.h>
 #include <event.h>
 #include <netdb.h>
Index: snmpd/mib.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v
retrieving revision 1.76
diff -u -p -r1.76 mib.c
--- snmpd/mib.c 10 Jun 2015 10:03:59 -0000 1.76
+++ snmpd/mib.c 26 Sep 2015 18:56:37 -0000
@@ -18,13 +18,8 @@
  */
 
 #include <sys/param.h> /* MAXCOMLEN */
-#include <sys/queue.h>
 #include <sys/proc.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/time.h>
-#include <sys/tree.h>
 #include <sys/utsname.h>
 #include <sys/sysctl.h>
 #include <sys/sensors.h>
@@ -37,21 +32,16 @@
 #include <netinet/ip.h>
 #include <netinet/ip_carp.h>
 #include <netinet/ip_var.h>
-#include <arpa/inet.h>
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/pfvar.h>
 #include <net/if_pfsync.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <string.h>
-#include <time.h>
 #include <unistd.h>
-#include <pwd.h>
 #include <limits.h>
 #include <kvm.h>
 
Index: snmpd/mps.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
retrieving revision 1.21
diff -u -p -r1.21 mps.c
--- snmpd/mps.c 18 Jul 2015 16:54:43 -0000 1.21
+++ snmpd/mps.c 26 Sep 2015 18:58:18 -0000
@@ -16,31 +16,14 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
-#include <sys/sysctl.h>
 
 #include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <arpa/inet.h>
 
 #include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <string.h>
-#include <unistd.h>
-#include <pwd.h>
 
 #include "snmpd.h"
 #include "mib.h"
Index: snmpd/smi.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/smi.c,v
retrieving revision 1.18
diff -u -p -r1.18 smi.c
--- snmpd/smi.c 21 Aug 2015 08:29:06 -0000 1.18
+++ snmpd/smi.c 26 Sep 2015 18:58:35 -0000
@@ -16,32 +16,17 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
-#include <sys/sysctl.h>
 
 #include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
 #include <arpa/inet.h>
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <string.h>
-#include <unistd.h>
 #include <limits.h>
-#include <pwd.h>
 #include <vis.h>
 
 #include "snmpd.h"
Index: snmpd/snmpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpd.c,v
retrieving revision 1.29
diff -u -p -r1.29 snmpd.c
--- snmpd/snmpd.c 3 Jun 2015 02:24:36 -0000 1.29
+++ snmpd/snmpd.c 26 Sep 2015 19:00:16 -0000
@@ -18,21 +18,17 @@
 
 #include <sys/param.h> /* nitems */
 #include <sys/types.h>
-#include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
 
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <err.h>
 #include <errno.h>
 #include <event.h>
-#include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <pwd.h>
Index: snmpd/snmpe.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/snmpe.c,v
retrieving revision 1.40
diff -u -p -r1.40 snmpe.c
--- snmpd/snmpe.c 16 Jan 2015 00:05:13 -0000 1.40
+++ snmpd/snmpe.c 26 Sep 2015 19:01:31 -0000
@@ -17,25 +17,17 @@
  */
 
 #include <sys/param.h> /* nitems */
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
-#include <netinet/in.h>
As done for bgpd recently, rename media_type to if_type.

Rationale: if_type values come from the IFT_ namespace in if_types.h,
not from the IFM_ namespace in if_media.h. This change prevents
confusion between uint8_t interface types and uint64_t media types.
-#include <arpa/inet.h>
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <errno.h>
 #include <event.h>
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#include <pwd.h>
 
 #include "snmpd.h"
 #include "mib.h"
Index: snmpd/timer.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/timer.c,v
retrieving revision 1.4
diff -u -p -r1.4 timer.c
--- snmpd/timer.c 16 Jan 2015 00:05:13 -0000 1.4
+++ snmpd/timer.c 26 Sep 2015 19:02:47 -0000
@@ -16,27 +16,17 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/sched.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 
 #include <net/if.h>
-#include <net/if_types.h>
 #include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <arpa/inet.h>
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <errno.h>
 #include <event.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <pwd.h>
 
 #include "snmpd.h"
 #include "mib.h"
Index: snmpd/trap.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/trap.c,v
retrieving revision 1.24
diff -u -p -r1.24 trap.c
--- snmpd/trap.c 16 Jan 2015 00:05:13 -0000 1.24
+++ snmpd/trap.c 26 Sep 2015 19:03:52 -0000
@@ -16,25 +16,15 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
 #include <event.h>
-#include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
-#include <pwd.h>
 
 #include "snmpd.h"
 #include "mib.h"
Index: snmpd/traphandler.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/traphandler.c,v
retrieving revision 1.2
diff -u -p -r1.2 traphandler.c
--- snmpd/traphandler.c 16 Jan 2015 00:05:13 -0000 1.2
+++ snmpd/traphandler.c 26 Sep 2015 19:06:00 -0000
@@ -15,22 +15,15 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/param.h> /* nitems */
 #include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/uio.h>
 #include <sys/wait.h>
 
 #include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 
 #include <event.h>
 #include <fcntl.h>
-#include <imsg.h>
 #include <netdb.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: snmpd/usm.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/usm.c,v
retrieving revision 1.9
diff -u -p -r1.9 usm.c
--- snmpd/usm.c 16 Jan 2015 00:05:13 -0000 1.9
+++ snmpd/usm.c 26 Sep 2015 19:07:33 -0000
@@ -16,27 +16,17 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/queue.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/tree.h>
 
 #include <net/if.h>
 
-#include <errno.h>
 #include <event.h>
-#include <fcntl.h>
-#include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <signal.h>
 #ifdef DEBUG
 #include <assert.h>
 #endif
 
-#include <openssl/evp.h>
 #include <openssl/hmac.h>
 
 #include "snmpd.h"
Index: snmpd/util.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/util.c,v
retrieving revision 1.4
diff -u -p -r1.4 util.c
--- snmpd/util.c 20 Jul 2015 22:51:11 -0000 1.4
+++ snmpd/util.c 26 Sep 2015 19:08:23 -0000
@@ -16,7 +16,6 @@
  */
 
 #include <sys/types.h>
-#include <sys/queue.h>
 #include <sys/socket.h>
 
 #include <net/if.h>

Reply | Threaded
Open this post in threaded view
|

Re: remove unused(?) #includes from snmpd

Michael McConville-2
Stefan Sperling wrote:

> I was looking for ifmedia bits to fix in here, but found nothing
> except a few unused if_media.h includes.
>
> Turns out snmpd compiles (on i386) without warnings with a lot
> less headers included.
>
> Is this a safe change?
>
> I've left sys/types.h alone since I guess removing it might
> break builds using older compilers.

I see some preproc conditions in usr.sbin/snmpctl/snmpclient.c. I only
bothered to check the first two. Are you sure they still compile in all
circumstances? If I understand correctly, compiling without warning only
implies safety if the preproc isn't conditionally including code.

> Index: snmpctl/parser.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpctl/parser.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 parser.c
> --- snmpctl/parser.c 14 Apr 2014 12:56:21 -0000 1.15
> +++ snmpctl/parser.c 26 Sep 2015 19:12:02 -0000
> @@ -20,16 +20,11 @@
>  
>  #include <sys/types.h>
>  #include <sys/socket.h>
> -#include <sys/queue.h>
> -#include <sys/tree.h>
> -#include <sys/uio.h>
>  
> -#include <netinet/in.h>
>  #include <net/if.h>
>  #include <arpa/inet.h>
>  
>  #include <err.h>
> -#include <errno.h>
>  #include <limits.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> Index: snmpctl/snmpclient.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpctl/snmpclient.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 snmpclient.c
> --- snmpctl/snmpclient.c 16 Jan 2015 06:40:21 -0000 1.13
> +++ snmpctl/snmpclient.c 26 Sep 2015 19:13:59 -0000
> @@ -16,15 +16,10 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
> -#include <netinet/in.h>
> -#include <arpa/inet.h>
>  
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -32,9 +27,7 @@
>  #include <netdb.h>
>  #include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <string.h>
> -#include <ctype.h>
>  #include <poll.h>
>  #include <err.h>
>  #include <pwd.h>
> Index: snmpctl/snmpctl.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpctl/snmpctl.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 snmpctl.c
> --- snmpctl/snmpctl.c 14 Apr 2014 12:56:21 -0000 1.20
> +++ snmpctl/snmpctl.c 26 Sep 2015 19:15:31 -0000
> @@ -21,16 +21,9 @@
>  
>  #include <sys/types.h>
>  #include <sys/socket.h>
> -#include <sys/queue.h>
>  #include <sys/un.h>
> -#include <sys/tree.h>
> -#include <sys/uio.h>
>  
> -#include <netinet/in.h>
> -#include <arpa/inet.h>
>  #include <net/if.h>
> -#include <net/if_media.h>
> -#include <net/if_types.h>
>  
>  #include <err.h>
>  #include <errno.h>
> Index: snmpd/agentx.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/agentx.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 agentx.c
> --- snmpd/agentx.c 19 Jul 2015 01:08:07 -0000 1.9
> +++ snmpd/agentx.c 26 Sep 2015 19:09:30 -0000
> @@ -18,12 +18,8 @@
>  #include <sys/types.h>
>  #include <sys/socket.h>
>  #include <sys/socketvar.h>
> -#include <sys/uio.h>
>  #include <sys/un.h>
>  
> -#include <arpa/inet.h>
> -
> -#include <err.h>
>  #include <errno.h>
>  #include <stdlib.h>
>  #include <stdio.h>
> Index: snmpd/control.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/control.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 control.c
> --- snmpd/control.c 28 May 2015 17:08:09 -0000 1.29
> +++ snmpd/control.c 26 Sep 2015 18:47:45 -0000
> @@ -17,21 +17,17 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/stat.h>
>  #include <sys/socket.h>
>  #include <sys/un.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
>  
>  #include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <unistd.h>
> -#include <signal.h>
>  
>  #include "snmpd.h"
>  
> Index: snmpd/kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/kroute.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 kroute.c
> --- snmpd/kroute.c 18 Jul 2015 00:27:32 -0000 1.31
> +++ snmpd/kroute.c 26 Sep 2015 18:57:39 -0000
> @@ -21,22 +21,13 @@
>  #include <sys/types.h>
>  #include <sys/socket.h>
>  #include <sys/sysctl.h>
> -#include <sys/tree.h>
> -#include <sys/uio.h>
>  #include <sys/ioctl.h>
>  
>  #include <net/if.h>
> -#include <net/if_dl.h>
> -#include <net/if_types.h>
> -#include <net/route.h>
>  #include <netinet/in.h>
> -#include <netinet/if_ether.h>
>  #include <arpa/inet.h>
>  
> -#include <err.h>
>  #include <errno.h>
> -#include <fcntl.h>
> -#include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <unistd.h>
> Index: snmpd/log.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/log.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 log.c
> --- snmpd/log.c 8 Feb 2015 23:28:48 -0000 1.8
> +++ snmpd/log.c 26 Sep 2015 18:58:00 -0000
> @@ -17,21 +17,12 @@
>   */
>  
>  #include <sys/types.h>
> -#include <sys/queue.h>
>  #include <sys/socket.h>
> -#include <sys/tree.h>
>  
>  #include <netinet/in.h>
> -#include <netinet/ip.h>
>  #include <net/if.h>
>  
> -#include <arpa/inet.h>
> -
>  #include <errno.h>
> -#include <stdarg.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <string.h>
>  #include <syslog.h>
>  #include <event.h>
>  #include <netdb.h>
> Index: snmpd/mib.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/mib.c,v
> retrieving revision 1.76
> diff -u -p -r1.76 mib.c
> --- snmpd/mib.c 10 Jun 2015 10:03:59 -0000 1.76
> +++ snmpd/mib.c 26 Sep 2015 18:56:37 -0000
> @@ -18,13 +18,8 @@
>   */
>  
>  #include <sys/param.h> /* MAXCOMLEN */
> -#include <sys/queue.h>
>  #include <sys/proc.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/time.h>
> -#include <sys/tree.h>
>  #include <sys/utsname.h>
>  #include <sys/sysctl.h>
>  #include <sys/sensors.h>
> @@ -37,21 +32,16 @@
>  #include <netinet/ip.h>
>  #include <netinet/ip_carp.h>
>  #include <netinet/ip_var.h>
> -#include <arpa/inet.h>
>  #include <net/if.h>
>  #include <net/if_types.h>
>  #include <net/pfvar.h>
>  #include <net/if_pfsync.h>
>  
>  #include <stdlib.h>
> -#include <stdio.h>
>  #include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <string.h>
> -#include <time.h>
>  #include <unistd.h>
> -#include <pwd.h>
>  #include <limits.h>
>  #include <kvm.h>
>  
> Index: snmpd/mps.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 mps.c
> --- snmpd/mps.c 18 Jul 2015 16:54:43 -0000 1.21
> +++ snmpd/mps.c 26 Sep 2015 18:58:18 -0000
> @@ -16,31 +16,14 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/tree.h>
> -#include <sys/sysctl.h>
>  
>  #include <net/if.h>
> -#include <net/if_dl.h>
> -#include <net/if_arp.h>
> -#include <net/if_media.h>
> -#include <net/route.h>
> -#include <netinet/in.h>
> -#include <netinet/if_ether.h>
> -#include <arpa/inet.h>
>  
>  #include <stdlib.h>
> -#include <stdio.h>
> -#include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <string.h>
> -#include <unistd.h>
> -#include <pwd.h>
>  
>  #include "snmpd.h"
>  #include "mib.h"
> Index: snmpd/smi.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/smi.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 smi.c
> --- snmpd/smi.c 21 Aug 2015 08:29:06 -0000 1.18
> +++ snmpd/smi.c 26 Sep 2015 18:58:35 -0000
> @@ -16,32 +16,17 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/tree.h>
> -#include <sys/sysctl.h>
>  
>  #include <net/if.h>
> -#include <net/if_dl.h>
> -#include <net/if_arp.h>
> -#include <net/if_media.h>
> -#include <net/route.h>
> -#include <netinet/in.h>
> -#include <netinet/if_ether.h>
>  #include <arpa/inet.h>
>  
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <string.h>
> -#include <unistd.h>
>  #include <limits.h>
> -#include <pwd.h>
>  #include <vis.h>
>  
>  #include "snmpd.h"
> Index: snmpd/snmpd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/snmpd.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 snmpd.c
> --- snmpd/snmpd.c 3 Jun 2015 02:24:36 -0000 1.29
> +++ snmpd/snmpd.c 26 Sep 2015 19:00:16 -0000
> @@ -18,21 +18,17 @@
>  
>  #include <sys/param.h> /* nitems */
>  #include <sys/types.h>
> -#include <sys/queue.h>
>  #include <sys/socket.h>
>  #include <sys/wait.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
>  
>  #include <string.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> -#include <getopt.h>
>  #include <err.h>
>  #include <errno.h>
>  #include <event.h>
> -#include <signal.h>
>  #include <unistd.h>
>  #include <fcntl.h>
>  #include <pwd.h>
> Index: snmpd/snmpe.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/snmpe.c,v
> retrieving revision 1.40
> diff -u -p -r1.40 snmpe.c
> --- snmpd/snmpe.c 16 Jan 2015 00:05:13 -0000 1.40
> +++ snmpd/snmpe.c 26 Sep 2015 19:01:31 -0000
> @@ -17,25 +17,17 @@
>   */
>  
>  #include <sys/param.h> /* nitems */
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
> -#include <netinet/in.h>
> As done for bgpd recently, rename media_type to if_type.
>
> Rationale: if_type values come from the IFT_ namespace in if_types.h,
> not from the IFM_ namespace in if_media.h. This change prevents
> confusion between uint8_t interface types and uint64_t media types.
> -#include <arpa/inet.h>
>  
>  #include <stdlib.h>
>  #include <stdio.h>
> -#include <errno.h>
>  #include <event.h>
>  #include <fcntl.h>
>  #include <string.h>
>  #include <unistd.h>
> -#include <pwd.h>
>  
>  #include "snmpd.h"
>  #include "mib.h"
> Index: snmpd/timer.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/timer.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 timer.c
> --- snmpd/timer.c 16 Jan 2015 00:05:13 -0000 1.4
> +++ snmpd/timer.c 26 Sep 2015 19:02:47 -0000
> @@ -16,27 +16,17 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
>  #include <sys/sched.h>
>  #include <sys/socket.h>
>  #include <sys/sysctl.h>
>  
>  #include <net/if.h>
> -#include <net/if_types.h>
>  #include <netinet/in.h>
> -#include <netinet/ip.h>
> -#include <netinet/ip_var.h>
> -#include <arpa/inet.h>
>  
>  #include <stdlib.h>
> -#include <stdio.h>
>  #include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
> -#include <string.h>
> -#include <unistd.h>
> -#include <pwd.h>
>  
>  #include "snmpd.h"
>  #include "mib.h"
> Index: snmpd/trap.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/trap.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 trap.c
> --- snmpd/trap.c 16 Jan 2015 00:05:13 -0000 1.24
> +++ snmpd/trap.c 26 Sep 2015 19:03:52 -0000
> @@ -16,25 +16,15 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
> -#include <netinet/in.h>
> -#include <arpa/inet.h>
>  
>  #include <stdlib.h>
> -#include <stdio.h>
> -#include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
>  #include <string.h>
>  #include <unistd.h>
> -#include <pwd.h>
>  
>  #include "snmpd.h"
>  #include "mib.h"
> Index: snmpd/traphandler.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/traphandler.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 traphandler.c
> --- snmpd/traphandler.c 16 Jan 2015 00:05:13 -0000 1.2
> +++ snmpd/traphandler.c 26 Sep 2015 19:06:00 -0000
> @@ -15,22 +15,15 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/param.h> /* nitems */
>  #include <sys/socket.h>
> -#include <sys/socketvar.h>
> -#include <sys/stat.h>
>  #include <sys/types.h>
> -#include <sys/uio.h>
>  #include <sys/wait.h>
>  
>  #include <net/if.h>
> -#include <netinet/in.h>
> -#include <arpa/inet.h>
>  
>  #include <event.h>
>  #include <fcntl.h>
> -#include <imsg.h>
>  #include <netdb.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> Index: snmpd/usm.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/usm.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 usm.c
> --- snmpd/usm.c 16 Jan 2015 00:05:13 -0000 1.9
> +++ snmpd/usm.c 26 Sep 2015 19:07:33 -0000
> @@ -16,27 +16,17 @@
>   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
>  
> -#include <sys/queue.h>
>  #include <sys/types.h>
> -#include <sys/stat.h>
>  #include <sys/socket.h>
> -#include <sys/un.h>
> -#include <sys/tree.h>
>  
>  #include <net/if.h>
>  
> -#include <errno.h>
>  #include <event.h>
> -#include <fcntl.h>
> -#include <stdlib.h>
>  #include <string.h>
> -#include <unistd.h>
> -#include <signal.h>
>  #ifdef DEBUG
>  #include <assert.h>
>  #endif
>  
> -#include <openssl/evp.h>
>  #include <openssl/hmac.h>
>  
>  #include "snmpd.h"
> Index: snmpd/util.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/util.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 util.c
> --- snmpd/util.c 20 Jul 2015 22:51:11 -0000 1.4
> +++ snmpd/util.c 26 Sep 2015 19:08:23 -0000
> @@ -16,7 +16,6 @@
>   */
>  
>  #include <sys/types.h>
> -#include <sys/queue.h>
>  #include <sys/socket.h>
>  
>  #include <net/if.h>

Reply | Threaded
Open this post in threaded view
|

Re: remove unused(?) #includes from snmpd

Stefan Sperling-5
On Sat, Sep 26, 2015 at 03:29:07PM -0400, Michael McConville wrote:
> I see some preproc conditions in usr.sbin/snmpctl/snmpclient.c. I only
> bothered to check the first two. Are you sure they still compile in all
> circumstances? If I understand correctly, compiling without warning only
> implies safety if the preproc isn't conditionally including code.

FWIW, it compiles with make CPPFLAGS="-DDEBUG" and with
make CPPFLAGS="-DDEBUG=2".

Reply | Threaded
Open this post in threaded view
|

Re: remove unused(?) #includes from snmpd

Michael McConville-2
Stefan Sperling wrote:
> On Sat, Sep 26, 2015 at 03:29:07PM -0400, Michael McConville wrote:
> > I see some preproc conditions in usr.sbin/snmpctl/snmpclient.c. I
> > only bothered to check the first two. Are you sure they still
> > compile in all circumstances? If I understand correctly, compiling
> > without warning only implies safety if the preproc isn't
> > conditionally including code.
>
> FWIW, it compiles with make CPPFLAGS="-DDEBUG" and with
> make CPPFLAGS="-DDEBUG=2".

A quick grep shows '#ifdef RTF_MPATH' in usr.sbin/snmpd/kroute.c and
'#ifdef notyet' in usr.sbin/snmpd/mib.c. Less variety than I expected,
and the notyet block is unlikely to be functional anyway.

There's a tool for testing this more rigorously, but I remember it being
hard to use:

        http://include-what-you-use.org/

Reply | Threaded
Open this post in threaded view
|

Re: remove unused(?) #includes from snmpd

Stefan Sperling-5
On Sat, Sep 26, 2015 at 03:51:25PM -0400, Michael McConville wrote:

> Stefan Sperling wrote:
> > On Sat, Sep 26, 2015 at 03:29:07PM -0400, Michael McConville wrote:
> > > I see some preproc conditions in usr.sbin/snmpctl/snmpclient.c. I
> > > only bothered to check the first two. Are you sure they still
> > > compile in all circumstances? If I understand correctly, compiling
> > > without warning only implies safety if the preproc isn't
> > > conditionally including code.
> >
> > FWIW, it compiles with make CPPFLAGS="-DDEBUG" and with
> > make CPPFLAGS="-DDEBUG=2".
>
> A quick grep shows '#ifdef RTF_MPATH' in usr.sbin/snmpd/kroute.c and

Yes, that one looks safe. It's using things also used outside the ifdef.

> '#ifdef notyet' in usr.sbin/snmpd/mib.c. Less variety than I expected,
> and the notyet block is unlikely to be functional anyway.

notyet was left for the future -> don't care

Reply | Threaded
Open this post in threaded view
|

Re: remove unused(?) #includes from snmpd

Claudio Jeker
On Sat, Sep 26, 2015 at 09:58:59PM +0200, Stefan Sperling wrote:

> On Sat, Sep 26, 2015 at 03:51:25PM -0400, Michael McConville wrote:
> > Stefan Sperling wrote:
> > > On Sat, Sep 26, 2015 at 03:29:07PM -0400, Michael McConville wrote:
> > > > I see some preproc conditions in usr.sbin/snmpctl/snmpclient.c. I
> > > > only bothered to check the first two. Are you sure they still
> > > > compile in all circumstances? If I understand correctly, compiling
> > > > without warning only implies safety if the preproc isn't
> > > > conditionally including code.
> > >
> > > FWIW, it compiles with make CPPFLAGS="-DDEBUG" and with
> > > make CPPFLAGS="-DDEBUG=2".
> >
> > A quick grep shows '#ifdef RTF_MPATH' in usr.sbin/snmpd/kroute.c and
>
> Yes, that one looks safe. It's using things also used outside the ifdef.

RTF_MPATH was added in some places to increase portability since this is
mostly an OpenBSD-ism. Not sure if we still care...

>
> > '#ifdef notyet' in usr.sbin/snmpd/mib.c. Less variety than I expected,
> > and the notyet block is unlikely to be functional anyway.
>
> notyet was left for the future -> don't care
>

--
:wq Claudio