Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/csh WARNS=6 [-Wconversion]
details: https://anonhg.NetBSD.org/src/rev/e632fd4619de
branches: trunk
changeset: 787948:e632fd4619de
user: christos <christos%NetBSD.org@localhost>
date: Tue Jul 16 17:47:43 2013 +0000
description:
WARNS=6 [-Wconversion]
diffstat:
bin/csh/Makefile | 3 +-
bin/csh/csh.c | 40 ++++++++++++++----------
bin/csh/csh.h | 28 ++++++++--------
bin/csh/dir.c | 43 ++++++++++++++-------------
bin/csh/dol.c | 47 +++++++++++++++--------------
bin/csh/err.c | 6 +-
bin/csh/exec.c | 12 +++---
bin/csh/extern.h | 6 +-
bin/csh/file.c | 79 ++++++++++++++++++++++++++------------------------
bin/csh/func.c | 47 +++++++++++++++--------------
bin/csh/glob.c | 36 ++++++++++++----------
bin/csh/hist.c | 6 +-
bin/csh/lex.c | 88 ++++++++++++++++++++++++++++---------------------------
bin/csh/misc.c | 19 +++++------
bin/csh/proc.c | 14 ++++----
bin/csh/proc.h | 6 +-
bin/csh/set.c | 12 +++---
bin/csh/str.c | 42 +++++++++++++-------------
bin/csh/time.c | 25 ++++++++-------
19 files changed, 289 insertions(+), 270 deletions(-)
diffs (truncated from 1978 to 300 lines):
diff -r 3590a7831ec3 -r e632fd4619de bin/csh/Makefile
--- a/bin/csh/Makefile Tue Jul 16 16:55:01 2013 +0000
+++ b/bin/csh/Makefile Tue Jul 16 17:47:43 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.38 2013/01/25 19:07:14 he Exp $
+# $NetBSD: Makefile,v 1.39 2013/07/16 17:47:43 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
#
# C Shell with process control; VM/UNIX VAX Makefile
@@ -7,6 +7,7 @@
# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile.
.include <bsd.own.mk>
+WARNS=6
PROG= csh
DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
diff -r 3590a7831ec3 -r e632fd4619de bin/csh/csh.c
--- a/bin/csh/csh.c Tue Jul 16 16:55:01 2013 +0000
+++ b/bin/csh/csh.c Tue Jul 16 17:47:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: csh.c,v 1.45 2013/01/23 16:39:03 christos Exp $ */
+/* $NetBSD: csh.c,v 1.46 2013/07/16 17:47:43 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#else
-__RCSID("$NetBSD: csh.c,v 1.45 2013/01/23 16:39:03 christos Exp $");
+__RCSID("$NetBSD: csh.c,v 1.46 2013/07/16 17:47:43 christos Exp $");
#endif
#endif /* not lint */
@@ -93,9 +93,9 @@
extern char **environ;
-static int readf(void *, char *, int);
+static ssize_t readf(void *, void *, size_t);
static off_t seekf(void *, off_t, int);
-static int writef(void *, const char *, int);
+static ssize_t writef(void *, const void *, size_t);
static int closef(void *);
static int srccat(Char *, Char *);
static int srcfile(const char *, int, int);
@@ -210,11 +210,14 @@
(void)fclose(cshin);
(void)fclose(cshout);
(void)fclose(csherr);
- if (!(cshin = funopen((void *) &SHIN, readf, writef, seekf, closef)))
+ if (!(cshin = funopen2((void *) &SHIN, readf, writef, seekf, NULL,
+ closef)))
exit(1);
- if (!(cshout = funopen((void *) &SHOUT, readf, writef, seekf, closef)))
+ if (!(cshout = funopen2((void *) &SHOUT, readf, writef, seekf, NULL,
+ closef)))
exit(1);
- if (!(csherr = funopen((void *) &SHERR, readf, writef, seekf, closef)))
+ if (!(csherr = funopen2((void *) &SHERR, readf, writef, seekf, NULL,
+ closef)))
exit(1);
(void)setvbuf(cshin, NULL, _IOLBF, 0);
(void)setvbuf(cshout, NULL, _IOLBF, 0);
@@ -675,7 +678,7 @@
sigset_t nsigset, osigset;
jmp_buf oldexit;
Char *oarginp, *oevalp, **oevalvec, *ogointr;
- char OHIST;
+ Char OHIST;
int oSHIN, oinsource, oldintty, oonelflg;
int oenterhist, otell;
/* The (few) real local variables */
@@ -1233,15 +1236,15 @@
*/
#define DESC(a) (*((int *) (a)) - (didfds && *((int *) a) >= FSHIN ? FSHIN : 0))
-static int
-readf(void *oreo, char *buf, int siz)
+static ssize_t
+readf(void *oreo, void *buf, size_t siz)
{
return read(DESC(oreo), buf, siz);
}
-static int
-writef(void *oreo, const char *buf, int siz)
+static ssize_t
+writef(void *oreo, const void *buf, size_t siz)
{
return write(DESC(oreo), buf, siz);
}
@@ -1314,7 +1317,7 @@
Char **blk, **blkp;
char *ptr;
- blkp = blk = (Char **)xmalloc((size_t) sizeof(Char *) * 10);
+ blkp = blk = xmalloc((size_t) sizeof(Char *) * 10);
#define DIRAPPEND(a) \
if (stat(ptr = a, &stb) == 0 && S_ISDIR(stb.st_mode)) \
@@ -1378,10 +1381,13 @@
for (cp = value(STRprompt); *cp; cp++) {
if (i >= sizeof(pbuf))
break;
- if (*cp == HIST)
- i += snprintf(pbuf + i, sizeof(pbuf) - i, "%d", eventno + 1);
- else
- pbuf[i++] = *cp;
+ if (*cp == HIST) {
+ int r;
+ r = snprintf(pbuf + i, sizeof(pbuf) - i, "%d", eventno + 1);
+ if (r > 0)
+ i += (size_t)r;
+ } else
+ pbuf[i++] = (char)*cp;
}
if (i >= sizeof(pbuf))
i = sizeof(pbuf) - 1;
diff -r 3590a7831ec3 -r e632fd4619de bin/csh/csh.h
--- a/bin/csh/csh.h Tue Jul 16 16:55:01 2013 +0000
+++ b/bin/csh/csh.h Tue Jul 16 17:47:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: csh.h,v 1.25 2013/01/23 16:39:03 christos Exp $ */
+/* $NetBSD: csh.h,v 1.26 2013/07/16 17:47:43 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -149,9 +149,9 @@
*/
time_t chktim; /* Time mail last checked */
Char *doldol; /* Character pid for $$ */
-int backpid; /* Pid of the last background process */
-int egid, gid; /* Invokers gid */
-int euid, uid; /* Invokers uid */
+pid_t backpid; /* Pid of the last background process */
+gid_t egid, gid; /* Invokers gid */
+uid_t euid, uid; /* Invokers uid */
int shpgrp; /* Pgrp of shell */
int tpgrp; /* Terminal process group */
@@ -201,16 +201,16 @@
* The eighth/sixteenth bit of characters is used to prevent recognition,
* and eventually stripped.
*/
-#define META 0200
-#define ASCII 0177
+#define META 0x80
+#define ASCII 0x7f
#ifdef SHORT_STRINGS
-#define CHAR 0377
-#define QUOTE 0100000 /* 16nth char bit used for 'ing */
-#define TRIM 0077777 /* Mask to strip quote bit */
+#define CHAR ((Char)0xff)
+#define QUOTE ((Char)0x8000) /* 16nth char bit used for 'ing */
+#define TRIM ((Char)0x7fff) /* Mask to strip quote bit */
#else
-#define CHAR 0177
-#define QUOTE 0200 /* Eighth char bit used for 'ing */
-#define TRIM 0177 /* Mask to strip quote bit */
+#define CHAR ((Char)0x7f)
+#define QUOTE ((Char)0x80) /* Eighth char bit used for 'ing */
+#define TRIM ((Char)0x7f) /* Mask to strip quote bit */
#endif
int AsciiOnly; /* If set only 7 bits is expected in characters */
@@ -307,14 +307,14 @@
* as needed during the semantics/execution pass (sh.sem.c).
*/
struct command {
- short t_dtyp; /* Type of node */
+ int t_dtyp; /* Type of node */
#define NODE_COMMAND 1 /* t_dcom <t_dlef >t_drit */
#define NODE_PAREN 2 /* ( t_dspr ) <t_dlef >t_drit */
#define NODE_PIPE 3 /* t_dlef | t_drit */
#define NODE_LIST 4 /* t_dlef ; t_drit */
#define NODE_OR 5 /* t_dlef || t_drit */
#define NODE_AND 6 /* t_dlef && t_drit */
- short t_dflg; /* Flags, e.g. F_AMPERSAND|... */
+ int t_dflg; /* Flags, e.g. F_AMPERSAND|... */
#define F_SAVE (F_NICE|F_TIME|F_NOHUP) /* save these when re-doing */
#define F_AMPERSAND (1<<0) /* executes in background */
diff -r 3590a7831ec3 -r e632fd4619de bin/csh/dir.c
--- a/bin/csh/dir.c Tue Jul 16 16:55:01 2013 +0000
+++ b/bin/csh/dir.c Tue Jul 16 17:47:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.29 2007/07/16 18:26:09 christos Exp $ */
+/* $NetBSD: dir.c,v 1.30 2013/07/16 17:47:43 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dir.c,v 1.29 2007/07/16 18:26:09 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.30 2013/07/16 17:47:43 christos Exp $");
#endif
#endif /* not lint */
@@ -145,7 +145,7 @@
* other junk characters glob will fail.
*/
- vec = (Char **)xmalloc((size_t)(2 * sizeof(Char **)));
+ vec = xmalloc((size_t)(2 * sizeof(Char **)));
vec[0] = Strsave(dp);
vec[1] = 0;
setq(STRcwd, vec, &shvhed);
@@ -201,7 +201,7 @@
{
struct directory *dp;
Char *hp, *s;
- int cur, idx, len;
+ size_t cur, idx, len;
hp = value(STRhome);
if (*hp == '\0')
@@ -213,7 +213,7 @@
if (dp == &dhead)
continue;
if (dirflag & DIR_VERT) {
- (void)fprintf(cshout, "%d\t", idx++);
+ (void)fprintf(cshout, "%zu\t", idx++);
cur = 0;
}
if (!(dirflag & DIR_LONG) && hp != NULL && !eq(hp, STRslash) &&
@@ -274,10 +274,10 @@
return (Strsave(cp));
if (adrof(STRignore_symlinks)) {
- int dotdot = 0;
+ size_t dotdot = 0;
Char *dp, *cwd;
- cwd = (Char *)xmalloc((size_t)((Strlen(dcwd->di_name) + 3) *
+ cwd = xmalloc((size_t)((Strlen(dcwd->di_name) + 3) *
sizeof(Char)));
(void)Strcpy(cwd, dcwd->di_name);
@@ -379,15 +379,15 @@
if (*cp != '/') {
Char *p, *q;
- int cwdlen;
+ size_t cwdlen;
for (p = dcwd->di_name; *p++;)
continue;
- if ((cwdlen = p - dcwd->di_name - 1) == 1) /* root */
+ if ((cwdlen = (size_t)(p - dcwd->di_name - 1)) == 1) /* root */
cwdlen = 0;
for (p = cp; *p++;)
continue;
- dp = (Char *)xmalloc((size_t)((cwdlen + (p - cp) + 1) * sizeof(Char)));
+ dp = xmalloc((size_t)(cwdlen + (size_t)(p - cp) + 1) * sizeof(Char));
for (p = dp, q = dcwd->di_name; (*p++ = *q++) != '\0';)
continue;
if (cwdlen)
@@ -613,7 +613,8 @@
char tlink[MAXPATHLEN];
Char *newcp, *sp;
Char *p1, *p2; /* general purpose */
- int cc;
+ ssize_t cc;
+ size_t len;
int slash;
/*
@@ -702,8 +703,8 @@
/*
* New length is "yyy/" + slink + "/.." and rest
*/
- p1 = newcp = (Char *)xmalloc(
- (size_t)(((sp - cp) + cc + (p1 - p)) * sizeof(Char)));
+ p1 = newcp = xmalloc(
+ (size_t)((sp - cp) + cc + (p1 - p)) * sizeof(Char));
/*
* Copy new path into newcp
*/
@@ -722,8 +723,8 @@
/*
* New length is slink + "/.." and rest
*/
- p1 = newcp = (Char *)xmalloc(
- (size_t)((cc + (p1 - p)) * sizeof(Char)));
+ p1 = newcp = xmalloc(
+ (size_t)(cc + (p1 - p)) * sizeof(Char));
/*
* Copy new path into newcp
*/
@@ -791,8 +792,8 @@
/*
* New length is "yyy/" + slink + "/.." and rest
*/
- p1 = newcp = (Char *)xmalloc(
- (size_t)(((sp - cp) + cc + (p1 - p)) * sizeof(Char)));
Home |
Main Index |
Thread Index |
Old Index