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


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] fix some warning


This patch fixes some of the warning I see with gcc-3.3 of the nature <warning: comparison between signed and unsigned>. There are many of these that may obscure more important warnings (like pointer to int casts). So I thought I would start chipping away some of the simpler cases.

2003-05-07 Steven Munroe <sjmunroe@us.ibm.com>

	* nss/nss_files/files-netgrp.c (_nss_netgroup_parseline): Cast
	pointer difference to size_t for comparison.
	* resolv/ns_print.c (ns_sprintrrf): Change siz type to size_t.
	* resolv/nss_dns/dns-network.c (getanswer_r): Cast char
	difference to unsigned for comparison.
	* time/strptime.c (strptime_internal): Change val type to
	size_t.
diff -rup libc23-cvstip-20030505/nss/nss_files/files-netgrp.c libc23/nss/nss_files/files-netgrp.c
--- libc23-cvstip-20030505/nss/nss_files/files-netgrp.c	2001-07-05 23:55:38.000000000 -0500
+++ libc23/nss/nss_files/files-netgrp.c	2003-05-06 11:08:26.000000000 -0500
@@ -243,7 +243,7 @@ _nss_netgroup_parseline (char **cursor, 
 
   /* When we got here we have found an entry.  Before we can copy it
      to the private buffer we have to make sure it is big enough.  */
-  if (cp - host > buflen)
+  if ((size_t)(cp - host) > buflen)
     {
       *errnop = ERANGE;
       status = NSS_STATUS_UNAVAIL;
diff -rup libc23-cvstip-20030505/resolv/ns_print.c libc23/resolv/ns_print.c
--- libc23-cvstip-20030505/resolv/ns_print.c	2002-11-01 14:43:45.000000000 -0600
+++ libc23/resolv/ns_print.c	2003-05-06 11:11:23.000000000 -0500
@@ -570,7 +570,8 @@ ns_sprintrrf(const u_char *msg, size_t m
 
 	case ns_t_cert: {
 		u_int c_type, key_tag, alg;
-		int n, siz;
+		int n;
+		size_t siz;
 		char base64_cert[8192], *leader, tmp[40];
 
 		c_type  = ns_get16(rdata); rdata += NS_INT16SZ;
diff -rup libc23-cvstip-20030505/resolv/nss_dns/dns-network.c libc23/resolv/nss_dns/dns-network.c
--- libc23-cvstip-20030505/resolv/nss_dns/dns-network.c	2003-01-01 10:29:36.000000000 -0600
+++ libc23/resolv/nss_dns/dns-network.c	2003-05-06 11:09:43.000000000 -0500
@@ -420,7 +420,7 @@ getanswer_r (const querybuf *answer, int
 		    uint32_t part = 0; /* Accumulates this part's number.  */
 		    do
 		      {
-			if (isdigit (*p) && (*p - '0' < base))
+			if (isdigit (*p) && ((unsigned int)(*p - '0') < base))
 			  part = (part * base) + (*p - '0');
 			else if (base == 16 && isxdigit (*p))
 			  part = (part << 4) + 10 + (tolower (*p) - 'a');
diff -rup libc23-cvstip-20030505/time/strptime.c libc23/time/strptime.c
--- libc23-cvstip-20030505/time/strptime.c	2002-11-24 12:39:35.000000000 -0600
+++ libc23/time/strptime.c	2003-05-06 14:54:22.000000000 -0500
@@ -290,7 +290,7 @@ strptime_internal (rp, fmt, tm, decided,
 
   const char *rp_backup;
   int cnt;
-  size_t val;
+  int val;
   int have_I, is_pm;
   int century, want_century;
   int want_era;

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