Module Name:    src
Committed By:   roy
Date:           Thu May  4 09:42:23 UTC 2017

Modified Files:
        src/lib/libterminfo: curterm.c setupterm.c term.c termcap.c tparm.c

Log Message:
Clean up some compile warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libterminfo/curterm.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libterminfo/setupterm.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libterminfo/term.c \
    src/lib/libterminfo/termcap.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libterminfo/tparm.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/curterm.c
diff -u src/lib/libterminfo/curterm.c:1.12 src/lib/libterminfo/curterm.c:1.13
--- src/lib/libterminfo/curterm.c:1.12	Fri Apr  1 19:59:08 2016
+++ src/lib/libterminfo/curterm.c	Thu May  4 09:42:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: curterm.c,v 1.12 2016/04/01 19:59:08 christos Exp $ */
+/* $NetBSD: curterm.c,v 1.13 2017/05/04 09:42:23 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: curterm.c,v 1.12 2016/04/01 19:59:08 christos Exp $");
+__RCSID("$NetBSD: curterm.c,v 1.13 2017/05/04 09:42:23 roy Exp $");
 
 #include <assert.h>
 #include <stdlib.h>
@@ -70,7 +70,7 @@ _ti_setospeed(TERMINAL *term)
 		os = cfgetospeed(&termios);
 		for (i = 0; i < __arraycount(bauds); i++)
 			if (bauds[i] == os) {
-				term->_ospeed = i;
+				term->_ospeed = (short)i;
 				break;
 			}
 	}

Index: src/lib/libterminfo/setupterm.c
diff -u src/lib/libterminfo/setupterm.c:1.7 src/lib/libterminfo/setupterm.c:1.8
--- src/lib/libterminfo/setupterm.c:1.7	Thu Mar 23 00:55:39 2017
+++ src/lib/libterminfo/setupterm.c	Thu May  4 09:42:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: setupterm.c,v 1.7 2017/03/23 00:55:39 roy Exp $ */
+/* $NetBSD: setupterm.c,v 1.8 2017/05/04 09:42:23 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: setupterm.c,v 1.7 2017/03/23 00:55:39 roy Exp $");
+__RCSID("$NetBSD: setupterm.c,v 1.8 2017/05/04 09:42:23 roy Exp $");
 
 #include <sys/ioctl.h>
 #include <assert.h>
@@ -127,8 +127,8 @@ ti_setupterm(TERMINAL **nterm, const cha
 	if (ioctl(fildes, TIOCGWINSZ, &win) != -1 &&
 	    win.ws_row != 0 && win.ws_col != 0)
 	{
-		t_lines(*nterm) = win.ws_row;
-		t_columns(*nterm) = win.ws_col;
+		t_lines(*nterm) = (short)win.ws_row;
+		t_columns(*nterm) = (short)win.ws_col;
 	}
 
 	/* POSIX 1003.2 requires that the environment override. */
@@ -136,9 +136,9 @@ ti_setupterm(TERMINAL **nterm, const cha
 		char *p;
 
 		if ((p = getenv("LINES")) != NULL)
-			t_lines(*nterm) = (int)strtol(p, NULL, 0);
+			t_lines(*nterm) = (short)strtol(p, NULL, 0);
 		if ((p = getenv("COLUMNS")) != NULL)
-			t_columns(*nterm) = (int)strtol(p, NULL, 0);
+			t_columns(*nterm) = (short)strtol(p, NULL, 0);
 	}
 
 	/* POSIX requires 1 for success */

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.21 src/lib/libterminfo/term.c:1.22
--- src/lib/libterminfo/term.c:1.21	Thu Apr 20 08:34:23 2017
+++ src/lib/libterminfo/term.c	Thu May  4 09:42:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.21 2017/04/20 08:34:23 roy Exp $ */
+/* $NetBSD: term.c,v 1.22 2017/05/04 09:42:23 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.21 2017/04/20 08:34:23 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.22 2017/05/04 09:42:23 roy Exp $");
 
 #include <sys/stat.h>
 
@@ -73,7 +73,7 @@ allocset(void *pp, int init, size_t nele
 static int
 _ti_readterm(TERMINAL *term, const char *cap, size_t caplen, int flags)
 {
-	uint8_t ver;
+	char ver;
 	uint16_t ind, num;
 	size_t len;
 	TERMUSERDEF *ud;
@@ -147,7 +147,7 @@ _ti_readterm(TERMINAL *term, const char 
 		for (; num != 0; num--) {
 			ind = le16dec(cap);
 			cap += sizeof(uint16_t);
-			term->nums[ind] = le16dec(cap);
+			term->nums[ind] = (short)le16dec(cap);
 			if (flags == 0 && !VALID_NUMERIC(term->nums[ind]))
 				term->nums[ind] = ABSENT_NUMERIC;
 			cap += sizeof(uint16_t);
@@ -205,7 +205,7 @@ _ti_readterm(TERMINAL *term, const char 
 				break;
 			case 'n':
 				ud->flag = ABSENT_BOOLEAN;
-				ud->num = le16dec(cap);
+				ud->num = (short)le16dec(cap);
 				if (flags == 0 &&
 				    !VALID_NUMERIC(ud->num))
 					ud->num = ABSENT_NUMERIC;
@@ -309,7 +309,7 @@ _ti_dbgettermp(TERMINAL *term, const cha
 	do {
 		for (p = path; *path != '\0' && *path != ':'; path++)
 			continue;
-		l = path - p;
+		l = (size_t)(path - p);
 		if (l != 0 && l + 1 < sizeof(pathbuf)) {
 			memcpy(pathbuf, p, l);
 			pathbuf[l] = '\0';
@@ -341,7 +341,7 @@ ticcmp(const TIC *tic, const char *name)
 		if (s == NULL)
 			l = strlen(alias);
 		else
-			l = s - alias;
+			l = (size_t)(s - alias);
 		if (len == l && memcmp(alias, name, l) == 0)
 			return 0;
 		if (s == NULL)
Index: src/lib/libterminfo/termcap.c
diff -u src/lib/libterminfo/termcap.c:1.21 src/lib/libterminfo/termcap.c:1.22
--- src/lib/libterminfo/termcap.c:1.21	Mon May  1 18:39:02 2017
+++ src/lib/libterminfo/termcap.c	Thu May  4 09:42:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: termcap.c,v 1.21 2017/05/01 18:39:02 roy Exp $ */
+/* $NetBSD: termcap.c,v 1.22 2017/05/04 09:42:23 roy Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,11 +28,12 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: termcap.c,v 1.21 2017/05/01 18:39:02 roy Exp $");
+__RCSID("$NetBSD: termcap.c,v 1.22 2017/05/04 09:42:23 roy Exp $");
 
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <string.h>
 #include <term_private.h>
@@ -223,11 +224,11 @@ strname(const char *key)
 }
 
 /* Print a parameter if needed */
