From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id p5TE3fjF104789 for ; Wed, 29 Jun 2011 09:03:41 -0500 Received: from bombadil.infradead.org (localhost [127.0.0.1]) by cuda.sgi.com (Spam Firewall) with ESMTP id 35E7A1D7DD36 for ; Wed, 29 Jun 2011 07:03:40 -0700 (PDT) Received: from bombadil.infradead.org (173-166-109-252-newengland.hfc.comcastbusiness.net [173.166.109.252]) by cuda.sgi.com with ESMTP id ByfzgpYVskFoan9b for ; Wed, 29 Jun 2011 07:03:40 -0700 (PDT) Received: from hch by bombadil.infradead.org with local (Exim 4.76 #1 (Red Hat Linux)) id 1QbvMh-0008IA-N2 for xfs@oss.sgi.com; Wed, 29 Jun 2011 14:03:39 +0000 Message-Id: <20110629140339.678322915@bombadil.infradead.org> Date: Wed, 29 Jun 2011 10:01:25 -0400 From: Christoph Hellwig Subject: [PATCH 16/27] xfs: cleanup the defintion of struct xfs_dir2_sf_entry References: <20110629140109.003209430@bombadil.infradead.org> Content-Disposition: inline; filename=xfs-cleanup-xfs_dir2_sf_entry List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: xfs-bounces@oss.sgi.com Errors-To: xfs-bounces@oss.sgi.com To: xfs@oss.sgi.com Remove the inumber member which is at a variable offset after the actual name, and make name a real variable sized C99 array instead of the incorrect one-sized array which confuses (not only) gcc. Based on this clean up the helpers to calculate the entry size. Signed-off-by: Christoph Hellwig Index: xfs/fs/xfs/xfs_dir2_sf.c =================================================================== --- xfs.orig/fs/xfs/xfs_dir2_sf.c 2011-06-29 13:15:18.790430446 +0200 +++ xfs/fs/xfs/xfs_dir2_sf.c 2011-06-29 13:15:26.800387051 +0200 @@ -375,7 +375,7 @@ xfs_dir2_sf_addname( /* * Compute entry (and change in) size. */ - add_entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen); + add_entsize = xfs_dir2_sf_entsize(sfp, args->namelen); incr_isize = add_entsize; objchange = 0; #if XFS_BIG_INUMS @@ -469,7 +469,7 @@ xfs_dir2_sf_addname_easy( /* * Grow the in-inode space. */ - xfs_idata_realloc(dp, xfs_dir2_sf_entsize_byname(sfp, args->namelen), + xfs_idata_realloc(dp, xfs_dir2_sf_entsize(sfp, args->namelen), XFS_DATA_FORK); /* * Need to set up again due to realloc of the inode data. @@ -1005,7 +1005,7 @@ xfs_dir2_sf_removename( * Calculate sizes. */ byteoff = (int)((char *)sfep - (char *)sfp); - entsize = xfs_dir2_sf_entsize_byname(sfp, args->namelen); + entsize = xfs_dir2_sf_entsize(sfp, args->namelen); newsize = oldsize - entsize; /* * Copy the part if any after the removed entry, sliding it down. Index: xfs/fs/xfs/xfs_dir2_sf.h =================================================================== --- xfs.orig/fs/xfs/xfs_dir2_sf.h 2011-06-29 13:15:18.807097021 +0200 +++ xfs/fs/xfs/xfs_dir2_sf.h 2011-06-29 13:17:15.143133442 +0200 @@ -76,10 +76,13 @@ typedef struct xfs_dir2_sf_hdr { } __arch_pack xfs_dir2_sf_hdr_t; typedef struct xfs_dir2_sf_entry { - __uint8_t namelen; /* actual name length */ + __u8 namelen; /* actual name length */ xfs_dir2_sf_off_t offset; /* saved offset */ - __uint8_t name[1]; /* name, variable size */ - xfs_dir2_inou_t inumber; /* inode number, var. offset */ + __u8 name[]; /* name, variable size */ + /* + * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a + * variable offset after the name. + */ } __arch_pack xfs_dir2_sf_entry_t; static inline int xfs_dir2_sf_hdr_size(int i8count) @@ -101,32 +104,27 @@ xfs_dir2_sf_put_offset(xfs_dir2_sf_entry INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off); } -static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_hdr_t *sfp, int len) -{ - return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ - ((sfp)->i8count == 0) * \ - ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); -} - static inline int -xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_hdr_t *sfp, xfs_dir2_sf_entry_t *sfep) +xfs_dir2_sf_entsize(xfs_dir2_sf_hdr_t *sfp, int len) { - return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ - ((sfp)->i8count == 0) * \ - ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); + return sizeof(xfs_dir2_sf_entry_t) + /* namelen + offset */ + len + /* name */ + (sfp->i8count ? /* ino */ + sizeof(xfs_dir2_ino8_t) : + sizeof(xfs_dir2_ino4_t)); } static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_hdr_t *sfp) { - return ((xfs_dir2_sf_entry_t *) \ - ((char *)(sfp) + xfs_dir2_sf_hdr_size(sfp->i8count))); + return (xfs_dir2_sf_entry_t *) + ((char *)sfp + xfs_dir2_sf_hdr_size(sfp->i8count)); } static inline xfs_dir2_sf_entry_t * xfs_dir2_sf_nextentry(xfs_dir2_sf_hdr_t *sfp, xfs_dir2_sf_entry_t *sfep) { - return ((xfs_dir2_sf_entry_t *) \ - ((char *)(sfep) + xfs_dir2_sf_entsize_byentry(sfp,sfep))); + return (xfs_dir2_sf_entry_t *) + ((char *)sfep + xfs_dir2_sf_entsize(sfp, sfep->namelen)); } /* _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs