diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-12-15 13:44:29 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-12-15 13:44:29 +0000 |
commit | 53e47701986a73834e08757242b4c20da101c18b (patch) | |
tree | a7bd2cc6baac821cf8b5c653bf61a67484f6eeab /sys | |
parent | 1340c74ca66b0f223a2fbb3ae9877bf78d4ba57d (diff) |
A sanity check for an unsigned variable being < 0 after a subtraction
is not useful. Check the value about to be subtracted.
Spotted by lint.
ok pedro@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_inode.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index 859a2179c9b..57d37e6d360 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_inode.c,v 1.30 2005/12/11 20:46:28 pedro Exp $ */ +/* $OpenBSD: ext2fs_inode.c,v 1.31 2005/12/15 13:44:28 krw Exp $ */ /* $NetBSD: ext2fs_inode.c,v 1.24 2001/06/19 12:59:18 wiz Exp $ */ /* @@ -413,9 +413,10 @@ done: * Put back the real size. */ (void)ext2fs_setsize(oip, length); - oip->i_e2fs_nblock -= blocksreleased; - if (oip->i_e2fs_nblock < 0) /* sanity */ + if (blocksreleased >= oip->i_e2fs_nblock) oip->i_e2fs_nblock = 0; + else + oip->i_e2fs_nblock -= blocksreleased; oip->i_flag |= IN_CHANGE; return (allerror); } |