Re: [Nbd] [PATCH 1/1] server: remove non-reachable call to err()
- To: Tuomas Räsänen <tuomasjjrasanen@...1258...>
- Cc: nbd-general@lists.sourceforge.net
- Subject: Re: [Nbd] [PATCH 1/1] server: remove non-reachable call to err()
- From: Wouter Verhelst <w@...112...>
- Date: Sun, 10 Mar 2013 22:15:07 +0100
- Message-id: <20130310211507.GA23754@...3...>
- In-reply-to: <4872930b34a4b68d73810e4e31f9fa0d522e0aac.1362947875.git.tuomasjjrasanen@...1261...>
- References: <4872930b34a4b68d73810e4e31f9fa0d522e0aac.1362947875.git.tuomasjjrasanen@...1261...>
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: