fix warning about signed vs. unsigned comparision and potential truncation error

This commit is contained in:
tg 2011-02-09 13:08:27 +00:00
parent 4e0f597b5d
commit 5161342b9b
3 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.405 2011/02/03 15:57:49 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.406 2011/02/09 13:08:24 tg Exp $
# $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 R39 2011/02/03
@(#)MIRBSD KSH R39 2011/02/09
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.104 2011/01/30 02:18:20 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.105 2011/02/09 13:08:25 tg Exp $");
/*-
* MirOS: This is the default mapping type, and need not be specified.
@ -274,9 +274,16 @@ c_fc(const char **wp)
if (stat(tf->name, &statb) < 0)
n = 128;
else {
if (notoktoadd(statb.st_size, 1 + X_EXTRA)) {
bi_errorf(T_intovfl,
(unsigned long)statb.st_size, '+',
unsigned long st_sizeUL;
/* we pretty much assume ulong >= size_t */
st_sizeUL = (unsigned long)statb.st_size;
if (
/* too big, truncated by the cast */
statb.st_size != (long)st_sizeUL ||
/* a few additional bytes do not fit */
notoktoadd(st_sizeUL, 1 + X_EXTRA)) {
bi_errorf(T_intovfl, st_sizeUL, '+',
1UL + X_EXTRA);
goto errout;
}

4
sh.h
View File

@ -154,9 +154,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.427 2011/02/03 15:57:52 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.428 2011/02/09 13:08:27 tg Exp $");
#endif
#define MKSH_VERSION "R39 2011/02/03"
#define MKSH_VERSION "R39 2011/02/09"
#ifndef MKSH_INCLUDES_ONLY