Re: [PATCH v3 2/4] Refactoring: connect.c: move duplicated code to a new function 'get_host_and_port'

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

 



On Wed, Feb 17, 2010 at 3:04 AM, Larry D'Anna <larry@xxxxxxxxxxxxxx> wrote:
> * Michael Lukashov (michael.lukashov@xxxxxxxxx) [100216 18:43]:
>
>> @@ -170,30 +192,14 @@ static const char *ai_name(const struct addrinfo *ai)
>>  static int git_tcp_connect_sock(char *host, int flags)
>>  {
>>       int sockfd = -1, saved_errno = 0;
>> -     char *colon, *end;
>>       const char *port = STR(DEFAULT_GIT_PORT);
>>       struct addrinfo hints, *ai0, *ai;
>>       int gai;
>>       int cnt = 0;
>>
>> -     if (host[0] == '[') {
>> -             end = strchr(host + 1, ']');
>> -             if (end) {
>> -                     *end = 0;
>> -                     end++;
>> -                     host++;
>> -             } else
>> -                     end = host;
>> -     } else
>> -             end = host;
>> -     colon = strchr(end, ':');
>> -
>> -     if (colon) {
>> -             *colon = 0;
>> -             port = colon + 1;
>> -             if (!*port)
>> -                     port = "<none>";
>> -     }
>> +     get_host_and_port(&host, &port);
>> +     if (!*port)
>> +             *port = "<none>";
>
> Again, isn't this wrong?  This doesn't even compile for me.  Shouldn't it be
>
> port = "<none>";
>
> ??
>
> What am I missing?
>
>     --larry
>

Oops, my bad, sorry.
Strange, my mingw-gcc 4.4.0 compiler didn't issue no errors or
warnings. Weird indeed.
I'll send repaired patch later.
��.n��������+%������w��{.n��������n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�m


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]