From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Tue, 3 Mar 2015 09:57:59 -0500 (EST) Subject: [Cluster-devel] [PATCH] GFS2: Improve readability of gfs2_alloc_inode In-Reply-To: <1425317501-23593-1-git-send-email-anprice@redhat.com> References: <54F4984B.3090501@redhat.com> <1425317501-23593-1-git-send-email-anprice@redhat.com> Message-ID: <942241918.22798702.1425394679929.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit ----- Original Message ----- > Returning &ip->i_inode when ip is NULL is safe as i_inode is the first > member in struct gfs2_inode, but that's not immediately obvious. > Reorganize gfs2_alloc_inode to avoid any doubt. > > Signed-off-by: Andrew Price > --- > > Re-sending with a more appropriate commit log based on Andreas' comments. > > fs/gfs2/super.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c > index 1666382..37c59ee 100644 > --- a/fs/gfs2/super.c > +++ b/fs/gfs2/super.c > @@ -1628,12 +1628,13 @@ static struct inode *gfs2_alloc_inode(struct > super_block *sb) > struct gfs2_inode *ip; > > ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); > - if (ip) { > - ip->i_flags = 0; > - ip->i_gl = NULL; > - ip->i_rgd = NULL; > - ip->i_res = NULL; > - } > + if (!ip) > + return NULL; > + > + ip->i_flags = 0; > + ip->i_gl = NULL; > + ip->i_rgd = NULL; > + ip->i_res = NULL; > return &ip->i_inode; > } > > -- > 1.9.3 ACK, Bob Peterson Red Hat File Systems