• Build.sh, strlcpy.c: gcc-current conversion &c. warnings cleanup

• histrap.c, lex.c, misc.c: get average stack frame size to <= 768 bytes
• check.t, sh.h: bump version
This commit is contained in:
tg 2009-05-27 09:58:24 +00:00
parent 9179c10119
commit b90007d784
7 changed files with 57 additions and 51 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.394 2009/05/20 10:10:35 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.395 2009/05/27 09:58:20 tg Stab $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Thorsten Glaser <tg@mirbsd.org>
@ -867,7 +867,7 @@ ac_test attribute_bounded attribute 0 'for __attribute__((bounded))' <<-'EOF'
__attribute__((bounded (buffer, 2, 3)));
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
int xcopy(const void *s, void *d, size_t n) {
memmove(d, s, n); return (n);
memmove(d, s, n); return ((int)n);
}
EOF
@ -1060,7 +1060,7 @@ ac_testn arc4random <<-'EOF'
#include <stdint.h>
#endif
extern u_int32_t arc4random(void);
int main(void) { return (arc4random()); }
int main(void) { return ((int)(arc4random() & 0xFF)); }
EOF
save_LIBS=$LIBS
@ -1084,7 +1084,8 @@ ac_test arc4random_pushb arc4random 0 <<-'EOF'
#include <stdint.h>
#endif
extern uint32_t arc4random_pushb(void *, size_t);
int main(int ac, char *av[]) { return (arc4random_pushb(*av, ac)); }
int main(int ac, char *av[]) { return ((int)(arc4random_pushb(*av,
(size_t)ac)) & 0xFF); }
EOF
LIBS=$save_LIBS
@ -1094,7 +1095,7 @@ ac_testn flock_ex '' 'flock and mmap' <<-'EOF'
#include <sys/mman.h>
#include <fcntl.h>
#include <stdlib.h>
int main(void) { return ((void *)mmap(NULL, flock(0, LOCK_EX),
int main(void) { return ((void *)mmap(NULL, (size_t)flock(0, LOCK_EX),
PROT_READ, MAP_PRIVATE, 0, 0) == (void *)NULL ? 1 :
munmap(NULL, 0)); }
EOF
@ -1104,7 +1105,8 @@ ac_test getrusage <<-'EOF'
#include "sh.h"
int main(void) {
struct rusage ru;
return (getrusage(RUSAGE_SELF + RUSAGE_CHILDREN, &ru));
return (getrusage(RUSAGE_SELF, &ru) +
getrusage(RUSAGE_CHILDREN, &ru));
}
EOF
@ -1113,7 +1115,7 @@ ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF'
#include "sh.h"
int main(int ac, char *av[]) {
dev_t dv;
dv = makedev(ac, 1);
dv = makedev((unsigned int)ac, 1);
return (mknod(av[0], 0, dv) ? (int)major(dv) : (int)minor(dv));
}
EOF
@ -1156,13 +1158,13 @@ EOF
ac_test setlocale_ctype '' 'setlocale(LC_CTYPE, "")' <<-'EOF'
#include <locale.h>
#include <stddef.h>
int main(void) { return ((ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
int main(void) { return ((int)(ptrdiff_t)(void *)setlocale(LC_CTYPE, "")); }
EOF
ac_test langinfo_codeset setlocale_ctype 0 'nl_langinfo(CODESET)' <<-'EOF'
#include <langinfo.h>
#include <stddef.h>
int main(void) { return ((ptrdiff_t)(void *)nl_langinfo(CODESET)); }
int main(void) { return ((int)(ptrdiff_t)(void *)nl_langinfo(CODESET)); }
EOF
ac_test setmode mknod 1 <<-'EOF'
@ -1198,7 +1200,7 @@ ac_test strcasestr <<-'EOF'
#include <strings.h>
#endif
int main(int ac, char *av[]) {
return ((ptrdiff_t)(void *)strcasestr(*av, av[ac]));
return ((int)(ptrdiff_t)(void *)strcasestr(*av, av[ac]));
}
EOF
@ -1216,25 +1218,25 @@ ac_test '!' arc4random_decl arc4random 1 'if arc4random() does not need to be de
#define MKSH_INCLUDES_ONLY
#include "sh.h"
long arc4random(void); /* this clashes if defined before */
int main(void) { return (arc4random()); }
int main(void) { return ((int)arc4random()); }
EOF
ac_test '!' arc4random_pushb_decl arc4random_pushb 1 'if arc4random_pushb() does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
int arc4random_pushb(char, int); /* this clashes if defined before */
int main(int ac, char *av[]) { return (arc4random_pushb(**av, ac)); }
int main(int ac, char *av[]) { return ((int)arc4random_pushb(**av, ac)); }
EOF
ac_test '!' flock_decl flock_ex 1 'if flock() does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
long flock(void); /* this clashes if defined before */
int main(void) { return (flock()); }
int main(void) { return ((int)flock()); }
EOF
ac_test '!' revoke_decl revoke 1 'if revoke() does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY
#include "sh.h"
long revoke(void); /* this clashes if defined before */
int main(void) { return (revoke()); }
int main(void) { return ((int)revoke()); }
EOF
ac_test sys_siglist_decl sys_siglist 1 'if sys_siglist[] does not need to be declared' <<-'EOF'
#define MKSH_INCLUDES_ONLY

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.279 2009/05/21 14:28:32 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.280 2009/05/27 09:58:21 tg Stab $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R38 2009/05/21
@(#)MIRBSD KSH R38 2009/05/27
description:
Check version of shell.
stdin:

View File

@ -26,7 +26,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.81 2009/05/16 18:40:06 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.82 2009/05/27 09:58:22 tg Exp $");
/*-
* MirOS: This is the default mapping type, and need not be specified.
@ -781,8 +781,8 @@ hist_count_lines(unsigned char *base, int bytes)
static int
hist_shrink(unsigned char *oldbase, int oldbytes)
{
int fd;
char nfile[PATH_MAX];
int fd, rv = 0;
char *nfile = NULL;
struct stat statb;
unsigned char *nbase = oldbase;
int nbytes = oldbytes;
@ -796,27 +796,32 @@ hist_shrink(unsigned char *oldbase, int oldbytes)
/*
* create temp file
*/
shf_snprintf(nfile, sizeof(nfile), "%s.%d", hname, (int)procpid);
nfile = shf_smprintf("%s.%d", hname, (int)procpid);
if ((fd = open(nfile, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0)
return 1;
goto errout;
if (fstat(histfd, &statb) >= 0 &&
chown(nfile, statb.st_uid, statb.st_gid))
goto errout;
if (sprinkle(fd) || write(fd, nbase, nbytes) != nbytes) {
errout:
close(fd);
unlink(nfile);
return 1;
}
if (sprinkle(fd) || write(fd, nbase, nbytes) != nbytes)
goto errout;
close(fd);
fd = -1;
/*
* rename
*/
if (rename(nfile, hname) < 0)
return 1;
return 0;
if (rename(nfile, hname) < 0) {
errout:
if (fd >= 0) {
close(fd);
if (nfile)
unlink(nfile);
}
rv = 1;
}
afree(nfile, ATEMP);
return (rv);
}
/*

6
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.83 2009/05/16 16:59:37 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.84 2009/05/27 09:58:22 tg Exp $");
/*
* states while lexing word
@ -127,11 +127,7 @@ static int ignore_backslash_newline;
#define getsc_() ((*source->str != '\0') && !(source->flags & SF_FIRST) \
? *source->str++ : getsc__())
#ifdef MKSH_SMALL
#define STATE_BSIZE 32
#else
#define STATE_BSIZE 48
#endif
#define PUSH_STATE(s) do { \
if (++statep == state_info.end) \

25
misc.c
View File

@ -29,7 +29,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.106 2009/05/16 18:40:07 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.107 2009/05/27 09:58:23 tg Exp $");
#undef USE_CHVT
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
@ -1300,10 +1300,10 @@ static char *
do_phys_path(XString *xsp, char *xp, const char *pathl)
{
const char *p, *q;
int len, llen;
int savepos;
char lbuf[PATH_MAX];
int len, llen, savepos;
char *lbuf;
lbuf = alloc(PATH_MAX, ATEMP);
Xcheck(*xsp, xp);
for (p = pathl; p; p = q) {
while (*p == '/')
@ -1329,22 +1329,25 @@ do_phys_path(XString *xsp, char *xp, const char *pathl)
xp += len;
*xp = '\0';
llen = readlink(Xstring(*xsp, xp), lbuf, sizeof(lbuf) - 1);
llen = readlink(Xstring(*xsp, xp), lbuf, PATH_MAX - 1);
if (llen < 0) {
/* EINVAL means it wasn't a symlink... */
if (errno != EINVAL)
return NULL;
continue;
if (errno != EINVAL) {
xp = NULL;
goto out;
}
}
lbuf[llen] = '\0';
/* If absolute path, start from scratch.. */
xp = lbuf[0] == '/' ? Xstring(*xsp, xp) :
Xrestpos(*xsp, xp, savepos);
if (!(xp = do_phys_path(xsp, xp, lbuf)))
return NULL;
if ((xp = do_phys_path(xsp, xp, lbuf)) == NULL)
break;
}
return xp;
out:
afree(lbuf, ATEMP);
return (xp);
}
#ifdef USE_CHVT

4
sh.h
View File

@ -122,9 +122,9 @@
#define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.302 2009/05/21 14:28:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.303 2009/05/27 09:58:23 tg Exp $");
#endif
#define MKSH_VERSION "R38 2009/05/21"
#define MKSH_VERSION "R38 2009/05/27"
#ifndef MKSH_INCLUDES_ONLY

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2006, 2008
* Copyright (c) 2006, 2008, 2009
* Thorsten Glaser <tg@mirbsd.org>
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
@ -18,7 +18,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.5 2009/05/16 18:57:54 tg Rel $");
__RCSID("$MirOS: src/bin/mksh/strlcpy.c,v 1.6 2009/05/27 09:58:24 tg Rel $");
/*
* Copy src to string dst of size siz. At most siz-1 characters
@ -48,5 +48,5 @@ strlcpy(char *dst, const char *src, size_t siz)
}
/* count does not include NUL */
return (s - src - 1);
return ((size_t)(s - src - 1));
}