[PATCH] Fix getaddrinfo
Jakub Jelinek
jakub@redhat.com
Thu Feb 1 07:44:00 GMT 2001
Hi!
Since gaih_typeproto's name is now 4byte array, not char pointer, it makes
no sense to compare it to NULL because it is always non-NULL. We have to
test whether it is "" string instead.
2001-02-01 Jakub Jelinek <jakub@redhat.com>
* sysdeps/posix/getaddrinfo.c (gaih_local, gaih_inet): Replace all
tp->name tests with tp->name[0] tests.
--- libc/sysdeps/posix/getaddrinfo.c.jj Wed Jan 31 16:35:22 2001
+++ libc/sysdeps/posix/getaddrinfo.c Thu Feb 1 17:43:42 2001
@@ -151,7 +151,7 @@ gaih_local (const char *name, const stru
{
const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
- while (tp->name != NULL
+ while (tp->name[0]
&& ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
|| (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
|| (req->ai_protocol != 0
@@ -159,7 +159,7 @@ gaih_local (const char *name, const stru
&& req->ai_protocol != tp->protocol)))
++tp;
- if (tp->name == NULL)
+ if (! tp->name[0])
{
if (req->ai_socktype)
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
@@ -324,14 +324,14 @@ gaih_inet (const char *name, const struc
{
++tp;
- while (tp->name != NULL
+ while (tp->name[0]
&& ((req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
|| (req->ai_protocol != 0
&& !(tp->protoflag & GAI_PROTO_PROTOANY)
&& req->ai_protocol != tp->protocol)))
++tp;
- if (tp->name == NULL)
+ if (! tp->name[0])
{
if (req->ai_socktype)
return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
@@ -347,7 +347,7 @@ gaih_inet (const char *name, const struc
if (service->num < 0)
{
- if (tp->name != NULL)
+ if (tp->name[0])
{
st = (struct gaih_servtuple *)
__alloca (sizeof (struct gaih_servtuple));
@@ -358,7 +358,7 @@ gaih_inet (const char *name, const struc
else
{
struct gaih_servtuple **pst = &st;
- for (tp++; tp->name; tp++)
+ for (tp++; tp->name[0]; tp++)
{
struct gaih_servtuple *newp;
@@ -414,7 +414,7 @@ gaih_inet (const char *name, const struc
/* Neither socket type nor protocol is set. Return all socket types
we know about. */
struct gaih_servtuple **lastp = &st;
- for (++tp; tp->name != NULL; ++tp)
+ for (++tp; tp->name[0]; ++tp)
{
struct gaih_servtuple *newp;
Jakub
More information about the Libc-hacker
mailing list