diff options
author | Daniel Gustafsson <dgustafsson@postgresql.org> | 2025-02-24 22:20:37 +0100 |
---|---|---|
committer | Daniel Gustafsson <dgustafsson@postgresql.org> | 2025-02-24 22:20:37 +0100 |
commit | d1146dc2a72e96294045f7feb6d0f29082e1c71c (patch) | |
tree | 98ef07bbc44ee90d93d4bc38c6c46debad2ce59a /src | |
parent | 03366b61dfe596796a19368f851859a4764229b9 (diff) | |
download | postgresql-d1146dc2a72e96294045f7feb6d0f29082e1c71c.tar.gz postgresql-d1146dc2a72e96294045f7feb6d0f29082e1c71c.zip |
oauth: Rename macro to avoid collisions on Windows
Our json parsing defined the macros OPTIONAL and REQUIRED to decorate the
structs with for increased readability. This however collides with macros
in the <windef.h> header on Windows.
../src/interfaces/libpq/fe-auth-oauth-curl.c:398:9: warning: "OPTIONAL" redefined
398 | #define OPTIONAL false
| ^~~~~~~~
In file included from D:/a/_temp/msys64/ucrt64/include/windef.h:9,
from D:/a/_temp/msys64/ucrt64/include/windows.h:69,
from D:/a/_temp/msys64/ucrt64/include/winsock2.h:23,
from ../src/include/port/win32_port.h:60,
from ../src/include/port.h:24,
from ../src/include/c.h:1331,
from ../src/include/postgres_fe.h:28,
from ../src/interfaces/libpq/fe-auth-oauth-curl.c:16:
include/minwindef.h:65:9: note: this is the location of the previous definition
65 | #define OPTIONAL
| ^~~~~~~~
Rename to avoid compilation errors in anticipation of implementing
support for Windows.
Reported-by: Dave Cramer (on PostgreSQL Hacking Discord)
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-auth-oauth-curl.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/interfaces/libpq/fe-auth-oauth-curl.c b/src/interfaces/libpq/fe-auth-oauth-curl.c index a80e2047bb7..ae339579f88 100644 --- a/src/interfaces/libpq/fe-auth-oauth-curl.c +++ b/src/interfaces/libpq/fe-auth-oauth-curl.c @@ -394,8 +394,8 @@ struct json_field }; /* Documentation macros for json_field.required. */ -#define REQUIRED true -#define OPTIONAL false +#define PG_OAUTH_REQUIRED true +#define PG_OAUTH_OPTIONAL false /* Parse state for parse_oauth_json(). */ struct oauth_parse @@ -844,8 +844,8 @@ static bool parse_provider(struct async_ctx *actx, struct provider *provider) { struct json_field fields[] = { - {"issuer", JSON_TOKEN_STRING, {&provider->issuer}, REQUIRED}, - {"token_endpoint", JSON_TOKEN_STRING, {&provider->token_endpoint}, REQUIRED}, + {"issuer", JSON_TOKEN_STRING, {&provider->issuer}, PG_OAUTH_REQUIRED}, + {"token_endpoint", JSON_TOKEN_STRING, {&provider->token_endpoint}, PG_OAUTH_REQUIRED}, /*---- * The following fields are technically REQUIRED, but we don't use @@ -857,8 +857,8 @@ parse_provider(struct async_ctx *actx, struct provider *provider) * - id_token_signing_alg_values_supported */ - {"device_authorization_endpoint", JSON_TOKEN_STRING, {&provider->device_authorization_endpoint}, OPTIONAL}, - {"grant_types_supported", JSON_TOKEN_ARRAY_START, {.array = &provider->grant_types_supported}, OPTIONAL}, + {"device_authorization_endpoint", JSON_TOKEN_STRING, {&provider->device_authorization_endpoint}, PG_OAUTH_OPTIONAL}, + {"grant_types_supported", JSON_TOKEN_ARRAY_START, {.array = &provider->grant_types_supported}, PG_OAUTH_OPTIONAL}, {0}, }; @@ -955,24 +955,24 @@ static bool parse_device_authz(struct async_ctx *actx, struct device_authz *authz) { struct json_field fields[] = { - {"device_code", JSON_TOKEN_STRING, {&authz->device_code}, REQUIRED}, - {"user_code", JSON_TOKEN_STRING, {&authz->user_code}, REQUIRED}, - {"verification_uri", JSON_TOKEN_STRING, {&authz->verification_uri}, REQUIRED}, - {"expires_in", JSON_TOKEN_NUMBER, {&authz->expires_in_str}, REQUIRED}, + {"device_code", JSON_TOKEN_STRING, {&authz->device_code}, PG_OAUTH_REQUIRED}, + {"user_code", JSON_TOKEN_STRING, {&authz->user_code}, PG_OAUTH_REQUIRED}, + {"verification_uri", JSON_TOKEN_STRING, {&authz->verification_uri}, PG_OAUTH_REQUIRED}, + {"expires_in", JSON_TOKEN_NUMBER, {&authz->expires_in_str}, PG_OAUTH_REQUIRED}, /* * Some services (Google, Azure) spell verification_uri differently. * We accept either. */ - {"verification_url", JSON_TOKEN_STRING, {&authz->verification_uri}, REQUIRED}, + {"verification_url", JSON_TOKEN_STRING, {&authz->verification_uri}, PG_OAUTH_REQUIRED}, /* * There is no evidence of verification_uri_complete being spelled * with "url" instead with any service provider, so only support * "uri". */ - {"verification_uri_complete", JSON_TOKEN_STRING, {&authz->verification_uri_complete}, OPTIONAL}, - {"interval", JSON_TOKEN_NUMBER, {&authz->interval_str}, OPTIONAL}, + {"verification_uri_complete", JSON_TOKEN_STRING, {&authz->verification_uri_complete}, PG_OAUTH_OPTIONAL}, + {"interval", JSON_TOKEN_NUMBER, {&authz->interval_str}, PG_OAUTH_OPTIONAL}, {0}, }; @@ -1010,9 +1010,9 @@ parse_token_error(struct async_ctx *actx, struct token_error *err) { bool result; struct json_field fields[] = { - {"error", JSON_TOKEN_STRING, {&err->error}, REQUIRED}, + {"error", JSON_TOKEN_STRING, {&err->error}, PG_OAUTH_REQUIRED}, - {"error_description", JSON_TOKEN_STRING, {&err->error_description}, OPTIONAL}, + {"error_description", JSON_TOKEN_STRING, {&err->error_description}, PG_OAUTH_OPTIONAL}, {0}, }; @@ -1069,8 +1069,8 @@ static bool parse_access_token(struct async_ctx *actx, struct token *tok) { struct json_field fields[] = { - {"access_token", JSON_TOKEN_STRING, {&tok->access_token}, REQUIRED}, - {"token_type", JSON_TOKEN_STRING, {&tok->token_type}, REQUIRED}, + {"access_token", JSON_TOKEN_STRING, {&tok->access_token}, PG_OAUTH_REQUIRED}, + {"token_type", JSON_TOKEN_STRING, {&tok->token_type}, PG_OAUTH_REQUIRED}, /*--- * We currently have no use for the following OPTIONAL fields: |