Date: Mon, 20 Sep 2010 09:09:43 -0700 From: Marcel Moolenaar <xcllnt@mac.com> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, Marcel Moolenaar <marcel@FreeBSD.org>, src-committers@FreeBSD.org Subject: Re: svn commit: r212886 - head/sbin/growfs Message-ID: <11C42F9D-7201-4804-8923-430F28E58C57@mac.com> In-Reply-To: <20100920163758.A788@besplex.bde.org> References: <201009200420.o8K4KtKn026514@svn.freebsd.org> <20100920163758.A788@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sep 19, 2010, at 11:55 PM, Bruce Evans wrote: > On Mon, 20 Sep 2010, Marcel Moolenaar wrote: > >> Log: >> Unbreak the build on strong-aligned architectures (arm, ia64). >> Casting from (char *) to (struct ufs1_dinode *) changes the >> alignment requirement of the pointer and GCC does not know that >> the pointer is adequately aligned (due to malloc(3)), and warns >> about it. Cast to (void *) first to by-pass the check. > > A previous version in which the pointer (iobuf) the correct type to > begin with was better. It used to have type void *, but now has type > caddr_t (whose existence is a bug), in order to abuse caddr_t by > assuming that it is char * to do pointer arithmetic on it in 1 place > (iobuf + sblock.fs_cgsize). The 7 other places where iobuf is used > only assume that caddr_t is a pointer (or perhaps a [u]intptr_t). > > growfs has no other instances of caddr_t. My first instinct was to retype iobuf as (void *), but saw the pointer arithmetic and decided against it. If we had a macro that one can use to add X number of bytes to a pointer to any, I would have used that. Other macros to add X number of short, int, long, could be handy too, but that may not be as useful as for bytes. Would it be useful to add a macro like (don't mind the name): #define ADDBYTESTOPOINTER(ptr, cnt) \ ((__typeof(ptr))(void *)((uintptr_t)(void *)(ptr) + (cnt))) ? -- Marcel Moolenaar xcllnt@mac.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?11C42F9D-7201-4804-8923-430F28E58C57>