Module Name:    src
Committed By:   roy
Date:           Thu May  4 09:46:30 UTC 2017

Modified Files:
        src/lib/libterminfo: compile.c

Log Message:
Clean up some more warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libterminfo/compile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libterminfo/compile.c
diff -u src/lib/libterminfo/compile.c:1.11 src/lib/libterminfo/compile.c:1.12
--- src/lib/libterminfo/compile.c:1.11	Sat Feb 11 15:13:17 2017
+++ src/lib/libterminfo/compile.c	Thu May  4 09:46:30 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: compile.c,v 1.11 2017/02/11 15:13:17 roy Exp $ */
+/* $NetBSD: compile.c,v 1.12 2017/05/04 09:46:30 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: compile.c,v 1.11 2017/02/11 15:13:17 roy Exp $");
+__RCSID("$NetBSD: compile.c,v 1.12 2017/05/04 09:46:30 roy Exp $");
 
 #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H
 #include <sys/endian.h>
@@ -90,7 +90,7 @@ char *
 _ti_find_cap(TBUF *tbuf, char type, short ind)
 {
 	size_t n;
-	short num;
+	uint16_t num;
 	char *cap;
 
 	_DIAGASSERT(tbuf != NULL);
@@ -99,7 +99,7 @@ _ti_find_cap(TBUF *tbuf, char type, shor
 	for (n = tbuf->entries; n > 0; n--) {
 		num = le16dec(cap);
 		cap += sizeof(uint16_t);
-		if (num == ind)
+		if ((short)num == ind)
 			return cap;
 		switch (type) {
 		case 'f':
@@ -124,7 +124,7 @@ char *
 _ti_find_extra(TBUF *tbuf, const char *code)
 {
 	size_t n;
-	short num;
+	uint16_t num;
 	char *cap;
 
 	_DIAGASSERT(tbuf != NULL);
@@ -184,7 +184,7 @@ _ti_store_extra(TIC *tic, int wrn, char 
 	if (!_ti_grow_tbuf(&tic->extras,
 		l + strl + (sizeof(uint16_t) * 2) + 1))
 		return 0;
-	le16enc(tic->extras.buf + tic->extras.bufpos, l);
+	le16enc(tic->extras.buf + tic->extras.bufpos, (uint16_t)l);
 	tic->extras.bufpos += sizeof(uint16_t);
 	memcpy(tic->extras.buf + tic->extras.bufpos, id, l);
 	tic->extras.bufpos += l;
@@ -194,11 +194,11 @@ _ti_store_extra(TIC *tic, int wrn, char 
 		tic->extras.buf[tic->extras.bufpos++] = flag;
 		break;
 	case 'n':
-		le16enc(tic->extras.buf + tic->extras.bufpos, num);
+		le16enc(tic->extras.buf + tic->extras.bufpos, (uint16_t)num);
 		tic->extras.bufpos += sizeof(uint16_t);
 		break;
 	case 's':
-		le16enc(tic->extras.buf + tic->extras.bufpos, strl);
+		le16enc(tic->extras.buf + tic->extras.bufpos, (uint16_t)strl);
 		tic->extras.bufpos += sizeof(uint16_t);
 		memcpy(tic->extras.buf + tic->extras.bufpos, str, strl);
 		tic->extras.bufpos += strl;
@@ -240,18 +240,18 @@ _ti_flatten(uint8_t **buf, const TIC *ti
 
 	cap = *buf;
 	*cap++ = 1;
-	le16enc(cap, len);
+	le16enc(cap, (uint16_t)len);
 	cap += sizeof(uint16_t);
 	memcpy(cap, tic->name, len);
 	cap += len;
 
-	le16enc(cap, alen);
+	le16enc(cap, (uint16_t)alen);
 	cap += sizeof(uint16_t);
 	if (tic->alias != NULL) {
 		memcpy(cap, tic->alias, alen);
 		cap += alen;
 	}
-	le16enc(cap, dlen);
+	le16enc(cap, (uint16_t)dlen);
 	cap += sizeof(uint16_t);
 	if (tic->desc != NULL) {
 		memcpy(cap, tic->desc, dlen);
@@ -262,9 +262,9 @@ _ti_flatten(uint8_t **buf, const TIC *ti
 		le16enc(cap, 0);
 		cap += sizeof(uint16_t);
 	} else {
-		le16enc(cap, (tic->flags.bufpos + sizeof(uint16_t)));
+		le16enc(cap, (uint16_t)(tic->flags.bufpos + sizeof(uint16_t)));
 		cap += sizeof(uint16_t);
-		le16enc(cap, tic->flags.entries);
+		le16enc(cap, (uint16_t)tic->flags.entries);
 		cap += sizeof(uint16_t);
 		memcpy(cap, tic->flags.buf, tic->flags.bufpos);
 		cap += tic->flags.bufpos;
@@ -274,9 +274,9 @@ _ti_flatten(uint8_t **buf, const TIC *ti
 		le16enc(cap, 0);
 		cap += sizeof(uint16_t);
 	} else {
-		le16enc(cap, (tic->nums.bufpos + sizeof(uint16_t)));
+		le16enc(cap, (uint16_t)(tic->nums.bufpos + sizeof(uint16_t)));
 		cap += sizeof(uint16_t);
-		le16enc(cap, tic->nums.entries);
+		le16enc(cap, (uint16_t)tic->nums.entries);
 		cap += sizeof(uint16_t);
 		memcpy(cap, tic->nums.buf, tic->nums.bufpos);
 		cap += tic->nums.bufpos;
@@ -286,9 +286,9 @@ _ti_flatten(uint8_t **buf, const TIC *ti
 		le16enc(cap, 0);
 		cap += sizeof(uint16_t);
 	} else {
-		le16enc(cap, (tic->strs.bufpos + sizeof(uint16_t)));
+		le16enc(cap, (uint16_t)(tic->strs.bufpos + sizeof(uint16_t)));
 		cap += sizeof(uint16_t);
-		le16enc(cap, tic->strs.entries);
+		le16enc(cap, (uint16_t)tic->strs.entries);
 		cap += sizeof(uint16_t);
 		memcpy(cap, tic->strs.buf, tic->strs.bufpos);
 		cap += tic->strs.bufpos;
@@ -298,9 +298,9 @@ _ti_flatten(uint8_t **buf, const TIC *ti
 		le16enc(cap, 0);
 		cap += sizeof(uint16_t);
 	} else {
-		le16enc(cap, (tic->extras.bufpos + sizeof(uint16_t)));
+		le16enc(cap, (uint16_t)(tic->extras.bufpos + sizeof(uint16_t)));
 		cap += sizeof(uint16_t);
-		le16enc(cap, tic->extras.entries);
+		le16enc(cap, (uint16_t)tic->extras.entries);
 		cap += sizeof(uint16_t);
 		memcpy(cap, tic->extras.buf, tic->extras.bufpos);
 		cap += tic->extras.bufpos;
@@ -413,7 +413,7 @@ encode_string(const char *term, const ch
 		last = ch;
 	}
 	*p++ = '\0';
-	tbuf->bufpos += p - s;
+	tbuf->bufpos += (size_t)(p - s);
 	return 0;
 }
 
@@ -457,8 +457,7 @@ _ti_compile(char *cap, int flags)
 	char *token, *p, *e, *name, *desc, *alias;
 	signed char flag;
 	long cnum;
-	short num;
-	ssize_t ind;
+	short ind, num;
 	size_t len;
 	TBUF buf;
 	TIC *tic;
@@ -518,7 +517,7 @@ _ti_compile(char *cap, int flags)
 		if (p != NULL) {
 			*p++ = '\0';
 			/* Don't use the string if we already have it */
-			ind = _ti_strindex(token);
+			ind = (short)_ti_strindex(token);
 			if (ind != -1 &&
 			    _ti_find_cap(&tic->strs, 's', ind) != NULL)
 				continue;
@@ -546,10 +545,10 @@ _ti_compile(char *cap, int flags)
 				if (!_ti_grow_tbuf(&tic->strs,
 					(sizeof(uint16_t) * 2) + buf.bufpos))
 					goto error;
-				le16enc(tic->strs.buf + tic->strs.bufpos, ind);
+				le16enc(tic->strs.buf + tic->strs.bufpos, (uint16_t)ind);
 				tic->strs.bufpos += sizeof(uint16_t);
 				le16enc(tic->strs.buf + tic->strs.bufpos,
-				    buf.bufpos);
+				    (uint16_t)buf.bufpos);
 				tic->strs.bufpos += sizeof(uint16_t);
 				memcpy(tic->strs.buf + tic->strs.bufpos,
 				    buf.buf, buf.bufpos);
@@ -564,7 +563,7 @@ _ti_compile(char *cap, int flags)
 		if (p != NULL) {
 			*p++ = '\0';
 			/* Don't use the number if we already have it */
-			ind = _ti_numindex(token);
+			ind = (short)_ti_numindex(token);
 			if (ind != -1 &&
 			    _ti_find_cap(&tic->nums, 'n', ind) != NULL)
 				continue;
@@ -588,9 +587,11 @@ _ti_compile(char *cap, int flags)
 				if (_ti_grow_tbuf(&tic->nums,
 					sizeof(uint16_t) * 2) == NULL)
 					goto error;
-				le16enc(tic->nums.buf + tic->nums.bufpos, ind);
+				le16enc(tic->nums.buf + tic->nums.bufpos,
+				    (uint16_t)ind);
 				tic->nums.bufpos += sizeof(uint16_t);
-				le16enc(tic->nums.buf + tic->nums.bufpos, num);
+				le16enc(tic->nums.buf + tic->nums.bufpos,
+				    (uint16_t)num);
 				tic->nums.bufpos += sizeof(uint16_t);
 				tic->nums.entries++;
 			}
