Date: Sun, 5 Dec 2010 22:40:55 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Colin Percival <cperciva@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r216191 - head/sys/i386/i386 Message-ID: <20101205222927.V981@besplex.bde.org> In-Reply-To: <201012042336.oB4NaeID046811@svn.freebsd.org> References: <201012042336.oB4NaeID046811@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 4 Dec 2010, Colin Percival wrote: > Log: > Remove gratuitous i386/amd64 inconsistency in favour of the less verbose > version of declaring a variable initialized to zero. This is resolved backwardsly. style(9) forbids initializing variables in declarations (except for the bug in it which allows this). > Modified: head/sys/i386/i386/busdma_machdep.c > ============================================================================== > --- head/sys/i386/i386/busdma_machdep.c Sat Dec 4 23:24:35 2010 (r216190) > +++ head/sys/i386/i386/busdma_machdep.c Sat Dec 4 23:36:40 2010 (r216191) > @@ -858,7 +858,7 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, > bus_dmamap_callback2_t *callback, void *callback_arg, > int flags) > { > - bus_addr_t lastaddr; > + bus_addr_t lastaddr = 0; > int nsegs, error, first, i; > bus_size_t resid; > struct iovec *iov; > @@ -878,7 +878,6 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, > nsegs = 0; > error = 0; > first = 1; > - lastaddr = (bus_addr_t) 0; Also, here this is inconsisent with all the other initializations, since those actually follow style(9). Other style bugs visible in this patch: - the declarations are totally disordered. The initializations are at least in the same order as the declarations - the cast in the old initialization of `lastaddr' was followed by a space. It is unclear if this cast is needed, and the new initialization doesn't have it. It is not needed if bus_addr_t is a integer or pointer type, but bus_addr_t should be opaque. If it is a pointer type, then the variable is not initialized to zero, but to a null pointer. MD code like this can know what it is, but then you can't copy this code around. Some of the other functions in this file have larger style bugs in declarations/initializations than this. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101205222927.V981>