[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Nbd] [PATCH 1/1] server: remove non-reachable call to err()



On Sun, Mar 10, 2013 at 10:42:06PM +0200, Tuomas Räsänen wrote:
> Currently, all places where append_serve() is called from, ensure that
> the server argument is never NULL.
> 
> Furthermore,
> 
> - exiting on error inside a "util" function is bad practice, it makes it
>   almost impossible to use the function from other code paths
> 
> - appending NULL server does not make any sense, therefore checking for
>   NULL is pointless, it's a programmer error to call append_serve() with
>   NULL

Mmm. Checking for programmer error isn't necessarily a bad idea, though.
Yes, it's best done at compile time, but that isn't always possible.

Perhaps change it into an assert() instead?

> Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@...1261...>
> ---
>  nbd-server.c |    3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/nbd-server.c b/nbd-server.c
> index 27c4600..554c423 100644
> --- a/nbd-server.c
> +++ b/nbd-server.c
> @@ -710,9 +710,6 @@ int append_serve(const SERVER *const s, GArray *const a) {
>  	int e;
>  	int ret;
>  
> -	if(!s)
> -		err("Invalid parsing server");
> -
>  	port = g_strdup_printf("%d", s->port);
>  
>  	memset(&hints,'\0',sizeof(hints));
> -- 
> 1.7.10.4
> 
> 
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
> endpoint security space. For insight on selecting the right partner to 
> tackle endpoint security challenges, access the full report. 
> http://p.sf.net/sfu/symantec-dev2dev
> _______________________________________________
> Nbd-general mailing list
> Nbd-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nbd-general

-- 
Copyshops should do vouchers. So that next time some bureaucracy requires you
to mail a form in triplicate, you can mail it just once, add a voucher, and
save on postage.



Reply to: