Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf62975b

Browse files
committed
Tighten header pre-inclusions in headerscheck and cpluspluscheck.
We allow our header files to depend on the appropriate one ofpostgres.h, postgres_fe.h, or c.h having already been included.However, there are a few headers such as libpq-fe.h that aremeant to be used by client applications and therefore mustcompile without any assumptions about previous inclusions.These test scripts failed to consider that, which seems quitehazardous since we might not immediately notice such a problemotherwise. Hence, adjust these scripts to test relevant libpqand ecpg headers with no prior inclusion.While at it, we can also make an effort to actually use therelevant one of postgres.h, postgres_fe.h, or c.h. I addedsome rules that guess which one to use based on the first-levelsrc 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
1 parentebd551f commitf62975b

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

‎src/tools/pginclude/cpluspluscheck

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,33 @@ do
161161
# OK, create .c file to include this .h file.
162162
{
163163
echo'extern "C" {'
164-
test"$f"!= src/include/postgres_fe.h&&echo'#include "postgres.h"'
164+
# Ideally we'd pre-include only the appropriate one of
165+
# postgres.h, postgres_fe.h, or c.h. We don't always have enough
166+
# info to guess which, but in some subdirectories there's a
167+
# reasonable choice to make, and otherwise we use postgres.h.
168+
# Also, those three files should compile with no pre-include, as
169+
# should src/interfaces headers meant to be exposed to clients.
170+
case"$f"in
171+
src/include/postgres.h) ;;
172+
src/include/postgres_fe.h) ;;
173+
src/include/c.h) ;;
174+
src/interfaces/libpq/libpq-fe.h) ;;
175+
src/interfaces/libpq/libpq-events.h) ;;
176+
src/interfaces/ecpg/ecpglib/ecpglib_extern.h)
177+
echo'#include "postgres_fe.h"' ;;
178+
src/interfaces/ecpg/ecpglib/*) ;;
179+
src/interfaces/*)
180+
echo'#include "postgres_fe.h"' ;;
181+
src/bin/*)
182+
echo'#include "postgres_fe.h"' ;;
183+
src/fe_utils/*)
184+
echo'#include "postgres_fe.h"' ;;
185+
src/port/*) ;;
186+
src/common/*)
187+
echo'#include "c.h"' ;;
188+
*)
189+
echo'#include "postgres.h"' ;;
190+
esac
165191
echo"#include\"$f\""
166192
echo'};'
167193
}>$tmp/test.cpp
@@ -174,9 +200,9 @@ do
174200
EXTRAINCLUDES="$python_includespec" ;;
175201
src/interfaces/ecpg/*)
176202
EXTRAINCLUDES="-I$builddir/src/interfaces/ecpg/include -I$srcdir/src/interfaces/ecpg/include" ;;
177-
src/backend/parser/*)
203+
src/backend/parser/*)
178204
EXTRAINCLUDES="-I$builddir/src/backend/parser/" ;;
179-
src/backend/utils/adt/*)
205+
src/backend/utils/adt/*)
180206
EXTRAINCLUDES="-I$builddir/src/backend/utils/adt/" ;;
181207
*)
182208
EXTRAINCLUDES="" ;;

‎src/tools/pginclude/headerscheck

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,33 @@ do
142142

143143
# OK, create .c file to include this .h file.
144144
{
145-
test"$f"!= src/include/postgres_fe.h&&echo'#include "postgres.h"'
145+
# Ideally we'd pre-include only the appropriate one of
146+
# postgres.h, postgres_fe.h, or c.h. We don't always have enough
147+
# info to guess which, but in some subdirectories there's a
148+
# reasonable choice to make, and otherwise we use postgres.h.
149+
# Also, those three files should compile with no pre-include, as
150+
# should src/interfaces headers meant to be exposed to clients.
151+
case"$f"in
152+
src/include/postgres.h) ;;
153+
src/include/postgres_fe.h) ;;
154+
src/include/c.h) ;;
155+
src/interfaces/libpq/libpq-fe.h) ;;
156+
src/interfaces/libpq/libpq-events.h) ;;
157+
src/interfaces/ecpg/ecpglib/ecpglib_extern.h)
158+
echo'#include "postgres_fe.h"' ;;
159+
src/interfaces/ecpg/ecpglib/*) ;;
160+
src/interfaces/*)
161+
echo'#include "postgres_fe.h"' ;;
162+
src/bin/*)
163+
echo'#include "postgres_fe.h"' ;;
164+
src/fe_utils/*)
165+
echo'#include "postgres_fe.h"' ;;
166+
src/port/*) ;;
167+
src/common/*)
168+
echo'#include "c.h"' ;;
169+
*)
170+
echo'#include "postgres.h"' ;;
171+
esac
146172
echo"#include\"$f\""
147173
}>$tmp/test.c
148174

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp