The following type of bug occurred frequently since the introduction
of error.h: An error code was defined for some file a.c and was used
in another file b.c. This is all good if each executable that contains
b.o also contains a.o.
If this is not the case, i.e. if there is an executable that contains
b.o but _not_ a.o, the error texts of all errors defined for a.c are
not included in the executable. This results in a segmentation fault
at runtime if PARA_STRERROR() is used for such an error code.
Unfortunately, this was hard to spot because all error codes were
visible everywhere. This patch gets rid of this flaw by making
only those error codes visible for b.c which are safe to use.
According to the above, the set of error codes which are safe to use
in b.c can be defined as follows. Let E_1, ... E_n be the set of
executables that contain b.o and let, for j=1,...n, S_j be the
set of files those files contained in E_j. Then, all errors defined
in the intersection
S_1 \cap S_2 \cap ... \cap S_n
are safe to use in b.c. The patch adds a function to configure.ac
That computes this intersection. Unfortunately, it is rather expensive.
The good news is that this simplifies error.h a bit and that it
already revealed a couple of bugs which are also fixed in the patch:
- afs.c used E_SIGNAL_CAUGHT which was only defined in audiod.
Introduce E_AFS_SIGNAL and change afs.c accordingly.
- audiod uses E_RECV_SYNTAX, which belonged to recv which is
not contained in audiod. Move it to recv_common instead.
This bug is also present in v0.2.x and needs a similar fix.
- E_NOTDIR was used in fd.c, but was defined in osl.c. Not all
executables that include fd.o also include osl.o. Move E_NOTDIR
to the set of errors for fd.