From 664ef9a3e1016e80fc1fcbbef6e9f66a2ededfe6 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 30 Jun 2018 19:34:41 +0200 Subject: pkg/compiler: check for unused declarations Error on unused structs/unions/resources/flags. Finds tons of bugs. --- sys/freebsd/socket.txt | 27 ------- sys/freebsd/socket_inet.txt | 14 ---- sys/freebsd/socket_inet6.txt | 19 ----- sys/freebsd/socket_inet_tcp.txt | 5 -- sys/freebsd/sys.txt | 160 ---------------------------------------- 5 files changed, 225 deletions(-) (limited to 'sys/freebsd') diff --git a/sys/freebsd/socket.txt b/sys/freebsd/socket.txt index e493fb160..3b7c7822b 100644 --- a/sys/freebsd/socket.txt +++ b/sys/freebsd/socket.txt @@ -43,13 +43,6 @@ send_flags = MSG_CONFIRM, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_NOSIGNAL, MS recv_flags = MSG_CMSG_CLOEXEC, MSG_DONTWAIT, MSG_ERRQUEUE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, MSG_WAITFORONE cmsg_levels = SOL_SOCKET, IPPROTO_ICMP, SOL_IP, SOL_TCP, LINUX_SOL_UDP, SOL_IPV6, SOL_IPX, SOL_AX25 -# This sockaddr type corresponds to the struct sockaddr and is 16 bytes or less. -sockaddr [ -# AF_UNIX sockaddr in bigger than 16 bytes - in sockaddr_in - random array[int32, 4] -] - # This sockaddr type corresponds to the sockaddr_storage type and is 128 bytes size. sockaddr_storage [ un sockaddr_un @@ -57,16 +50,6 @@ sockaddr_storage [ in6 sockaddr_in6 ] [varlen] -sockaddr_generic { - sa_family flags[socket_domain, int16] - sa_data array[int8, 14] -} - -sockaddr_storage_generic { - sa_family flags[socket_domain, int16] - sa_data array[int8, 126] -} - send_msghdr { msg_name ptr[in, sockaddr_storage, opt] msg_namelen len[msg_name, int32] @@ -77,11 +60,6 @@ send_msghdr { msg_flags flags[send_flags, int32] } -send_mmsghdr { - msg_hdr send_msghdr - msg_len int32 -} - recv_msghdr { msg_name ptr[out, sockaddr_storage, opt] msg_namelen len[msg_name, int32] @@ -92,11 +70,6 @@ recv_msghdr { msg_flags int32 } -recv_mmsghdr { - msg_hdr recv_msghdr - msg_len int32 -} - cmsghdr { cmsg_len len[parent, intptr] cmsg_level flags[cmsg_levels, int32] diff --git a/sys/freebsd/socket_inet.txt b/sys/freebsd/socket_inet.txt index fea82c588..6dde4601f 100644 --- a/sys/freebsd/socket_inet.txt +++ b/sys/freebsd/socket_inet.txt @@ -105,12 +105,6 @@ ip_msfilter { ip_msfilter_mode = MCAST_INCLUDE, MCAST_EXCLUDE -in_pktinfo { - ipi_ifindex ifindex - ipi_spec_dst ipv4_addr - ipi_addr ipv4_addr -} - group_req_in { gr_interface int32 gr_group sockaddr_storage_in @@ -121,11 +115,3 @@ group_source_req_in { gsr_group sockaddr_storage_in gsr_source sockaddr_storage_in } - -group_filter_in { - gf_interface int32 - gf_group sockaddr_storage_in - gf_fmode flags[ip_msfilter_mode, int32] - gf_numsrc len[gf_slist, int32] - gf_slist array[sockaddr_storage_in] -} diff --git a/sys/freebsd/socket_inet6.txt b/sys/freebsd/socket_inet6.txt index 8ccb932d0..435673c94 100644 --- a/sys/freebsd/socket_inet6.txt +++ b/sys/freebsd/socket_inet6.txt @@ -91,11 +91,6 @@ mf6cctl { mf6cc_ifset array[int32, 8] } -ipv6_mreq { - multi ipv6_addr - ifindex ifindex -} - group_req_in6 { gr_interface int32 gr_group sockaddr_storage_in6 @@ -107,21 +102,7 @@ group_source_req_in6 { gsr_source sockaddr_storage_in6 } -group_filter_in6 { - gf_interface int32 - gf_group sockaddr_storage_in6 - gf_fmode flags[ip_msfilter_mode, int32] - gf_numsrc len[gf_slist, int32] - gf_slist array[sockaddr_storage_in6] -} - in6_pktinfo { ipi6_addr ipv6_addr ipi6_ifindex ifindex } - -in6_ifreq { - ifr6_addr ipv6_addr - ifr6_prefixlen int32 - ifr6_ifindex ifindex -} diff --git a/sys/freebsd/socket_inet_tcp.txt b/sys/freebsd/socket_inet_tcp.txt index 458ce06ed..1cac4b13d 100644 --- a/sys/freebsd/socket_inet_tcp.txt +++ b/sys/freebsd/socket_inet_tcp.txt @@ -52,8 +52,3 @@ setsockopt$inet_tcp_TCP_CONGESTION(fd sock_tcp, level const[IPPROTO_TCP], optnam setsockopt$inet6_tcp_TCP_CONGESTION(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_CONGESTION], optval ptr[in, string[tcp_congestion_control_alg_names]], optlen len[optval]) tcp_congestion_control_alg_names = "cubic", "reno", "bic", "cdg", "dctcp", "westwood", "highspeed", "hybla", "htcp", "vegas", "nv", "veno", "scalable", "lp", "yeah", "illinois" - -sockaddr_storage_tcp { - in sockaddr_storage_in - in6 sockaddr_storage_in6 -} diff --git a/sys/freebsd/sys.txt b/sys/freebsd/sys.txt index 60f7f8afb..28b486dcd 100644 --- a/sys/freebsd/sys.txt +++ b/sys/freebsd/sys.txt @@ -126,69 +126,21 @@ sigset { mask int64 } -sigset_size { - ss ptr[inout, sigset] - len len[ss, intptr] -} - -resource time_sec[intptr] -resource time_nsec[intptr] -resource time_usec[intptr] - -# prog knowns about this struct type timespec { sec intptr nsec intptr } -# prog knowns about this struct type timeval { sec intptr usec intptr } -statx_timestamp { - sec int64 - nsec int32 - __reserved int32 -} - -itimerspec { - interv timespec - value timespec -} - itimerval { interv timeval value timeval } -utimbuf { - actime intptr - modtime intptr -} - -io_event { - data int64 - obj int64 - res int64 - res2 int32 -} - -cap_header { - var flags[cap_version, int32] - pid pid -} - -cap_data { - eff0 int32 - perm0 int32 - inher0 int32 - eff1 int32 - perm1 int32 - inher1 int32 -} - # TODO: fd_set needs to be a separate type fd_set { mask0 int64 @@ -201,49 +153,6 @@ fd_set { mask7 int64 } -sock_fprog { - len len[filter, int16] - filter ptr[in, array[sock_filter]] -} - -sock_filter { - code int16 - jt int8 - jf int8 - k int32 -} - -file_handle { - bytes len[parent, int32] - type int32 - handle array[int8] -} - -mq_attr { - flags intptr - maxmsg intptr - msgsize intptr - curmsg intptr - res0 intptr - res1 intptr - res2 intptr - res3 intptr -} - -kexec_segment { - buf buffer[in] - sz len[buf, intptr] -# TODO: this is address in kernel - mem intptr - memsz intptr -} - -robust_list { - next vma - off intptr - pend vma -} - rusage { utime timeval stime timeval @@ -268,68 +177,6 @@ rlimit { hard intptr } -tms { - utime intptr - stime intptr - cutime intptr - cstime intptr -} - -timex { - stuff0 intptr - stuff1 intptr - stuff2 intptr - stuff3 intptr - stuff4 intptr - stuff5 intptr - stuff6 intptr - stuff7 intptr - stuff8 intptr - stuff9 intptr - stuff10 intptr - stuff11 intptr - stuff12 intptr - stuff13 intptr - stuff14 intptr - stuff15 intptr - stuff16 intptr - stuff17 intptr - stuff18 intptr - stuff19 intptr - stuff20 intptr - stuff21 intptr - stuff22 intptr - stuff23 intptr - stuff24 intptr - stuff25 intptr -} - -ustat { - free int32 - inode intptr - nampac0 int32 - nampac1 int32 - nampac2 int32 -} - -user_desc { - entry_number int32 -# Base should be vma and limit should be len[base] -# But these fields are int32, so we can't use vma. - base_addr flags[user_desc_bases, int32] - limit flags[user_desc_limits, int32] - seg_32bit int32:1 - contents int32:2 - read_exec_only int32:1 - limit_in_pages int32:1 - seg_not_present int32:1 - useable int32:1 - lm int32:1 -} - -user_desc_bases = 0, 4096, 1048576, 536870912, 536872960, 536875008, 0xffffffff -user_desc_limits = 0, 1024, 4096, 8192, 16384, 0xffffffff - flock { type flags[flock_type, int16] whence flags[seek_whence, int16] @@ -349,10 +196,6 @@ ucred { gid gid } -fadvise_flags = POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL, POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, POSIX_FADV_DONTNEED -dup_flags = O_CLOEXEC -clock_type = CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID -cap_version = 0x19980330, 0x20071026, 0x20080522 pollfd_events = POLLIN, POLLPRI, POLLOUT, POLLERR, POLLHUP, POLLNVAL, POLLRDNORM, POLLRDBAND, POLLWRNORM, POLLWRBAND, POLLINIGNEOF mknod_mode = S_IFREG, S_IFCHR, S_IFBLK, S_IFIFO, S_IFSOCK, S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP, S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH at_flags = AT_SYMLINK_NOFOLLOW, AT_SYMLINK_FOLLOW @@ -363,13 +206,10 @@ faccessat_flags = 0x100, 0x200, 0x400, 0x800, 0x1000 rusage_who = RUSAGE_SELF, RUSAGE_CHILDREN, RUSAGE_THREAD rlimit_type = RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_MEMLOCK, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK clock_id = CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID -sigprocmask_how = SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK getitimer_which = ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF wait_options = WNOHANG, WUNTRACED, WCONTINUED, WEXITED, WSTOPPED, WCONTINUED, WNOHANG, WNOWAIT -waitid_which = P_PID, P_PGID, P_ALL timer_flags = 0, TIMER_ABSTIME utimensat_flags = 0, AT_SYMLINK_NOFOLLOW -priority_which = PRIO_PROCESS, PRIO_PGRP, PRIO_USER fcntl_dupfd = F_DUPFD, F_DUPFD_CLOEXEC fcntl_getflags = F_GETFD, F_GETFL fcntl_lock = F_SETLK, F_SETLKW, F_GETLK -- cgit mrf-deployment