[Date Prev][Date Next] [Chronological] [Thread] [Top]

Compile errors in liblber/encode.c 1.31 (ITS#388)



Full_Name: Steven Sonntag
Version: development
OS: WinNT
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (137.65.214.133)


liblber/encode.c gets compile errors in version 1.31 on WinNT using VC++ 5.0

An example follows:
.\liblber\encode.c(95) : warning C4101: 'xtag' : unreferenced local variable
.\liblber\encode.c(536) : warning C4018: '<' : signed/unsigned mismatch
.\liblber\encode.c(540) : warning C4244: '=' : conversion from 'unsigned long '
to 'unsigned char ', possible loss of data

I made the following changes to correct the compile errors expressed in diff
format:
78d77
< 	ber_tag_t	xtag;
86c85
< 		nettag[(sizeof(ber_tag_t)-1) - i] = tag & 0xffU;
---
> 		nettag[(sizeof(ber_tag_t)-1) - i] = (unsigned char)(tag & 0xffU);
131d129
< 	ber_len_t	xlen;
169c167
< 		netlen[(sizeof(ber_len_t)-1) - j] = len & 0xffU;
---
> 		netlen[(sizeof(ber_len_t)-1) - j] = (unsigned char)(len & 0xffU);
190c188
< 	ber_uint_t	unum, xnum, mask;
---
> 	ber_uint_t	unum, mask;
506c504,505
< 	int rc, i;
---
> 	int rc;
> 	unsigned i;
539c538
< 			netlen[(sizeof(ber_len_t)-1) - i] = (len >> i*8) & 0xffU;
---
> 			netlen[(sizeof(ber_len_t)-1) - i] = (unsigned char)((len >> i*8) & 0xffU);
542c541
< 		netlen[sizeof(ber_len_t)-1] = len & 0x7fU;
---
> 		netlen[sizeof(ber_len_t)-1] = (unsigned char)(len & 0x7fU);
584c583
< 		int i;
---
> 		unsigned i;
592c591
< 			nettag[(sizeof(ber_tag_t)-1) - i] = tmptag & 0xffU;
---
> 			nettag[(sizeof(ber_tag_t)-1) - i] = (unsigned char)(tmptag & 0xffU);
--------------------------------------------
or in diff -u format
--------------------------------------------
--- ldap/libraries/liblber/encode.c	Wed Dec 01 17:08:56 1999
+++ encode.c	Thu Dec 02 17:44:34 1999
@@ -75,7 +75,6 @@
 	ber_len_t	taglen;
 	ber_len_t	i;
 	unsigned char nettag[sizeof(ber_tag_t)];
-	ber_tag_t	xtag;
 
 	assert( ber != NULL );
 	assert( BER_VALID( ber ) );
@@ -83,7 +82,7 @@
 	taglen = ber_calc_taglen( tag );
 
 	for( i=0; i<taglen; i++ ) {
-		nettag[(sizeof(ber_tag_t)-1) - i] = tag & 0xffU;
+		nettag[(sizeof(ber_tag_t)-1) - i] = (unsigned char)(tag & 0xffU);
 		tag >>= 8;
 	}
 
@@ -128,7 +127,6 @@
 	char		lenlen;
 	ber_len_t	mask;
 	unsigned char netlen[sizeof(ber_len_t)];
-	ber_len_t	xlen;
 
 	assert( ber != NULL );
 	assert( BER_VALID( ber ) );
@@ -166,7 +164,7 @@
 		return( -1 );
 
 	for( j=0; j<i; j++) {
-		netlen[(sizeof(ber_len_t)-1) - j] = len & 0xffU;
+		netlen[(sizeof(ber_len_t)-1) - j] = (unsigned char)(len & 0xffU);
 		len >>= 8;
 	}
 
@@ -187,7 +185,7 @@
 	int rc;
 	int	i, j, sign;
 	ber_len_t	len, lenlen, taglen;
-	ber_uint_t	unum, xnum, mask;
+	ber_uint_t	unum, mask;
 	unsigned char netnum[sizeof(ber_uint_t)];
 
 	assert( ber != NULL );
@@ -503,7 +501,8 @@
 static int
 ber_put_seqorset( BerElement *ber )
 {
-	int rc, i;
+	int rc;
+	unsigned i;
 	ber_len_t	len;
 	unsigned char netlen[sizeof(ber_len_t)];
 	ber_len_t	taglen, lenlen;
@@ -536,10 +535,10 @@
 
 	if( lenlen > 1 ) {
 		for( i=0; i < lenlen-1; i++ ) {
-			netlen[(sizeof(ber_len_t)-1) - i] = (len >> i*8) & 0xffU;
+			netlen[(sizeof(ber_len_t)-1) - i] = (unsigned char)((len >> i*8) & 0xffU);
 		}
 	} else {
-		netlen[sizeof(ber_len_t)-1] = len & 0x7fU;
+		netlen[sizeof(ber_len_t)-1] = (unsigned char)(len & 0x7fU);
 	}
 
 	if ( (next = (*sos)->sos_next) == NULL ) {
@@ -581,7 +580,7 @@
 		(*sos)->sos_ber->ber_ptr += len;
 
 	} else {
-		int i;
+		unsigned i;
 		unsigned char nettag[sizeof(ber_tag_t)];
 		ber_tag_t tmptag = (*sos)->sos_tag;
 
@@ -589,7 +588,7 @@
 		taglen = ber_calc_taglen( tmptag );
 
 		for( i = 0; i < taglen; i++ ) {
-			nettag[(sizeof(ber_tag_t)-1) - i] = tmptag & 0xffU;
+			nettag[(sizeof(ber_tag_t)-1) - i] = (unsigned char)(tmptag & 0xffU);
 			tmptag >>= 8;
 		}