On 28/11/19(Thu) 16:49, nayden wrote:
> Hello,
> 
> A mostly mechanical diff that makes use of __func__ in place of hardcoded
> function names in panic() and printf() calls.
> 
> If someone is working in netinet6 and this change will trample
> your work please let me know and I'll hold off.
> 
> ok?

Why, the trace isn't already clear?

> Index: icmp6.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/icmp6.c,v
> retrieving revision 1.229
> diff -u -p -r1.229 icmp6.c
> --- icmp6.c   25 Dec 2018 19:28:25 -0000      1.229
> +++ icmp6.c   17 Jan 2019 03:50:22 -0000
> @@ -225,7 +225,7 @@ icmp6_mtudisc_callback_register(void (*f
> 
>       mc = malloc(sizeof(*mc), M_PCB, M_NOWAIT);
>       if (mc == NULL)
> -             panic("icmp6_mtudisc_callback_register");
> +             panic("%s", __func__);
> 
>       mc->mc_func = func;
>       LIST_INSERT_HEAD(&icmp6_mtudisc_callbacks, mc, mc_list);
> Index: in6_pcb.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/in6_pcb.c,v
> retrieving revision 1.109
> diff -u -p -r1.109 in6_pcb.c
> --- in6_pcb.c 17 Oct 2019 00:51:28 -0000      1.109
> +++ in6_pcb.c 11 Nov 2019 06:18:42 -0000
> @@ -376,8 +376,8 @@ in6_pcbnotify(struct inpcbtable *table,           return 
> (0);
>       if (IN6_IS_ADDR_V4MAPPED(&dst->sin6_addr)) {
> #ifdef DIAGNOSTIC
> -             printf("Huh?  Thought in6_pcbnotify() never got "
> -                    "called with mapped!\n");
> +             printf("%s: Huh?  Thought we never got "
> +                    "called with mapped!\n", __func__);
> #endif
>               return (0);
>       }
> Index: ip6_divert.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/ip6_divert.c,v
> retrieving revision 1.59
> diff -u -p -r1.59 ip6_divert.c
> --- ip6_divert.c      4 Feb 2019 21:40:52 -0000       1.59
> +++ ip6_divert.c      15 Feb 2019 12:46:55 -0000
> @@ -301,7 +301,7 @@ divert6_usrreq(struct socket *so, int re
>               break;
> 
>       default:
> -             panic("divert6_usrreq");
> +             panic("%s", __func__);
>       }
> 
> release:
> Index: ip6_input.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/ip6_input.c,v
> retrieving revision 1.219
> diff -u -p -r1.219 ip6_input.c
> --- ip6_input.c       21 Aug 2019 15:32:18 -0000      1.219
> +++ ip6_input.c       27 Nov 2019 17:22:30 -0000
> @@ -144,7 +144,7 @@ ip6_init(void)
> 
>       pr = pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
>       if (pr == NULL)
> -             panic("ip6_init");
> +             panic("%s", __func__);
>       for (i = 0; i < IPPROTO_MAX; i++)
>               ip6_protox[i] = pr - inet6sw;
>       for (pr = inet6domain.dom_protosw;
> @@ -1204,7 +1204,7 @@ ip6_nexthdr(struct mbuf *m, int off, int
> 
>       /* just in case */
>       if (m == NULL)
> -             panic("ip6_nexthdr: m == NULL");
> +             panic("%s: m == NULL", __func__);
>       if ((m->m_flags & M_PKTHDR) == 0 || m->m_pkthdr.len < off)
>               return -1;
> 
> Index: ip6_output.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/ip6_output.c,v
> retrieving revision 1.244
> diff -u -p -r1.244 ip6_output.c
> --- ip6_output.c      10 Jun 2019 16:32:51 -0000      1.244
> +++ ip6_output.c      27 Nov 2019 17:24:15 -0000
> @@ -174,7 +174,7 @@ ip6_output(struct mbuf *m0, struct ip6_p
> 
> #ifdef IPSEC
>       if (inp && (inp->inp_flags & INP_IPV6) == 0)
> -             panic("ip6_output: IPv4 pcb is passed");
> +             panic("%s: IPv4 pcb is passed", __func__);
> #endif /* IPSEC */
> 
>       ip6 = mtod(m, struct ip6_hdr *);
> @@ -295,7 +295,7 @@ ip6_output(struct mbuf *m0, struct ip6_p
>                */
>               if (exthdrs.ip6e_dest2) {
>                       if (!hdrsplit)
> -                             panic("assumption failed: hdr not split");
> +                             panic("%s: assumption failed: hdr not split", 
> __func__);
>                       exthdrs.ip6e_dest2->m_next = m->m_next;
>                       m->m_next = exthdrs.ip6e_dest2;
>                       *mtod(exthdrs.ip6e_dest2, u_char *) = ip6->ip6_nxt;
> @@ -1761,7 +1761,7 @@ ip6_getpcbopt(struct ip6_pktopts *pktopt
>               break;
>       default:                /* should not happen */
> #ifdef DIAGNOSTIC
> -             panic("ip6_getpcbopt: unexpected option");
> +             panic("%s: unexpected option", __func__);
> #endif
>               return (ENOPROTOOPT);
>       }
> Index: nd6.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/nd6.c,v
> retrieving revision 1.228
> diff -u -p -r1.228 nd6.c
> --- nd6.c     7 Nov 2019 11:23:24 -0000       1.228
> +++ nd6.c     11 Nov 2019 06:18:42 -0000
> @@ -177,7 +177,7 @@ nd6_option(union nd_opts *ndopts)
>       int olen;
> 
>       if (!ndopts)
> -             panic("ndopts == NULL in nd6_option");
> +             panic("%s: ndopts == NULL", __func__);
>       if (!ndopts->nd_opts_last)
>               panic("%s: uninitialized ndopts", __func__);
>       if (!ndopts->nd_opts_search)
> @@ -228,7 +228,7 @@ nd6_options(union nd_opts *ndopts)
>       int i = 0;
> 
>       if (!ndopts)
> -             panic("ndopts == NULL in nd6_options");
> +             panic("%s: ndopts == NULL", __func__);
>       if (!ndopts->nd_opts_last)
>               panic("%s: uninitialized ndopts", __func__);
>       if (!ndopts->nd_opts_search)
> @@ -1091,9 +1091,9 @@ nd6_cache_lladdr(struct ifnet *ifp, stru
>       int newstate = 0;
> 
>       if (!ifp)
> -             panic("ifp == NULL in nd6_cache_lladdr");
> +             panic("%s: ifp == NULL", __func__);
>       if (!from)
> -             panic("from == NULL in nd6_cache_lladdr");
> +             panic("%s: from == NULL", __func__);
> 
>       /* nothing must be updated for unspecified address */
>       if (IN6_IS_ADDR_UNSPECIFIED(from))
> Index: nd6_nbr.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/nd6_nbr.c,v
> retrieving revision 1.128
> diff -u -p -r1.128 nd6_nbr.c
> --- nd6_nbr.c 18 Oct 2019 18:35:32 -0000      1.128
> +++ nd6_nbr.c 11 Nov 2019 06:18:42 -0000
> @@ -377,9 +377,9 @@ nd6_ns_output(struct ifnet *ifp, struct   maxlen +=
> (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
> #ifdef DIAGNOSTIC
>       if (max_linkhdr + maxlen >= MCLBYTES) {
> -             printf("nd6_ns_output: max_linkhdr + maxlen >= MCLBYTES "
> -                 "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
> -             panic("nd6_ns_output: insufficient MCLBYTES");
> +             printf("%s: max_linkhdr + maxlen >= MCLBYTES "
> +                 "(%d + %d > %d)\n", __func__, max_linkhdr, maxlen, 
> MCLBYTES);
> +             panic("%s: insufficient MCLBYTES", __func__);
>               /* NOTREACHED */
>       }
> #endif
> @@ -893,9 +893,9 @@ nd6_na_output(struct ifnet *ifp, struct   maxlen +=
> (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
> #ifdef DIAGNOSTIC
>       if (max_linkhdr + maxlen >= MCLBYTES) {
> -             printf("nd6_na_output: max_linkhdr + maxlen >= MCLBYTES "
> -                 "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
> -             panic("nd6_na_output: insufficient MCLBYTES");
> +             printf("%s: max_linkhdr + maxlen >= MCLBYTES "
> +                 "(%d + %d > %d)\n", __func__, max_linkhdr, maxlen, 
> MCLBYTES);
> +             panic("%s: insufficient MCLBYTES", __func__);
>               /* NOTREACHED */
>       }
> #endif
> @@ -1323,7 +1323,7 @@ nd6_dad_ns_input(struct ifaddr *ifa)
>       int duplicate;
> 
>       if (!ifa)
> -             panic("ifa == NULL in nd6_dad_ns_input");
> +             panic("%s: ifa == NULL", __func__);
> 
>       duplicate = 0;
>       dp = nd6_dad_find(ifa);
> Index: raw_ip6.c
> ===================================================================
> RCS file: /home/nayden/cvsync/src/sys/netinet6/raw_ip6.c,v
> retrieving revision 1.136
> diff -u -p -r1.136 raw_ip6.c
> --- raw_ip6.c 23 Apr 2019 11:01:54 -0000      1.136
> +++ raw_ip6.c 11 Nov 2019 06:18:42 -0000
> @@ -580,7 +580,7 @@ rip6_usrreq(struct socket *so, int req,   case PRU_ABORT:
>               soisdisconnected(so);
>               if (in6p == NULL)
> -                     panic("rip6_detach");
> +                     panic("%s", __func__);
> #ifdef MROUTING
>               if (so == ip6_mrouter[in6p->inp_rtableid])
>                       ip6_mrouter_done(so);
> @@ -698,7 +698,7 @@ rip6_usrreq(struct socket *so, int req,           break;
> 
>       default:
> -             panic("rip6_usrreq");
> +             panic("%s", __func__);
>       }
> release:
>       if (req != PRU_RCVD && req != PRU_RCVOOB && req != PRU_SENSE) {
> @@ -715,7 +715,7 @@ rip6_attach(struct socket *so, int proto
>       int error;
> 
>       if (so->so_pcb)
> -             panic("rip6_attach");
> +             panic("%s", __func__);
>       if ((so->so_state & SS_PRIV) == 0)
>               return (EACCES);
>       if (proto < 0 || proto >= IPPROTO_MAX)
> @@ -749,7 +749,7 @@ rip6_detach(struct socket *so)
>       soassertlocked(so);
> 
>       if (in6p == NULL)
> -             panic("rip6_detach");
> +             panic("%s", __func__);
> #ifdef MROUTING
>       if (so == ip6_mrouter[in6p->inp_rtableid])
>               ip6_mrouter_done(so);
> 

Reply via email to