Wireshark-dev: Re: [Wireshark-dev] Replace ntohl() with g_ntohl() -> automated check?
From: Jeff Morriss <jeff.morriss@xxxxxxxxxxx>
Date: Wed, 15 Nov 2006 17:08:39 +0800


Ulf Lamping wrote:
Thomas Anders wrote:
Joerg Mayer wrote:
On Tue, Nov 07, 2006 at 12:57:59PM +0000, LEGO wrote:
what about #defining them so they trigger an error?
#define ntohl error() won't work, a g_ntohl would match as well.
I'm not sure that's true. Have you actually tried?
a macro definition is different from a simple define, #define ntohl() will *not* affect any g_ntohl() calls! -> no problem here!
FWIW, Samba3 is doing something similar for C++ reserved words:
(http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/branches/SAMBA_3_0_RELEASE/source/include/includes.h?rev=19018&view=markup)

- --- snip ---
/* only do the C++ reserved word check when we compile
   to include --with-developer since too many systems
   still have comflicts with their header files (e.g. IRIX 6.4) */

#if !defined(__cplusplus) && defined(DEVELOPER)
#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#endif
- --- snap ---

This is a simple approach which seem to be also working for function declarations :-)

[...]

So with the current #include sequence this won't work!


Any ideas?

Perl is built for this kind of thing. :-)

It requires an extra step, but the code to do it is quite easy, see attached. This program has 2 lists: a list of prohibited APIs that must not be used (or the program will return an error) and a list of deprecated APIs that, if they are used, only generate a warning.

Does Subversion have the concept of a check-in trigger? E.g., before accepting the check-in it runs a script and if the script returns an error, the check-in fails? Could be done there, though that's a bit aggressive ;-).

Or "make codecheck" or something else...

Of course the lists I put are just some basics for testing. And maybe the lists need to be different for dissectors vs. core Wireshark, etc., but the concept is there. I even put a Copyright notice in case it's a good enough start. :-)

Attachment: checkAPIs.pl.gz
Description: GNU Zip compressed data