xref: /netbsd-src/external/bsd/openldap/dist/doc/devel/variadic_debug/README (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1*e670fd5cSchristosMost of the project now depends on the compiler supporting C99 variadic
2*e670fd5cSchristosmacros. This is used in the Debug() macro everywhere except libldap and
3*e670fd5cSchristosits dependencies.
4*e670fd5cSchristos
5*e670fd5cSchristosFrom now on, any time Debug( level, fmt, args... ) is used, you can and
6*e670fd5cSchristosshould provide the appropriate number of arguments. The coccinelle
7*e670fd5cSchristospatches in this directory implement the transformations used to bring
8*e670fd5cSchristosthe project in line with this.
9*e670fd5cSchristos
10*e670fd5cSchristosAs we still aim to support libldap on platforms that only provide C89,
11*e670fd5cSchristosDebug0/1/2/3 macros are used instead.
12*e670fd5cSchristos
13*e670fd5cSchristosIf you need to adapt your own fork, see ITS#8731, the rest of this
14*e670fd5cSchristosREADME and scripts in this directory on what you'll need to achieve
15*e670fd5cSchristosthis.
16*e670fd5cSchristos
17*e670fd5cSchristosCoccinelle as of git hash e65a7bdc04ac9122acdae2353422c5736b7998ba from
18*e670fd5cSchristoshttps://github.com/coccinelle/coccinelle has been used to run the
19*e670fd5cSchristostransformations performed. One notable limitation at the time of writing
20*e670fd5cSchristosis that multi-part (format) strings are always merged onto the same line.
21*e670fd5cSchristos
22*e670fd5cSchristosSome sources cannot be processed, nssov overlay being a prime example,
23*e670fd5cSchristosbeing wrapped in non-trivial macros.
24*e670fd5cSchristos
25*e670fd5cSchristosThe following semantic patches are involved:
26*e670fd5cSchristos- 03-libldap_Debug.cocci: converts the libraries to use the Debug[0123]
27*e670fd5cSchristos  macros as appropriate
28*e670fd5cSchristos- 04-variadic.cocci: converts the rest of the project to use the Debug
29*e670fd5cSchristos  macro with the right number of arguments (as opposed to padding with
30*e670fd5cSchristos  zeroes)
31*e670fd5cSchristos- 09-merge.cocci will merge an 'snprintf(s, len, "fmt", args...);
32*e670fd5cSchristos  Debug(level, "... %s ...", ..., s, ...);' sequence together
33*e670fd5cSchristos- 07-shortcut.cocci is actually used to apply the above since
34*e670fd5cSchristos  coccinelle's model-checker seems to struggle with state space
35*e670fd5cSchristos  explosion in some of the very long and complex functions we have -
36*e670fd5cSchristos  09-merge.cocci doesn't finish in any reasonable time
37*e670fd5cSchristos
38*e670fd5cSchristosThe equivalence.iso and macros.h files aid coccinelle to parse our
39*e670fd5cSchristossources correctly and simplify the semantic patches.
40