diff options
author | 1998-11-04 21:21:24 +0000 | |
---|---|---|
committer | 1998-11-04 21:21:24 +0000 | |
commit | 43b0c78d4d89d4c2c0300bc397cee57be4800d66 (patch) | |
tree | 75bbadb75c77e5c42aae97a1530c488fab78b80c /lib/libocurses | |
parent | protos for strlcat, strlcpy (diff) | |
download | wireguard-openbsd-43b0c78d4d89d4c2c0300bc397cee57be4800d66.tar.xz wireguard-openbsd-43b0c78d4d89d4c2c0300bc397cee57be4800d66.zip |
Some -Wall and use strlcpy
Diffstat (limited to 'lib/libocurses')
-rw-r--r-- | lib/libocurses/cr_put.c | 9 | ||||
-rw-r--r-- | lib/libocurses/cur_hash.c | 2 | ||||
-rw-r--r-- | lib/libocurses/insch.c | 3 | ||||
-rw-r--r-- | lib/libocurses/termcap.c | 41 |
4 files changed, 27 insertions, 28 deletions
diff --git a/lib/libocurses/cr_put.c b/lib/libocurses/cr_put.c index ada2df5ca1e..d98e66b50e0 100644 --- a/lib/libocurses/cr_put.c +++ b/lib/libocurses/cr_put.c @@ -100,11 +100,12 @@ fgoto(in_refresh) outcol %= COLS; if (AM == 0) { while (l > 0) { - if (__pfast) + if (__pfast) { if (CR) tputs(CR, 0, __cputchar); else putchar('\r'); + } if (NL) tputs(NL, 0, __cputchar); else @@ -297,7 +298,7 @@ plod(cnt, in_refresh) * If it will be cheaper, or if we can't back up, then send a return * preliminarily. */ - if (j > i + 1 || outcol > destcol && !BS && !BC) { + if (j > i + 1 || (outcol > destcol && !BS && !BC)) { /* * BUG: this doesn't take the (possibly long) length of CR * into account. @@ -383,7 +384,7 @@ dontcr: while (outline < destline) { * Move one char to the right. We don't use ND space because * it's better to just print the char we are moving over. */ - if (in_refresh) + if (in_refresh) { if (plodflg) /* Avoid a complex calculation. */ plodcnt--; else { @@ -395,7 +396,7 @@ dontcr: while (outline < destline) { else goto nondes; } - else + } else nondes: if (ND) tputs(ND, 0, plodput); else diff --git a/lib/libocurses/cur_hash.c b/lib/libocurses/cur_hash.c index ed47fe37333..b3b84ba54ed 100644 --- a/lib/libocurses/cur_hash.c +++ b/lib/libocurses/cur_hash.c @@ -52,7 +52,7 @@ __hash(s, len) i = 0; while (i < len) { h = (h << 4) + s[i]; - if (g = h & 0xf0000000) { + if ((g = h & 0xf0000000)) { h = h ^ (g >> 24); h = h ^ g; } diff --git a/lib/libocurses/insch.c b/lib/libocurses/insch.c index 36cc0dee894..d16abea37f8 100644 --- a/lib/libocurses/insch.c +++ b/lib/libocurses/insch.c @@ -63,12 +63,13 @@ winsch(win, ch) __touchline(win, win->cury, win->curx, win->maxx - 1, 0); if (win->cury == LINES - 1 && (win->lines[LINES - 1]->line[COLS - 1].ch != ' ' || - win->lines[LINES -1]->line[COLS - 1].attr != 0)) + win->lines[LINES -1]->line[COLS - 1].attr != 0)) { if (win->flags & __SCROLLOK) { wrefresh(win); scroll(win); win->cury--; } else return (ERR); + } return (OK); } diff --git a/lib/libocurses/termcap.c b/lib/libocurses/termcap.c index 88e14612ee5..0f55e14ba75 100644 --- a/lib/libocurses/termcap.c +++ b/lib/libocurses/termcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: termcap.c,v 1.2 1998/10/08 04:31:29 millert Exp $ */ +/* $OpenBSD: termcap.c,v 1.3 1998/11/04 21:21:24 millert Exp $ */ /* $NetBSD: termcap.c,v 1.7 1995/06/05 19:45:52 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; #else -static char rcsid[] = "$OpenBSD: termcap.c,v 1.2 1998/10/08 04:31:29 millert Exp $"; +static char rcsid[] = "$OpenBSD: termcap.c,v 1.3 1998/11/04 21:21:24 millert Exp $"; #endif #endif /* not lint */ @@ -50,6 +50,7 @@ static char rcsid[] = "$OpenBSD: termcap.c,v 1.2 1998/10/08 04:31:29 millert Exp #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <curses.h> #include "pathnames.h" @@ -90,7 +91,6 @@ tgetent(bp, name) fname = pathvec; pvec = pathvec; tbuf = bp; - p = pathbuf; if (!issetugid()) { cp = getenv("TERMCAP"); @@ -107,29 +107,27 @@ tgetent(bp, name) */ if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */ if ((termpath = getenv("TERMPATH")) != NULL) - strncpy(pathbuf, termpath, sizeof(pathbuf) - 1); + strlcpy(pathbuf, termpath, sizeof(pathbuf)); else { - if ((home = getenv("HOME")) != NULL) { - /* set up default */ - /* $HOME first */ - strncpy(pathbuf, home, sizeof(pathbuf) - - 1 - strlen(_PATH_DEF) - 1); - pathbuf[sizeof(pathbuf) - 1 - - strlen(_PATH_DEF) - 1] = '\0'; - p += strlen(pathbuf); /* path, looking in */ - *p++ = '/'; - } /* if no $HOME look in current dir */ - strncpy(p, _PATH_DEF, sizeof(pathbuf) -1 - - (p - pathbuf)); + if ((home = getenv("HOME")) != NULL && + strlen(home) + sizeof(_PATH_DEF) < + sizeof(pathbuf)) { + sprintf(pathbuf, "%s/%s", home, + _PATH_DEF); + } else { + strlcpy(pathbuf, _PATH_DEF, + sizeof(pathbuf)); + } } - } else { /* user-defined name in TERMCAP */ + } else { /* user-defined path in TERMCAP */ /* still can be tokenized */ - strncpy(pathbuf, cp, sizeof(pathbuf) - 1); + strlcpy(pathbuf, cp, sizeof(pathbuf)); } - pathbuf[sizeof(pathbuf) - 1] = '\0'; - *fname++ = pathbuf; /* tokenize path into vector of names */ } + + /* split pathbuf into a vector of paths */ + p = pathbuf; while (*++p) if (*p == ' ' || *p == ':') { *p = '\0'; @@ -153,8 +151,7 @@ tgetent(bp, name) i = cgetent(&dummy, pathvec, name); if (i == 0 && bp != NULL) { - strncpy(bp, dummy, 1023); - bp[1023] = '\0'; + strlcpy(bp, dummy, 1024); if ((cp = strrchr(bp, ':')) != NULL) if (cp[1] != '\0') cp[1] = '\0'; |