All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Michael Lukashov <michael.lukashov@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/4] Refactoring: connect.c: move duplicated code to get_host_and_port
Date: Mon, 15 Feb 2010 22:11:56 +0100	[thread overview]
Message-ID: <4B79B89C.1050603@kdbg.org> (raw)
In-Reply-To: <1266182863-5048-2-git-send-email-michael.lukashov@gmail.com>

Michael Lukashov schrieb:
> +static void get_host_and_port(char **host, const char **port, int set_port_none)

Minor nit: The last parameter, set_port_none, is a rather prominent sign 
that this function mixes policy and functionality. And indeed, this 
implementation:

> +	if (colon) {
> +		*colon = 0;
> +		*port = colon + 1;
> +		if (set_port_none && !**port)
> +			*port = "<none>";
> +	}

proves it. The _functionality_ is to find host and port from a string. The 
_policy_ is to set the port to "<none>" if it would otherwise be empty. 
The callers take care of the _policy_, this function should only care 
about _functionality_. There's only one call site that wants "<none>"; 
don't move this detail into this function.

Other than that: nice catch.

-- Hannes

  reply	other threads:[~2010-02-15 21:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14 21:27 [PATCH 1/4] Refactoring: remove duplicated code from transport.c and builtin-send-pack.c Michael Lukashov
2010-02-14 21:27 ` [PATCH 2/4] Refactoring: connect.c: move duplicated code to get_host_and_port Michael Lukashov
2010-02-15 21:11   ` Johannes Sixt [this message]
2010-02-14 21:27 ` [PATCH 3/4] Refactoring: move duplicated code from builtin-pack-objects.c and fast-import.c to object.c Michael Lukashov
2010-02-14 21:27 ` [PATCH 4/4] Refactoring: remove duplicated code from builtin-checkout.c and merge-recursive.c Michael Lukashov
2010-02-15  3:29 ` [PATCH 1/4] Refactoring: remove duplicated code from transport.c and builtin-send-pack.c Tay Ray Chuan
2010-02-15  5:28 ` Jeff King
2010-02-15  6:34   ` Junio C Hamano
2010-02-15  7:55     ` Jeff King
2010-02-15  8:46       ` Ilari Liusvaara
2010-02-15 18:25       ` Daniel Barkalow
     [not found]     ` <7v635zj8jr.fsf@alter.siamese.dyndns.org>
2010-02-15 17:30       ` Larry D'Anna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B79B89C.1050603@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=michael.lukashov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.