Module Name: src
Committed By: lukem
Date: Sat Apr 25 05:11:37 UTC 2009
Modified Files:
src/bin/ksh: c_ksh.c c_sh.c edit.c emacs.c eval.c misc.c path.c vi.c
Log Message:
Fix most of the -Wsign-compare issues.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/bin/ksh/c_ksh.c
cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/c_sh.c src/bin/ksh/misc.c
cvs rdiff -u -r1.21 -r1.22 src/bin/ksh/edit.c
cvs rdiff -u -r1.31 -r1.32 src/bin/ksh/emacs.c
cvs rdiff -u -r1.10 -r1.11 src/bin/ksh/eval.c src/bin/ksh/vi.c
cvs rdiff -u -r1.7 -r1.8 src/bin/ksh/path.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/ksh/c_ksh.c
diff -u src/bin/ksh/c_ksh.c:1.15 src/bin/ksh/c_ksh.c:1.16
--- src/bin/ksh/c_ksh.c:1.15 Mon Apr 24 20:00:31 2006
+++ src/bin/ksh/c_ksh.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: c_ksh.c,v 1.15 2006/04/24 20:00:31 christos Exp $ */
+/* $NetBSD: c_ksh.c,v 1.16 2009/04/25 05:11:37 lukem Exp $ */
/*
* built-in Korn commands: c_*
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: c_ksh.c,v 1.15 2006/04/24 20:00:31 christos Exp $");
+__RCSID("$NetBSD: c_ksh.c,v 1.16 2009/04/25 05:11:37 lukem Exp $");
#endif
#include "sh.h"
@@ -1268,7 +1268,8 @@
ki.name_width = mess_width = 0;
for (si = 0; si < SIGNALS; si++) {
w = sigtraps[si].name ?
- strlen(sigtraps[si].name) : ki.num_width;
+ (int)strlen(sigtraps[si].name) :
+ ki.num_width;
if (w > ki.name_width)
ki.name_width = w;
w = strlen(sigtraps[si].mess);
Index: src/bin/ksh/c_sh.c
diff -u src/bin/ksh/c_sh.c:1.12 src/bin/ksh/c_sh.c:1.13
--- src/bin/ksh/c_sh.c:1.12 Sat Apr 1 23:39:58 2006
+++ src/bin/ksh/c_sh.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: c_sh.c,v 1.12 2006/04/01 23:39:58 christos Exp $ */
+/* $NetBSD: c_sh.c,v 1.13 2009/04/25 05:11:37 lukem Exp $ */
/*
* built-in Bourne commands
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: c_sh.c,v 1.12 2006/04/01 23:39:58 christos Exp $");
+__RCSID("$NetBSD: c_sh.c,v 1.13 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -825,7 +825,7 @@
* 1000, must print 3 places after decimal (if non-zero, else 1).
*/
if (CLK_TCK != 100) /* convert to 1/100'ths */
- t = (t < 1000000000/CLK_TCK) ?
+ t = (t < (clock_t)(1000000000/CLK_TCK)) ?
(t * 100) / CLK_TCK : (t / CLK_TCK) * 100;
*--cp = '\0';
Index: src/bin/ksh/misc.c
diff -u src/bin/ksh/misc.c:1.12 src/bin/ksh/misc.c:1.13
--- src/bin/ksh/misc.c:1.12 Sun Jun 26 19:09:00 2005
+++ src/bin/ksh/misc.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.12 2005/06/26 19:09:00 christos Exp $ */
+/* $NetBSD: misc.c,v 1.13 2009/04/25 05:11:37 lukem Exp $ */
/*
* Miscellaneous functions
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.12 2005/06/26 19:09:00 christos Exp $");
+__RCSID("$NetBSD: misc.c,v 1.13 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -128,7 +128,7 @@
{
char *old_beg = xsp->beg;
- xsp->len += more > xsp->len ? more : xsp->len;
+ xsp->len += (size_t)more > xsp->len ? (size_t)more : xsp->len;
xsp->beg = aresize(xsp->beg, xsp->len + 8, xsp->areap);
xsp->end = xsp->beg + xsp->len;
return xsp->beg + (xp - old_beg);
@@ -202,7 +202,7 @@
{
int i;
- for (i = 0; i < NELEM(goptions); i++)
+ for (i = 0; i < (int)NELEM(goptions); i++)
if (goptions[i].name && strcmp(goptions[i].name, n) == 0)
return i;
@@ -249,7 +249,7 @@
/* verbose version */
shprintf("Current option settings\n");
- for (i = n = oi.opt_width = 0; i < NELEM(goptions); i++)
+ for (i = n = oi.opt_width = 0; i < (int)NELEM(goptions); i++)
if (goptions[i].name) {
len = strlen(goptions[i].name);
oi.opts[n].name = goptions[i].name;
@@ -262,7 +262,7 @@
} else {
/* short version ala ksh93 */
shprintf("set");
- for (i = 0; i < NELEM(goptions); i++)
+ for (i = 0; i < (int)NELEM(goptions); i++)
if (Flag(i) && goptions[i].name)
shprintf(" -o %s", goptions[i].name);
shprintf(newline);
@@ -272,7 +272,7 @@
char *
getoptions()
{
- int i;
+ size_t i;
char m[(int) FNFLAGS + 1];
register char *cp = m;
@@ -370,7 +370,7 @@
/* see set_opts[] declaration */
strlcpy(set_opts, "A:o;s", sizeof set_opts);
q = set_opts + strlen(set_opts);
- for (i = 0; i < NELEM(goptions); i++) {
+ for (i = 0; i < (int)NELEM(goptions); i++) {
if (goptions[i].c) {
if (goptions[i].flags & OF_CMDLINE)
*p++ = goptions[i].c;
@@ -438,7 +438,7 @@
sortargs = 1;
break;
}
- for (i = 0; i < NELEM(goptions); i++)
+ for (i = 0; i < (int)NELEM(goptions); i++)
if (optc == goptions[i].c
&& (what & goptions[i].flags))
{
@@ -544,7 +544,7 @@
if (!isfile && !has_globbing(p, pe)) {
int len = pe - p + 1;
char tbuf[64];
- char *t = len <= sizeof(tbuf) ? tbuf
+ char *t = len <= (int)sizeof(tbuf) ? tbuf
: (char *) alloc(len, ATEMP);
debunk(t, p, len);
return !strcmp(t, s);
Index: src/bin/ksh/edit.c
diff -u src/bin/ksh/edit.c:1.21 src/bin/ksh/edit.c:1.22
--- src/bin/ksh/edit.c:1.21 Sun Jan 28 20:20:25 2007
+++ src/bin/ksh/edit.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: edit.c,v 1.21 2007/01/28 20:20:25 cbiere Exp $ */
+/* $NetBSD: edit.c,v 1.22 2009/04/25 05:11:37 lukem Exp $ */
/*
* Command line editing - common code
@@ -7,7 +7,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: edit.c,v 1.21 2007/01/28 20:20:25 cbiere Exp $");
+__RCSID("$NetBSD: edit.c,v 1.22 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -390,7 +390,7 @@
#endif
};
char *rcp;
- int i;
+ size_t i;
if ((rcp = ksh_strrchr_dirsep(ed)))
ed = ++rcp;
Index: src/bin/ksh/emacs.c
diff -u src/bin/ksh/emacs.c:1.31 src/bin/ksh/emacs.c:1.32
--- src/bin/ksh/emacs.c:1.31 Sat May 13 21:58:51 2006
+++ src/bin/ksh/emacs.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: emacs.c,v 1.31 2006/05/13 21:58:51 christos Exp $ */
+/* $NetBSD: emacs.c,v 1.32 2009/04/25 05:11:37 lukem Exp $ */
/*
* Emacs-like command line editing and history
@@ -10,7 +10,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: emacs.c,v 1.31 2006/05/13 21:58:51 christos Exp $");
+__RCSID("$NetBSD: emacs.c,v 1.32 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -1519,7 +1519,8 @@
void
x_init_emacs()
{
- register int i, j;
+ size_t i;
+ register int j;
char *locale;
ainit(AEDIT);
Index: src/bin/ksh/eval.c
diff -u src/bin/ksh/eval.c:1.10 src/bin/ksh/eval.c:1.11
--- src/bin/ksh/eval.c:1.10 Sun Jan 28 22:30:12 2007
+++ src/bin/ksh/eval.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.c,v 1.10 2007/01/28 22:30:12 cbiere Exp $ */
+/* $NetBSD: eval.c,v 1.11 2009/04/25 05:11:37 lukem Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: eval.c,v 1.10 2007/01/28 22:30:12 cbiere Exp $");
+__RCSID("$NetBSD: eval.c,v 1.11 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -1208,10 +1208,10 @@
char *d, *s;
if ((s = strchr(sp, MAGIC))) {
- if (s - sp >= dlen)
+ if (s - sp >= (ptrdiff_t)dlen)
return dp;
memcpy(dp, sp, s - sp);
- for (d = dp + (s - sp); *s && (d - dp < dlen); s++)
+ for (d = dp + (s - sp); *s && (d - dp < (ptrdiff_t)dlen); s++)
if (!ISMAGIC(*s) || !(*++s & 0x80)
|| !strchr("*...@! ", *s & 0x7f))
*d++ = *s;
@@ -1219,7 +1219,7 @@
/* extended pattern operators: *...@! */
if ((*s & 0x7f) != ' ')
*d++ = *s & 0x7f;
- if (d - dp < dlen)
+ if (d - dp < (ptrdiff_t)dlen)
*d++ = '(';
}
*d = '\0';
Index: src/bin/ksh/vi.c
diff -u src/bin/ksh/vi.c:1.10 src/bin/ksh/vi.c:1.11
--- src/bin/ksh/vi.c:1.10 Sun Jun 26 19:09:00 2005
+++ src/bin/ksh/vi.c Sat Apr 25 05:11:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.10 2005/06/26 19:09:00 christos Exp $ */
+/* $NetBSD: vi.c,v 1.11 2009/04/25 05:11:37 lukem Exp $ */
/*
* vi command editing
@@ -9,7 +9,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: vi.c,v 1.10 2005/06/26 19:09:00 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.11 2009/04/25 05:11:37 lukem Exp $");
#endif
#include "config.h"
@@ -244,7 +244,7 @@
x_putc('\r'); x_putc('\n'); x_flush();
- if (c == -1 || len <= es->linelen)
+ if (c == -1 || len <= (size_t)es->linelen)
return -1;
if (es->cbuf != buf)
Index: src/bin/ksh/path.c
diff -u src/bin/ksh/path.c:1.7 src/bin/ksh/path.c:1.8
--- src/bin/ksh/path.c:1.7 Sun Jun 26 19:09:00 2005
+++ src/bin/ksh/path.c Sat Apr 25 05:11:37 2009
@@ -1,8 +1,8 @@
-/* $NetBSD: path.c,v 1.7 2005/06/26 19:09:00 christos Exp $ */
+/* $NetBSD: path.c,v 1.8 2009/04/25 05:11:37 lukem Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: path.c,v 1.7 2005/06/26 19:09:00 christos Exp $");
+__RCSID("$NetBSD: path.c,v 1.8 2009/04/25 05:11:37 lukem Exp $");
#endif
@@ -256,7 +256,7 @@
p++;
if (!*p)
break;
- len = (q = ksh_strchr_dirsep(p)) ? q - p : strlen(p);
+ len = (q = ksh_strchr_dirsep(p)) ? q - p : (int)strlen(p);
if (len == 1 && p[0] == '.')
continue;
if (len == 2 && p[0] == '.' && p[1] == '.') {