@@ -603,28 +604,29 @@ _ti_compile(char *cap, int flags)
 			flag = CANCELLED_BOOLEAN;
 			token[len] = '\0';
 		}
-		ind = _ti_flagindex(token);
+		ind = (short)_ti_flagindex(token);
 		if (ind == -1 && flag == CANCELLED_BOOLEAN) {
-			if ((ind = _ti_numindex(token)) != -1) {
+			if ((ind = (short)_ti_numindex(token)) != -1) {
 				if (_ti_find_cap(&tic->nums, 'n', ind) != NULL)
 					continue;
 				if (_ti_grow_tbuf(&tic->nums,
 					sizeof(uint16_t) * 2) == NULL)
 					goto error;
-				le16enc(tic->nums.buf + tic->nums.bufpos, ind);
+				le16enc(tic->nums.buf + tic->nums.bufpos,
+				    (uint16_t)ind);
 				tic->nums.bufpos += sizeof(uint16_t);
 				le16enc(tic->nums.buf + tic->nums.bufpos,
-					(uint16_t)CANCELLED_NUMERIC);
+				    (uint16_t)CANCELLED_NUMERIC);
 				tic->nums.bufpos += sizeof(uint16_t);
 				tic->nums.entries++;
 				continue;
-			} else if ((ind = _ti_strindex(token)) != -1) {
+			} else if ((ind = (short)_ti_strindex(token)) != -1) {
 				if (_ti_find_cap(&tic->strs, 's', ind) != NULL)
 					continue;
 				if (_ti_grow_tbuf(&tic->strs,
-					(sizeof(uint16_t) * 2) + 1) == NULL)
+				    (sizeof(uint16_t) * 2) + 1) == NULL)
 					goto error;
-				le16enc(tic->strs.buf + tic->strs.bufpos, ind);
+				le16enc(tic->strs.buf + tic->strs.bufpos, (uint16_t)ind);
 				tic->strs.bufpos += sizeof(uint16_t);
 				le16enc(tic->strs.buf + tic->strs.bufpos, 0);
 				tic->strs.bufpos += sizeof(uint16_t);
@@ -639,7 +641,8 @@ _ti_compile(char *cap, int flags)
 			if (_ti_grow_tbuf(&tic->flags, sizeof(uint16_t) + 1)
 			    == NULL)
 				goto error;
-			le16enc(tic->flags.buf + tic->flags.bufpos, ind);
+			le16enc(tic->flags.buf + tic->flags.bufpos,
+			    (uint16_t)ind);
 			tic->flags.bufpos += sizeof(uint16_t);
 			tic->flags.buf[tic->flags.bufpos++] = flag;
 			tic->flags.entries++;

Reply via email to