Date: Mon, 2 Apr 2012 07:52:52 -0400 From: John Baldwin <jhb@freebsd.org> To: Dimitry Andric <dim@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, Scott Long <scottl@freebsd.org>, Stefan Farfeleder <stefanf@freebsd.org>, David Xu <davidxu@freebsd.org>, svn-src-head@freebsd.org Subject: Re: svn commit: r233700 - head/sys/kern Message-ID: <201204020752.52596.jhb@freebsd.org> In-Reply-To: <4F760E5F.5030300@FreeBSD.org> References: <201203301257.q2UCvE4l042042@svn.freebsd.org> <20120330133045.GD1423@mole.fafoe.narf.at> <4F760E5F.5030300@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, March 30, 2012 3:49:51 pm Dimitry Andric wrote: > On 2012-03-30 15:30, Stefan Farfeleder wrote: > > here are a few similar cases. > > Hm, what about this one that clang warns about: > > sys/dev/asr/asr.c:2420:57: warning: for loop has empty body [-Wempty- body] > for (ha = &Asr_softc_list; *ha; ha = &((*ha)->ha_next)); > ^ > sys/dev/asr/asr.c:2420:57: note: put the semicolon on a separate line to silence this warning [-Wempty-body] > > I'm not sure about it though, the code looks like this: > > static int > asr_attach(device_t dev) > { > [...] > Asr_softc_t *sc, **ha; > [...] > LIST_INIT(&(sc->ha_ccb)); > /* Link us into the HA list */ > for (ha = &Asr_softc_list; *ha; ha = &((*ha)->ha_next)); > *(ha) = sc; > > It seems the for loop walks the list until the end, then tacks 'sc' onto > it. > > So to 'fix' the warning, and make the meaning more explicit, we should > probably rewrite that fragment as: > > LIST_INIT(&(sc->ha_ccb)); > /* Link us into the HA list */ > for (ha = &Asr_softc_list; *ha; ha = &((*ha)->ha_next)) > ; > *(ha) = sc; > > Is this OK? Can we just make that code use a STAILQ() instead of doing it obscurely by hand? -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204020752.52596.jhb>