Date: Sun, 15 Feb 2015 01:12:15 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278790 - head/sys/fs/ext2fs Message-ID: <201502150112.t1F1CFHj097770@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Sun Feb 15 01:12:15 2015 New Revision: 278790 URL: https://svnweb.freebsd.org/changeset/base/278790 Log: Initialize the allocation of variables related to the ext2 allocator. The e2fs_gd struct was not being initialized and garbage was being used for hinting the ext2 allocator variant. Use malloc to clear the values and also initialize e2fs_contigdirs during allocation to keep consistency. While here clean up small style issues. Reported by: Clang static analyser MFC after: 1 week Modified: head/sys/fs/ext2fs/ext2_vfsops.c Modified: head/sys/fs/ext2fs/ext2_vfsops.c ============================================================================== --- head/sys/fs/ext2fs/ext2_vfsops.c Sat Feb 14 23:28:09 2015 (r278789) +++ head/sys/fs/ext2fs/ext2_vfsops.c Sun Feb 15 01:12:15 2015 (r278790) @@ -355,7 +355,7 @@ compute_sb_data(struct vnode *devvp, str } fs->e2fs_ipb = fs->e2fs_bsize / EXT2_INODE_SIZE(fs); - fs->e2fs_itpg = fs->e2fs_ipg /fs->e2fs_ipb; + fs->e2fs_itpg = fs->e2fs_ipg / fs->e2fs_ipb; /* s_resuid / s_resgid ? */ fs->e2fs_gcount = (es->e2fs_bcount - es->e2fs_first_dblock + EXT2_BLOCKS_PER_GROUP(fs) - 1) / EXT2_BLOCKS_PER_GROUP(fs); @@ -363,9 +363,9 @@ compute_sb_data(struct vnode *devvp, str db_count = (fs->e2fs_gcount + e2fs_descpb - 1) / e2fs_descpb; fs->e2fs_gdbcount = db_count; fs->e2fs_gd = malloc(db_count * fs->e2fs_bsize, - M_EXT2MNT, M_WAITOK); + M_EXT2MNT, M_WAITOK | M_ZERO); fs->e2fs_contigdirs = malloc(fs->e2fs_gcount * - sizeof(*fs->e2fs_contigdirs), M_EXT2MNT, M_WAITOK); + sizeof(*fs->e2fs_contigdirs), M_EXT2MNT, M_WAITOK | M_ZERO); /* * Adjust logic_sb_block. @@ -390,11 +390,11 @@ compute_sb_data(struct vnode *devvp, str brelse(bp); bp = NULL; } + /* Initialization for the ext2 Orlov allocator variant. */ fs->e2fs_total_dir = 0; - for (i=0; i < fs->e2fs_gcount; i++){ + for (i = 0; i < fs->e2fs_gcount; i++) fs->e2fs_total_dir += fs->e2fs_gd[i].ext2bgd_ndirs; - fs->e2fs_contigdirs[i] = 0; - } + if (es->e2fs_rev == E2FS_REV0 || !EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_LARGEFILE)) fs->e2fs_maxfilesize = 0x7fffffff;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502150112.t1F1CFHj097770>