Fix bugs found in MFS by clang static analyzer.

This commit is contained in:
Evgeniy Ivanov 2011-08-10 20:46:33 +00:00 committed by Ben Gras
parent 10375d2629
commit a9a45cddc4
5 changed files with 12 additions and 6 deletions

View File

@ -321,12 +321,16 @@ PUBLIC int fs_rename()
old_ip = NULL; old_ip = NULL;
if (r == EENTERMOUNT) r = EXDEV; /* should this fail at all? */ if (r == EENTERMOUNT) r = EXDEV; /* should this fail at all? */
else if (r == ELEAVEMOUNT) r = EINVAL; /* rename on dot-dot */ else if (r == ELEAVEMOUNT) r = EINVAL; /* rename on dot-dot */
} else if (old_ip == NULL) {
return(err_code);
} }
/* Get new dir inode */ /* Get new dir inode */
if( (new_dirp = get_inode(fs_dev, (ino_t) fs_m_in.REQ_REN_NEW_DIR)) == NULL) if( (new_dirp = get_inode(fs_dev, (ino_t) fs_m_in.REQ_REN_NEW_DIR)) == NULL) {
r = err_code; put_inode(old_ip);
else { put_inode(old_dirp);
return(err_code);
} else {
if (new_dirp->i_nlinks == NO_LINK) { /* Dir does not actually exist */ if (new_dirp->i_nlinks == NO_LINK) { /* Dir does not actually exist */
put_inode(old_ip); put_inode(old_ip);
put_inode(old_dirp); put_inode(old_dirp);

View File

@ -30,7 +30,7 @@ PUBLIC int main(int argc, char *argv[])
* three major activities: getting new work, processing the work, and * three major activities: getting new work, processing the work, and
* sending the reply. The loop never terminates, unless a panic occurs. * sending the reply. The loop never terminates, unless a panic occurs.
*/ */
int error, ind, transid; int error = OK, ind, transid;
/* SEF local startup. */ /* SEF local startup. */
env_setargs(argc, argv); env_setargs(argc, argv);
@ -52,7 +52,6 @@ PUBLIC int main(int argc, char *argv[])
assert(IS_VFS_FS_TRANSID(transid)); assert(IS_VFS_FS_TRANSID(transid));
src = fs_m_in.m_source; src = fs_m_in.m_source;
error = OK;
caller_uid = INVAL_UID; /* To trap errors */ caller_uid = INVAL_UID; /* To trap errors */
caller_gid = INVAL_GID; caller_gid = INVAL_GID;
req_nr = fs_m_in.m_type; req_nr = fs_m_in.m_type;

View File

@ -466,6 +466,7 @@ unsigned bytes_ahead; /* bytes beyond position for immediate use */
block = baseblock; block = baseblock;
bp = get_block(dev, block, PREFETCH); bp = get_block(dev, block, PREFETCH);
assert(bp != NULL);
if (bp->b_dev != NO_DEV) return(bp); if (bp->b_dev != NO_DEV) return(bp);
/* The best guess for the number of blocks to prefetch: A lot. /* The best guess for the number of blocks to prefetch: A lot.

View File

@ -27,6 +27,8 @@ int map; /* IMAP (inode map) or ZMAP (zone map) */
bit_t i, b; bit_t i, b;
bit_t free_bits; bit_t free_bits;
assert(sp != NULL);
if (map == IMAP) { if (map == IMAP) {
start_block = START_BLOCK; start_block = START_BLOCK;
map_bits = (bit_t) (sp->s_ninodes + 1); map_bits = (bit_t) (sp->s_ninodes + 1);

View File

@ -92,7 +92,7 @@ int op; /* special actions */
excess = excess % nr_indirects; excess = excess % nr_indirects;
if (ind_ex >= nr_indirects) return(EFBIG); if (ind_ex >= nr_indirects) return(EFBIG);
if(z == NO_ZONE) { if(z == NO_ZONE && (op & WMAP_FREE)) {
/* WMAP_FREE and no double indirect block - then no /* WMAP_FREE and no double indirect block - then no
* single indirect block either. * single indirect block either.
*/ */