Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 May 2016 17:31:36 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Garrett Cooper <ngie@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r300935 - head/usr.sbin/rpc.statd
Message-ID:  <20160529171235.A1958@besplex.bde.org>
In-Reply-To: <201605290418.u4T4IlWI057643@repo.freebsd.org>
References:  <201605290418.u4T4IlWI057643@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 29 May 2016, Garrett Cooper wrote:

> Log:
>  Mark out_of_mem(..) and usage(..) with __dead2 as they both directly call exit
>  as a hint to static analysis tools

This is bogus for usage() since it is static so only very broken static
analyis tools can't see its full details.

> Modified: head/usr.sbin/rpc.statd/statd.c
> ==============================================================================
> --- head/usr.sbin/rpc.statd/statd.c	Sun May 29 04:02:02 2016	(r300934)
> +++ head/usr.sbin/rpc.statd/statd.c	Sun May 29 04:18:47 2016	(r300935)
> @@ -72,9 +72,9 @@ static int	create_service(struct netconf
> static void	complete_service(struct netconfig *nconf, char *port_str);
> static void	clearout_service(void);
> static void handle_sigchld(int sig);
> -void out_of_mem(void);
> +void out_of_mem(void) __dead2;

This is even more bogus:
- out_of_mem() is public, and this adds __dead2 in the one place that clearly
   doesn't need it
- the declarartions are unsorted internally and externally.  Prototypes for
   public functions belong in a header file.  Some are already there, but
   this one is unsorted into the middle of static ones
- however, perhaps this function should be static.  It is only directly
   referenced in this file.  I don't know if it is also referenced in some
   other utility or rpc generated code.  If so, then these are probably
   missing the __dead2.

> -static void usage(void);
> +static void usage(void) __dead2;

There are also many lexical (indentation) style bugs near here, in all of
the newer prototypes starting with handle_sigchld().

>
> int
> main(int argc, char **argv)
> @@ -613,7 +613,7 @@ clearout_service(void)
> }
>
> static void
> -usage()
> +usage(void)

Perhaps Coverity was just complaining about this K&R definition.  No change
was needed, since there is a prototype in scope.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160529171235.A1958>