-static int
-printparam(char **dst, char p, int *nop)
+static size_t
+printparam(char **dst, char p, bool *nop)
 {
-	if (*nop != 0) {
-		*nop = 0;
+	if (*nop) {
+		*nop = false;
 		return 0;
 	}
 
@@ -238,16 +239,16 @@ printparam(char **dst, char p, int *nop)
 }
 
 /* Convert a termcap character into terminfo equivalents */
-static int
+static size_t
 printchar(char **dst, const char **src)
 {
-	unsigned char v;
-	int l;
+	char v;
+	size_t l;
 
 	l = 4;
-	v = (unsigned char) *++(*src);
+	v = *++(*src);
 	if (v == '\\') {
-		v = (unsigned char) *++(*src);
+		v = *++(*src);
 		switch (v) {
 		case '0':
 		case '1':
@@ -255,7 +256,7 @@ printchar(char **dst, const char **src)
 		case '3':
 			v = 0;
 			while (isdigit((unsigned char) **src))
-				v = 8 * v + ((unsigned char) *(*src)++ - '0');
+				v = 8 * v + (*(*src)++ - '0');
 			(*src)--;
 			break;
 		case '\0':
@@ -263,9 +264,11 @@ printchar(char **dst, const char **src)
 			break;
 		}
 	} else if (v == '^')
-		v = (unsigned char) (*++(*src) & 0x1f);
+		v = *++(*src) & 0x1f;
 	*(*dst)++ = '%';
-	if (isgraph(v) && v != ',' && v != '\'' && v != '\\' && v != ':') {
+	if (isgraph((unsigned char )v) &&
+	    v != ',' && v != '\'' && v != '\\' && v != ':')
+	{
 		*(*dst)++ = '\'';
 		*(*dst)++ = v;
 		*(*dst)++ = '\'';
@@ -295,9 +298,9 @@ static const char fmtElse[] = "%+%;";
 static char *
 strval(const char *val)
 {
-	char *info, *ip, c;
+	char *info, *ip, c, p;
 	const char *ps, *pe;
-	int p, nop;
+	bool nop;
 	size_t len, l;
 
 	len = 1024; /* no single string should be bigger */
@@ -321,7 +324,8 @@ strval(const char *val)
 	} else
 		ps = pe  = NULL;
 
-	l = nop = 0;
+	nop = false;
+	l = 0;
 	p = 1;
 	for (; *val != '\0'; val++) {
 		if (l + 2 > len)
@@ -347,7 +351,7 @@ strval(const char *val)
 			ip[19] += p;
 			ip += sizeof(fmtB) - 1;
 			l += sizeof(fmtB) - 1;
-			nop = 1;
+			nop = true;
 			continue;
 		case 'D':
 			if (l + sizeof(fmtD) > len)
@@ -358,7 +362,7 @@ strval(const char *val)
 			ip[5] += p;
 			ip += sizeof(fmtD) - 1;
 			l += sizeof(fmtD) - 1;
-			nop = 1;
+			nop = true;
 			continue;
 		case 'r':
 			/* non op as switched below */
@@ -408,7 +412,7 @@ strval(const char *val)
 			ip += sizeof(fmtElse) - 1;
 			l += sizeof(fmtElse) - 1;
 			l += 16;
-			nop = 1;
+			nop = true;
 			continue;
 		case '.':
 			if (l + 6 > len)
@@ -443,7 +447,7 @@ strval(const char *val)
 
 	/* Add our padding at the end. */
 	if (ps != NULL) {
-		size_t n = pe - ps;
+		size_t n = (size_t)(pe - ps);
 		if (l + n + 4 > len)
 			goto elen;
 		*ip++ = '$';

Index: src/lib/libterminfo/tparm.c
diff -u src/lib/libterminfo/tparm.c:1.16 src/lib/libterminfo/tparm.c:1.17
--- src/lib/libterminfo/tparm.c:1.16	Wed Nov 25 18:46:59 2015
+++ src/lib/libterminfo/tparm.c	Thu May  4 09:42:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tparm.c,v 1.16 2015/11/25 18:46:59 christos Exp $ */
+/* $NetBSD: tparm.c,v 1.17 2017/05/04 09:42:23 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2011, 2013 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tparm.c,v 1.16 2015/11/25 18:46:59 christos Exp $");
+__RCSID("$NetBSD: tparm.c,v 1.17 2017/05/04 09:42:23 roy Exp $");
 #include <sys/param.h>
 
 #include <assert.h>
@@ -122,17 +122,21 @@ ochar(TERMINAL *term, int c)
 }
 
 static size_t
-onum(TERMINAL *term, const char *fmt, int num, unsigned int len)
+onum(TERMINAL *term, const char *fmt, int num, size_t len)
 {
-	size_t l;
+	int l;
+	size_t r;
 
 	if (len < LONG_STR_MAX)
 		len = LONG_STR_MAX;
 	if (checkbuf(term, len + 2) == NULL)
 		return 0;
 	l = snprintf(term->_buf + term->_bufpos, len + 2, fmt, num);
-	term->_bufpos += l;
-	return l;
+	if (l == -1)
+		return 0;
+	r = (size_t)l;
+	term->_bufpos += r;
+	return r;
 }
 
 /*
@@ -187,10 +191,10 @@ _ti_tiparm(TERMINAL *term, const char *s
 	char c, fmt[64], *fp, *ostr;
 	long val, val2;
 	long dnums[26]; /* dynamic variables a-z, not preserved */
-	size_t l, max;
+	size_t l, max, width, precision, olen;
 	TPSTACK stack;
 	TPVAR params[TPARM_MAX];
-	unsigned int done, dot, minus, width, precision, olen;
+	unsigned int done, dot, minus;
 	int piss[TPARM_MAX]; /* Parameter IS String - piss ;) */
 
 	if (str == NULL)
@@ -222,7 +226,7 @@ _ti_tiparm(TERMINAL *term, const char *s
 	}
 
 	memset(&piss, 0, sizeof(piss));
-	max = _ti_parm_analyse(str, piss, TPARM_MAX);
+	max = (size_t)_ti_parm_analyse(str, piss, TPARM_MAX);
 
 	/* Put our parameters into variables */
 	memset(&params, 0, sizeof(params));
@@ -286,7 +290,7 @@ _ti_tiparm(TERMINAL *term, const char *s
 				*fp++ = c;
 				if (dot == 0) {
 					dot = 1;
-					width = val;
+					width = (size_t)val;
 				} else
 					done = 2;
 				val = 0;
@@ -320,9 +324,9 @@ _ti_tiparm(TERMINAL *term, const char *s
 			olen = 0;
 		} else {
 			if (dot == 0)
-				width = val;
+				width = (size_t)val;
 			else
-				precision = val;
+				precision = (size_t)val;
 			olen = MAX(width, precision);
 		}
 		*fp++ = '\0';
@@ -337,14 +341,17 @@ _ti_tiparm(TERMINAL *term, const char *s
 		case 's':
 			pop(NULL, &ostr, &stack);
 			if (ostr != NULL) {
+				int r;
+
 				l = strlen(ostr);
 				if (l < (size_t)olen)
 					l = olen;
 				if (checkbuf(term, (size_t)(l + 1)) == NULL)
 					return NULL;
-				l = snprintf(term->_buf + term->_bufpos, l + 1,
+				r = snprintf(term->_buf + term->_bufpos, l + 1,
 				    fmt, ostr);
-				term->_bufpos += l;
+				if (r != -1)
+					term->_bufpos += (size_t)r;
 			}
 			break;
 		case 'l':
@@ -371,7 +378,7 @@ _ti_tiparm(TERMINAL *term, const char *s
 		case 'p':
 			if (*str < '1' || *str > '9')
 				break;
-			l = *str++ - '1';
+			l = (size_t)(*str++ - '1');
 			if (push(params[l].num, params[l].string, &stack))
 				return NULL;
 			break;

Reply via email to