From owner-svn-src-all@freebsd.org Mon Feb 5 14:30:28 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17600EF4771; Mon, 5 Feb 2018 14:30:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B743E75887; Mon, 5 Feb 2018 14:30:27 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AE0B71D32; Mon, 5 Feb 2018 14:30:27 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15EURHB070274; Mon, 5 Feb 2018 14:30:27 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15EURWm070273; Mon, 5 Feb 2018 14:30:27 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201802051430.w15EURWm070273@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 5 Feb 2018 14:30:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328882 - head/sys/fs/ext2fs X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/sys/fs/ext2fs X-SVN-Commit-Revision: 328882 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 14:30:28 -0000 Author: pfg Date: Mon Feb 5 14:30:27 2018 New Revision: 328882 URL: https://svnweb.freebsd.org/changeset/base/328882 Log: ext2fs: Cleanup variable assignments for extents. Delay the initialization of variables until the are needed. In the case of ext4_ext_rm_leaf(), make sure 'error' value is not undefined. Reported by: Clang's static analyzer Differential Revision: https://reviews.freebsd.org/D14193 Modified: head/sys/fs/ext2fs/ext2_extents.c Modified: head/sys/fs/ext2fs/ext2_extents.c ============================================================================== --- head/sys/fs/ext2fs/ext2_extents.c Mon Feb 5 14:19:36 2018 (r328881) +++ head/sys/fs/ext2fs/ext2_extents.c Mon Feb 5 14:30:27 2018 (r328882) @@ -1159,14 +1159,13 @@ ext4_new_blocks(struct inode *ip, daddr_t lbn, e4fs_da struct m_ext2fs *fs; e4fs_daddr_t newblk; - fs = ip->i_e2fs; - /* * We will allocate only single block for now. */ if (*count > 1) return (0); + fs = ip->i_e2fs; EXT2_LOCK(ip->i_ump); *perror = ext2_alloc(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newblk); if (*perror) @@ -1193,13 +1192,12 @@ ext4_ext_get_blocks(struct inode *ip, e4fs_daddr_t ibl unsigned long allocated = 0; int error = 0, depth; - fs = ip->i_e2fs; - *pallocated = 0; - path = NULL; if(bpp) *bpp = NULL; + *pallocated = 0; /* Check cache. */ + path = NULL; if ((bpref = ext4_ext_in_cache(ip, iblk, &newex))) { if (bpref == EXT4_EXT_CACHE_IN) { /* Block is already allocated. */ @@ -1271,6 +1269,7 @@ out: if (bpp) { + fs = ip->i_e2fs; error = bread(ip->i_devvp, fsbtodb(fs, newblk), fs->e2fs_bsize, cred, &bp); if (error) { @@ -1304,7 +1303,7 @@ static inline struct ext4_extent_header * ext4_ext_header(struct inode *ip) { - return (struct ext4_extent_header *)ip->i_db; + return ((struct ext4_extent_header *)ip->i_db); } static int @@ -1345,19 +1344,15 @@ static int ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_path *path, uint64_t start) { - struct m_ext2fs *fs; - int depth; struct ext4_extent_header *eh; + struct ext4_extent *ex; unsigned int a, b, block, num; unsigned long ex_blk; unsigned short ex_len; - struct ext4_extent *ex; + int depth; int error, correct_index; - fs = ip->i_e2fs; depth = ext4_ext_inode_depth(ip); - correct_index = 0; - if (!path[depth].ep_header) { if (path[depth].ep_data == NULL) return (EINVAL); @@ -1367,7 +1362,8 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ eh = path[depth].ep_header; if (!eh) { - ext2_fserr(fs, ip->i_uid, "bad header => extent corrupted"); + ext2_fserr(ip->i_e2fs, ip->i_uid, + "bad header => extent corrupted"); return (EIO); } @@ -1375,6 +1371,8 @@ ext4_ext_rm_leaf(struct inode *ip, struct ext4_extent_ ex_blk = ex->e_blk; ex_len = ext4_ext_get_actual_len(ex); + error = 0; + correct_index = 0; while (ex >= EXT_FIRST_EXTENT(eh) && ex_blk + ex_len > start) { path[depth].ep_ext = ex; a = ex_blk > start ? ex_blk : start; @@ -1442,7 +1440,6 @@ ext4_read_extent_tree_block(struct inode *ip, e4fs_dad int error; fs = ip->i_e2fs; - error = bread(ip->i_devvp, fsbtodb(fs, pblk), fs->e2fs_bsize, NOCRED, &bp); if (error) { @@ -1506,10 +1503,10 @@ ext4_ext_remove_space(struct inode *ip, off_t length, if (!path) return (ENOMEM); - i = 0; path[0].ep_header = ehp; path[0].ep_depth = depth; - while (i >= 0 && error == 0) { + i = 0; + while (error == 0 && i >= 0) { if (i == depth) { /* This is leaf. */ error = ext4_ext_rm_leaf(ip, path, length); @@ -1568,7 +1565,6 @@ ext4_ext_remove_space(struct inode *ip, off_t length, ext4_ext_header(ip)->eh_depth = 0; ext4_ext_header(ip)->eh_max = ext4_ext_space_root(ip); ext4_ext_dirty(ip, path); - } ext4_ext_drop_refs(path);