Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libterminfo Clean up some compile warnings.



details:   https://anonhg.NetBSD.org/src/rev/bfaf1e63f6f3
branches:  trunk
changeset: 353409:bfaf1e63f6f3
user:      roy <roy%NetBSD.org@localhost>
date:      Thu May 04 09:42:23 2017 +0000

description:
Clean up some compile warnings.

diffstat:

 lib/libterminfo/curterm.c   |   6 ++--
 lib/libterminfo/setupterm.c |  12 +++++-----
 lib/libterminfo/term.c      |  14 ++++++------
 lib/libterminfo/termcap.c   |  46 ++++++++++++++++++++++++--------------------
 lib/libterminfo/tparm.c     |  37 +++++++++++++++++++++--------------
 5 files changed, 63 insertions(+), 52 deletions(-)

diffs (truncated from 389 to 300 lines):

diff -r 80c69e8bec0a -r bfaf1e63f6f3 lib/libterminfo/curterm.c
--- a/lib/libterminfo/curterm.c Thu May 04 04:37:51 2017 +0000
+++ b/lib/libterminfo/curterm.c Thu May 04 09:42:23 2017 +0000
@@ -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 @@
                os = cfgetospeed(&termios);
                for (i = 0; i < __arraycount(bauds); i++)
                        if (bauds[i] == os) {
-                               term->_ospeed = i;
+                               term->_ospeed = (short)i;
                                break;
                        }
        }
diff -r 80c69e8bec0a -r bfaf1e63f6f3 lib/libterminfo/setupterm.c
--- a/lib/libterminfo/setupterm.c       Thu May 04 04:37:51 2017 +0000
+++ b/lib/libterminfo/setupterm.c       Thu May 04 09:42:23 2017 +0000
@@ -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 @@
        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 @@
                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 */
diff -r 80c69e8bec0a -r bfaf1e63f6f3 lib/libterminfo/term.c
--- a/lib/libterminfo/term.c    Thu May 04 04:37:51 2017 +0000
+++ b/lib/libterminfo/term.c    Thu May 04 09:42:23 2017 +0000
@@ -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 @@
 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 @@
                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 @@
                                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 @@
        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 @@
                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)
diff -r 80c69e8bec0a -r bfaf1e63f6f3 lib/libterminfo/termcap.c
--- a/lib/libterminfo/termcap.c Thu May 04 04:37:51 2017 +0000
+++ b/lib/libterminfo/termcap.c Thu May 04 09:42:23 2017 +0000
@@ -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 @@
 }
 
 /* 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 @@
 }
 
 /* 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 @@
                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 @@
                        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 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 @@
        } 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 @@
                        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 @@
                        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 @@
                        ip += sizeof(fmtElse) - 1;
                        l += sizeof(fmtElse) - 1;
                        l += 16;
-                       nop = 1;
+                       nop = true;
                        continue;
                case '.':
                        if (l + 6 > len)
@@ -443,7 +447,7 @@
 
        /* 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++ = '$';
diff -r 80c69e8bec0a -r bfaf1e63f6f3 lib/libterminfo/tparm.c
--- a/lib/libterminfo/tparm.c   Thu May 04 04:37:51 2017 +0000
+++ b/lib/libterminfo/tparm.c   Thu May 04 09:42:23 2017 +0000
@@ -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 @@
 }
 
 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;



Home | Main Index | Thread Index | Old Index