This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Warning fixes


Hi!

../sysdeps/posix/getaddrinfo.c: In function `gaih_inet':
../sysdeps/posix/getaddrinfo.c:859: warning: assignment discards qualifiers from pointer target type
nss_dns/dns-canon.c: In function `_nss_dns_getcanonname_r':
nss_dns/dns-canon.c:55: warning: 'status' might be used uninitialized in this function

The former is because ai_canonname is char *, while canon is const char *.
No idea if char * ai_canonname is in the standard just for historical
reasons or if it actually ought to be writable.

The latter sounds like a bug, if both A and AAAA queries fail,
_nss_dns_getcanonname_r would return the unitialized status value,
so with bad luck it could be NSS_STATUS_SUCCESS which is the only value
the caller cares about.

2004-08-19  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/posix/getaddrinfo.c (gaih_inet): Cast canon to (char *)
	to avoid warning.

	* resolv/nss_dns/dns-canon.c (_nss_dns_getcanonname_r): Initialize
	status to NSS_STATUS_UNAVAIL.

--- libc/sysdeps/posix/getaddrinfo.c.jj	2004-08-19 12:18:26.000000000 +0200
+++ libc/sysdeps/posix/getaddrinfo.c	2004-08-19 12:22:23.251899931 +0200
@@ -856,7 +856,7 @@ gaih_inet (const char *name, const struc
 	    (*pai)->ai_addr = (void *) (*pai + 1);
 
 	    /* We only add the canonical name once.  */
-	    (*pai)->ai_canonname = canon;
+	    (*pai)->ai_canonname = (char *) canon;
 	    canon = NULL;
 
 #if SALEN
--- libc/resolv/nss_dns/dns-canon.c.jj	2004-08-16 19:13:13.000000000 +0200
+++ libc/resolv/nss_dns/dns-canon.c	2004-08-19 12:24:36.573339586 +0200
@@ -52,7 +52,7 @@ _nss_dns_getcanonname_r (const char *nam
     querybuf *buf;
     unsigned char *ptr;
   } ansp = { .ptr = buf };
-  enum nss_status status;
+  enum nss_status status = NSS_STATUS_UNAVAIL;
   int qtypes[] = { ns_t_a, ns_t_aaaa };
 #define nqtypes (sizeof (qtypes) / sizeof (qtypes[0]))
 


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]