[bind10-dev] coding guidelines

Michal 'vorner' Vaner michal.vaner at nic.cz
Mon Oct 15 07:31:55 UTC 2012


Hello

On Sun, Oct 14, 2012 at 10:30:26AM +0000, Francis Dupont wrote:
>  - Close all file and socket objects: running tests (aka make check) on
>   some systems show it is not enforced in tests. Perhaps it doesn't
>   matter, perhaps it is too easy to leak a file or socket descriptor?
>   (PS: the messages are from a closing python in debug mode as far as
>    I can remember)

I think some tests are older than the guidelines. We didn't invest the effort to
fix all tests, because some were just too much work with nearly no benefit.

>  - Ordering Include Files: the proposed order is the opposite of the
>   usual one but IMHO it is from the statement about header files themselves.
>   BTW how this applies to config.h?

I'm not sure about the generally usual one, but I'm sure this is not the first
project with „Local headers first“. We decided this is better, because then we
can test the headers have no hidden dependencies.

>  - Ordering Include Files: this section MUST decide about <> vs "" and
>   IMHO suggest full relative paths (i.e., dns/message.h even in the
>   src/lib/dns directory): the idea is to have *only* -I$(xxx)/src/lib
>   in the Makefile. BTW this avoids ambiguity with 2 headers with the
>   same name.

I'd strongly disagree here. I'm OK with full relative paths in < >. But the " "
includes have their place. The " " ones look into the local directory first. If
you write:

  #include <dns/name.h>

you may get unexpected results if something like -I/usr/lib/bind10-other-version
gets at the front of your include path. If you write:

  #include "name.h"

from another file in the dns directory, you're sure the correct (local) name.h
gets picked. So I tend to prefer " " for local files. Also, it makes it clear
this is a local/related header file, not an external library one.

Also, writing things like

  #include "dns/name.h"

is IMO completely wrong, since the " " one is meant to be relative to local
directory.

With regards

-- 
Anyone seen smoking will be considered on fire and will be put out immediately.

Michal 'vorner' Vaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20121015/0290e943/attachment.bin>


More information about the bind10-dev mailing list