DragonFly BSD
DragonFly submit List (threaded) for 2004-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: ANSI-fy of ranlib, ruptime and rdist [patches]


From: Joerg Sonnenberger <joerg@xxxxxxxxxxxxxxxxx>
Date: Sat, 24 Jul 2004 15:18:22 +0200

On Sat, Jul 24, 2004 at 05:42:38AM +0200, Douwe Kiela wrote:
> * In some cases I find that *rintf() function calls are preceeded by a
> (void) cast,
> e.g. (void) printf("blah"); do we want this all over the code, or don't we
> want this
> all over the code? In my opinion consistency is a key factor, so we should
> either
> maintain this method everywhere, or nowhere.. Opinions about this?

Remove them. I'm not really sure why there have been introduced in first
place, but this is IMO anachronistic.

[skip return value, no opinion on that}
> * Concerning error checking, what should be used, the return value of a
> function checked
> within a condition, or the condition that checks the return value
> seperately, i.e.
> if ((buf = malloc(bsize)) == NULL)
>           err(1, "buffer");
> versus
> buf = malloc(bsize);
> if (buf == NULL)
>           err(1, "buffer");
> Any opinions on this? Or just let it be the way it is?

I strongly prefer the second version, which is cleaner and often makes
the code more readable by avoiding site-effects in conditionals. changing
it depends on the context, but discouraging it in style(9) should be fine.

> * Concerning the initialisation of function-scoped variables, which one is
> the correct..
> to assign values to variables in their declaration, e.g. int var = 0; or
> seperately, e.g.
> int var;
> var = 0;
> This is being mixed all over the code, which one is the correct?

Normally it is preferable to keep it separate. But an important exception
is are quasi-arguments like they are used in the kernel for newbus functions.
You normally get a device_t instance passed as argument and are only
interested in the softc associated with it, so the
	struct XX_softc = device_get_softc(dev);
is fine. Similiar arguments are true for net layer and struct ifnet or
cast of arguments to the appropiately typed variable.

> That's all for now, I think ;-)

A small note, your MUA does some strange things with the line breaking,
can you fix that?

Joerg

> 
> Greetings,
> Douwe
> 
> 



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]