* [Patch] gethostby_helper
@ 2011-08-16 23:39 Pierre A. Humblet
2011-08-17 0:14 ` Christopher Faylor
0 siblings, 1 reply; 2+ messages in thread
From: Pierre A. Humblet @ 2011-08-16 23:39 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 3455 bytes --]
This patch has already been already applied.
Diff in attachment and also below.
Pierre
2011-08-16 Pierre Humblet <Pierre.Humblet@ieee.org>
* net.cc (gethostby_helper): Remove DEBUGGING code from and
streamline the second pass.
Index: net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/net.cc,v
retrieving revision 1.289
diff -u -p -r1.289 net.cc
--- net.cc 4 Aug 2011 08:22:11 -0000 1.289
+++ net.cc 16 Aug 2011 23:31:44 -0000
@@ -1198,57 +1198,34 @@ gethostby_helper (const char *name, cons
string_ptr = (char *) (ret->h_addr_list + address_count + 1);
/* Rescan the answers */
- ancount = alias_count + address_count; /* Valid records */
alias_count = address_count = 0;
+ prevptr->set_next (prevptr + 1);
- for (i = 0, curptr = anptr; i < ancount; i++, curptr = curptr->next ())
+ for (curptr = anptr; curptr <= prevptr; curptr = curptr->next ())
{
antype = curptr->type;
if (antype == ns_t_cname)
{
- complen = dn_expand (msg, eomsg, curptr->name (),
string_ptr, string_size);
-#ifdef DEBUGGING
- if (complen != curptr->complen)
- goto debugging;
-#endif
+ dn_expand (msg, eomsg, curptr->name (), string_ptr,
curptr->namelen1);
ret->h_aliases[alias_count++] = string_ptr;
- namelen1 = curptr->namelen1;
- string_ptr += namelen1;
- string_size -= namelen1;
- continue;
+ string_ptr += curptr->namelen1;
}
- if (antype == type)
+ else
+ {
+ if (address_count == 0)
{
- if (address_count == 0)
- {
- complen = dn_expand (msg, eomsg, curptr->name(),
string_ptr, string_size);
-#ifdef DEBUGGING
- if (complen != curptr->complen)
- goto debugging;
-#endif
- ret->h_name = string_ptr;
- namelen1 = curptr->namelen1;
- string_ptr += namelen1;
- string_size -= namelen1;
- }
- ret->h_addr_list[address_count++] = string_ptr;
- if (addrsize_in != addrsize_out)
- memcpy4to6 (string_ptr, curptr->data);
- else
- memcpy (string_ptr, curptr->data, addrsize_in);
- string_ptr += addrsize_out;
- string_size -= addrsize_out;
- continue;
- }
-#ifdef DEBUGGING
- /* Should not get here */
- goto debugging;
-#endif
+ dn_expand (msg, eomsg, curptr->name (), string_ptr,
curptr->namelen1);
+ ret->h_name = string_ptr;
+ string_ptr += curptr->namelen1;
+ }
+ ret->h_addr_list[address_count++] = string_ptr;
+ if (addrsize_in != addrsize_out)
+ memcpy4to6 (string_ptr, curptr->data);
+ else
+ memcpy (string_ptr, curptr->data, addrsize_in);
+ string_ptr += addrsize_out;
+ }
}
-#ifdef DEBUGGING
- if (string_size < 0)
- goto debugging;
-#endif
free (msg);
@@ -1263,16 +1240,6 @@ gethostby_helper (const char *name, cons
Should it be NO_RECOVERY ? */
h_errno = TRY_AGAIN;
return NULL;
-
-
-#ifdef DEBUGGING
- debugging:
- system_printf ("Please debug.");
- free (msg);
- free (ret);
- h_errno = NO_RECOVERY;
- return NULL;
-#endif
}
/* gethostbyname2: standards? */
[-- Attachment #2: net.cc.diff --]
[-- Type: application/octet-stream, Size: 2827 bytes --]
Index: net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/net.cc,v
retrieving revision 1.289
diff -u -p -r1.289 net.cc
--- net.cc 4 Aug 2011 08:22:11 -0000 1.289
+++ net.cc 16 Aug 2011 23:31:44 -0000
@@ -1198,57 +1198,34 @@ gethostby_helper (const char *name, cons
string_ptr = (char *) (ret->h_addr_list + address_count + 1);
/* Rescan the answers */
- ancount = alias_count + address_count; /* Valid records */
alias_count = address_count = 0;
+ prevptr->set_next (prevptr + 1);
- for (i = 0, curptr = anptr; i < ancount; i++, curptr = curptr->next ())
+ for (curptr = anptr; curptr <= prevptr; curptr = curptr->next ())
{
antype = curptr->type;
if (antype == ns_t_cname)
{
- complen = dn_expand (msg, eomsg, curptr->name (), string_ptr, string_size);
-#ifdef DEBUGGING
- if (complen != curptr->complen)
- goto debugging;
-#endif
+ dn_expand (msg, eomsg, curptr->name (), string_ptr, curptr->namelen1);
ret->h_aliases[alias_count++] = string_ptr;
- namelen1 = curptr->namelen1;
- string_ptr += namelen1;
- string_size -= namelen1;
- continue;
+ string_ptr += curptr->namelen1;
}
- if (antype == type)
+ else
+ {
+ if (address_count == 0)
{
- if (address_count == 0)
- {
- complen = dn_expand (msg, eomsg, curptr->name(), string_ptr, string_size);
-#ifdef DEBUGGING
- if (complen != curptr->complen)
- goto debugging;
-#endif
- ret->h_name = string_ptr;
- namelen1 = curptr->namelen1;
- string_ptr += namelen1;
- string_size -= namelen1;
- }
- ret->h_addr_list[address_count++] = string_ptr;
- if (addrsize_in != addrsize_out)
- memcpy4to6 (string_ptr, curptr->data);
- else
- memcpy (string_ptr, curptr->data, addrsize_in);
- string_ptr += addrsize_out;
- string_size -= addrsize_out;
- continue;
- }
-#ifdef DEBUGGING
- /* Should not get here */
- goto debugging;
-#endif
+ dn_expand (msg, eomsg, curptr->name (), string_ptr, curptr->namelen1);
+ ret->h_name = string_ptr;
+ string_ptr += curptr->namelen1;
+ }
+ ret->h_addr_list[address_count++] = string_ptr;
+ if (addrsize_in != addrsize_out)
+ memcpy4to6 (string_ptr, curptr->data);
+ else
+ memcpy (string_ptr, curptr->data, addrsize_in);
+ string_ptr += addrsize_out;
+ }
}
-#ifdef DEBUGGING
- if (string_size < 0)
- goto debugging;
-#endif
free (msg);
@@ -1263,16 +1240,6 @@ gethostby_helper (const char *name, cons
Should it be NO_RECOVERY ? */
h_errno = TRY_AGAIN;
return NULL;
-
-
-#ifdef DEBUGGING
- debugging:
- system_printf ("Please debug.");
- free (msg);
- free (ret);
- h_errno = NO_RECOVERY;
- return NULL;
-#endif
}
/* gethostbyname2: standards? */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] gethostby_helper
2011-08-16 23:39 [Patch] gethostby_helper Pierre A. Humblet
@ 2011-08-17 0:14 ` Christopher Faylor
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Faylor @ 2011-08-17 0:14 UTC (permalink / raw)
To: cygwin-patches
On Tue, Aug 16, 2011 at 07:38:26PM -0400, Pierre A. Humblet wrote:
>This patch has already been already applied.
>Diff in attachment and also below.
>
>Pierre
>
>2011-08-16 Pierre Humblet <Pierre.Humblet@ieee.org>
>
> * net.cc (gethostby_helper): Remove DEBUGGING code from and
> streamline the second pass.
Thanks Pierre.
cgf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-17 0:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-16 23:39 [Patch] gethostby_helper Pierre A. Humblet
2011-08-17 0:14 ` Christopher Faylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).