[pacman-dev] Style questions and concerns
Allan McRae
allan at archlinux.org
Fri Feb 25 20:50:47 EST 2011
On 26/02/11 02:27, Dan McGee wrote:
> I've noticed these things a lot in recent patches, so let the
> discussion commence.
>
> 1) typedef-ed structs. This is just a "copy the rest of them" habit,
> but I really feel we should stop doing this, only typedef-ing when we
> are making a public-facing type that we don't want to expose the
> internal contents of. Everything else should remain a struct type, and
> referred to as such, no typedef and no confusion that the fields are
> accessible.
Seems reasonable.
> 2) return(value) style. This is a rule set in stone in the coding
> style doc but people are continuously breaking it. To be fair, it is
> silly, but mixing styles sucks way worse. I propose switching this,
> *BUT* all current patches need to follow current style, and if we
> switch, it should happen post-3.5.0 and in one commit, not this
> piecemeal junk.
Agreed, a single patch post 3.5 would be good.
> 3) C99. Several patches are introducing things that go further down
> this road.I don't think they should all be avoided but I'm not sure
> GCC 3.X (Cygwin is still on this?) supports all of these.
I believe Cygwin's gcc is gcc3.4 by default, but they do provide gcc4
(4.5) packages. Has anyone attempted to compile pacman using gcc-3.x
lately?
> * Variable declarations not at the start of a block. I'm not a huge
> fan of this, as I think having them at the start of the block helps
> clarify scope a lot better.
Agreed.
> * Dynamically sized array declarations, e.g. data[numcpus]. I think
> this needs to be avoided, unfortunately, but it isn't hard to just use
> MALLOC/FREE in this case.
> * C99 structure initialization (saw it in the parallelize patches).
I'm not sure of the relative advantages/disadvantages of these so no
comment from me other than I doubt I would use C99 structure initialization.
Allan
More information about the pacman-dev
mailing list