Tighten header pre-inclusions in headerscheck and cpluspluscheck.
We allow our header files to depend on the appropriate one of postgres.h, postgres_fe.h, or c.h having already been included. However, there are a few headers such as libpq-fe.h that are meant to be used by client applications and therefore must compile without any assumptions about previous inclusions. These test scripts failed to consider that, which seems quite hazardous since we might not immediately notice such a problem otherwise. Hence, adjust these scripts to test relevant libpq and ecpg headers with no prior inclusion. While at it, we can also make an effort to actually use the relevant one of postgres.h, postgres_fe.h, or c.h. I added some rules that guess which one to use based on the first-level src subdirectory, e.g. use postgres_fe.h under src/bin/. These rules are hardly water-tight but they seem to work today, and we can always refine them in the future. These changes don't reveal any live problems today, which is good, but they should make these scripts more able to catch future bugs. Discussion: https://postgr.es/m/2488193.1677863247@sss.pgh.pa.us
This commit is contained in:
parent
ebd551f586
commit
f62975b2af
@ -161,7 +161,33 @@ do
|
||||
# OK, create .c file to include this .h file.
|
||||
{
|
||||
echo 'extern "C" {'
|
||||
test "$f" != src/include/postgres_fe.h && echo '#include "postgres.h"'
|
||||
# Ideally we'd pre-include only the appropriate one of
|
||||
# postgres.h, postgres_fe.h, or c.h. We don't always have enough
|
||||
# info to guess which, but in some subdirectories there's a
|
||||
# reasonable choice to make, and otherwise we use postgres.h.
|
||||
# Also, those three files should compile with no pre-include, as
|
||||
# should src/interfaces headers meant to be exposed to clients.
|
||||
case "$f" in
|
||||
src/include/postgres.h) ;;
|
||||
src/include/postgres_fe.h) ;;
|
||||
src/include/c.h) ;;
|
||||
src/interfaces/libpq/libpq-fe.h) ;;
|
||||
src/interfaces/libpq/libpq-events.h) ;;
|
||||
src/interfaces/ecpg/ecpglib/ecpglib_extern.h)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/interfaces/ecpg/ecpglib/*) ;;
|
||||
src/interfaces/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/bin/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/fe_utils/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/port/*) ;;
|
||||
src/common/*)
|
||||
echo '#include "c.h"' ;;
|
||||
*)
|
||||
echo '#include "postgres.h"' ;;
|
||||
esac
|
||||
echo "#include \"$f\""
|
||||
echo '};'
|
||||
} >$tmp/test.cpp
|
||||
|
@ -142,7 +142,33 @@ do
|
||||
|
||||
# OK, create .c file to include this .h file.
|
||||
{
|
||||
test "$f" != src/include/postgres_fe.h && echo '#include "postgres.h"'
|
||||
# Ideally we'd pre-include only the appropriate one of
|
||||
# postgres.h, postgres_fe.h, or c.h. We don't always have enough
|
||||
# info to guess which, but in some subdirectories there's a
|
||||
# reasonable choice to make, and otherwise we use postgres.h.
|
||||
# Also, those three files should compile with no pre-include, as
|
||||
# should src/interfaces headers meant to be exposed to clients.
|
||||
case "$f" in
|
||||
src/include/postgres.h) ;;
|
||||
src/include/postgres_fe.h) ;;
|
||||
src/include/c.h) ;;
|
||||
src/interfaces/libpq/libpq-fe.h) ;;
|
||||
src/interfaces/libpq/libpq-events.h) ;;
|
||||
src/interfaces/ecpg/ecpglib/ecpglib_extern.h)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/interfaces/ecpg/ecpglib/*) ;;
|
||||
src/interfaces/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/bin/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/fe_utils/*)
|
||||
echo '#include "postgres_fe.h"' ;;
|
||||
src/port/*) ;;
|
||||
src/common/*)
|
||||
echo '#include "c.h"' ;;
|
||||
*)
|
||||
echo '#include "postgres.h"' ;;
|
||||
esac
|
||||
echo "#include \"$f\""
|
||||
} >$tmp/test.c
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user