Skip to content

Commit afda557

Browse files
committed
Fix CI: give st config-struct fields default member initializers
GCC's -Wmissing-field-initializers (-Wextra, and the build is -Werror) fires on a partial designated-initializer such as .deadLetterPolicy({.maxRedeliverCount = 5}) for every omitted member that lacks a default member initializer. clang does not warn, so this was missed locally. Give every optional field in the user-facing policy/ack/DLQ structs an '= std::nullopt' NSDMI so designated-init of any subset is warning-clean. Verified with gcc:13 -Wextra -Werror against all four st examples. Signed-off-by: Matteo Merli <mmerli@apache.org>
1 parent fa4def3 commit afda557

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

include/pulsar/st/Consumer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ enum class SubscriptionInitialPosition
5454
struct AckPolicy {
5555
/** Time window over which acknowledgments are batched before being sent, in milliseconds; 0 acks
5656
* immediately. Unset uses the client default. */
57-
std::optional<std::chrono::milliseconds> groupTime;
57+
std::optional<std::chrono::milliseconds> groupTime = std::nullopt;
5858
/** Delay before a negatively-acknowledged message is redelivered, in milliseconds. QueueConsumer only.
5959
* Unset uses the client default. */
60-
std::optional<std::chrono::milliseconds> negativeAckRedeliveryDelay;
60+
std::optional<std::chrono::milliseconds> negativeAckRedeliveryDelay = std::nullopt;
6161
};
6262

6363
/**
@@ -73,10 +73,10 @@ struct DeadLetterPolicy {
7373
* which disables dead-lettering. */
7474
int maxRedeliverCount = 0;
7575
/** Name of the dead-letter topic. Unset defaults to "&lt;topic&gt;-&lt;subscription&gt;-DLQ". */
76-
std::optional<std::string> deadLetterTopic;
76+
std::optional<std::string> deadLetterTopic = std::nullopt;
7777
/** If set, creates this subscription on the dead-letter topic up front so no messages are missed before a
7878
* consumer attaches. Unset creates no initial subscription. */
79-
std::optional<std::string> initialSubscriptionName;
79+
std::optional<std::string> initialSubscriptionName = std::nullopt;
8080
};
8181

8282
} // namespace pulsar::st

include/pulsar/st/Policies.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@ struct MemorySize {
8989
*/
9090
struct ConnectionPolicy {
9191
/** Number of physical connections opened to each broker. Unset uses the client default. */
92-
std::optional<int> connectionsPerBroker;
92+
std::optional<int> connectionsPerBroker = std::nullopt;
9393
/** Maximum time to wait for a TCP/TLS connection to be established, in milliseconds. Unset uses the
9494
* client default. */
95-
std::optional<std::chrono::milliseconds> connectionTimeout;
95+
std::optional<std::chrono::milliseconds> connectionTimeout = std::nullopt;
9696
/** Maximum time to wait for a broker request (e.g. produce/consume control ops) to complete, in
9797
* milliseconds. Unset uses the client default. */
98-
std::optional<std::chrono::milliseconds> operationTimeout;
98+
std::optional<std::chrono::milliseconds> operationTimeout = std::nullopt;
9999
/** Interval between keep-alive pings sent on an idle connection, in seconds. Unset uses the client
100100
* default. */
101-
std::optional<std::chrono::seconds> keepAliveInterval;
101+
std::optional<std::chrono::seconds> keepAliveInterval = std::nullopt;
102102
/** Maximum number of concurrent topic-lookup requests in flight. Unset uses the client default. */
103-
std::optional<int> maxLookupRequests;
103+
std::optional<int> maxLookupRequests = std::nullopt;
104104
/** Maximum number of lookup redirects to follow before failing a lookup. Unset uses the client default.
105105
*/
106-
std::optional<int> maxLookupRedirects;
106+
std::optional<int> maxLookupRedirects = std::nullopt;
107107
/** Time an idle pooled connection may stay open before being closed, in milliseconds. Unset uses the
108108
* client default. */
109-
std::optional<std::chrono::milliseconds> maxConnectionIdleTime;
109+
std::optional<std::chrono::milliseconds> maxConnectionIdleTime = std::nullopt;
110110
};
111111

112112
/**
@@ -118,10 +118,10 @@ struct ConnectionPolicy {
118118
*/
119119
struct BackoffPolicy {
120120
/** Delay before the first reconnection attempt, in milliseconds. Unset uses the client default. */
121-
std::optional<std::chrono::milliseconds> initialBackoff;
121+
std::optional<std::chrono::milliseconds> initialBackoff = std::nullopt;
122122
/** Upper bound on the backoff delay as it grows across retries, in milliseconds. Unset uses the client
123123
* default. */
124-
std::optional<std::chrono::milliseconds> maxBackoff;
124+
std::optional<std::chrono::milliseconds> maxBackoff = std::nullopt;
125125
};
126126

127127
/**
@@ -136,13 +136,13 @@ struct TlsPolicy {
136136
bool enabled = false;
137137
/** Path to the PEM file of trusted CA certificates used to verify the broker. Unset uses the system trust
138138
* store. */
139-
std::optional<std::string> trustCertsFilePath;
139+
std::optional<std::string> trustCertsFilePath = std::nullopt;
140140
/** Path to the client certificate PEM file, for mutual TLS. Unset disables client-certificate
141141
* authentication. */
142-
std::optional<std::string> certificateFilePath;
142+
std::optional<std::string> certificateFilePath = std::nullopt;
143143
/** Path to the client private key PEM file, for mutual TLS. Unset disables client-certificate
144144
* authentication. */
145-
std::optional<std::string> privateKeyFilePath;
145+
std::optional<std::string> privateKeyFilePath = std::nullopt;
146146
/** Whether to accept the broker's certificate without validating it against the trust store. Defaults to
147147
* false (validation enforced). */
148148
bool allowInsecureConnection = false;
@@ -160,7 +160,7 @@ struct TlsPolicy {
160160
struct TransactionPolicy {
161161
/** Default lifetime of a transaction before it is automatically aborted, in milliseconds. Unset uses the
162162
* client default. */
163-
std::optional<std::chrono::milliseconds> timeout;
163+
std::optional<std::chrono::milliseconds> timeout = std::nullopt;
164164
};
165165

166166
} // namespace pulsar::st

0 commit comments

Comments
 (0)