Skip to content

Commit 0426c9d

Browse files
committed
Migrate port to uint16_t in Kinesis output plugins
Signed-off-by: Ryan Underwood <[email protected]>
1 parent 2497139 commit 0426c9d

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

plugins/out_kinesis_firehose/firehose.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,16 @@ static int cb_firehose_init(struct flb_output_instance *ins,
131131
*/
132132
flb_plg_debug(ins, "Retrieved port from ins->host.port: %d", ins->host.port);
133133

134-
if (ins->host.port >= FLB_KINESIS_MIN_PORT && ins->host.port <= FLB_KINESIS_MAX_PORT) {
135-
ctx->port = ins->host.port;
136-
flb_plg_debug(ins, "Setting port to: %d", ctx->port);
137-
}
138-
else if (ins->host.port == 0) {
134+
if (ins->host.port == 0) {
139135
ctx->port = FLB_KINESIS_DEFAULT_HTTPS_PORT;
140136
flb_plg_debug(ins, "Port not set. Using default HTTPS port: %d", ctx->port);
141137
}
138+
else if (ins->host.port == (ctx->port = (uint16_t)ins->host.port)) {
139+
flb_plg_debug(ins, "Setting port to: %d", ctx->port);
140+
}
142141
else {
143142
flb_plg_error(ins, "Invalid port number: %d. Must be between %d and %d",
144-
ins->host.port, FLB_KINESIS_MIN_PORT, FLB_KINESIS_MAX_PORT);
143+
ins->host.port, 0, (uint16_t)-1);
145144
goto error;
146145
}
147146

plugins/out_kinesis_firehose/firehose.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#define DEFAULT_TIME_KEY_FORMAT "%Y-%m-%dT%H:%M:%S"
3131

3232
#define FLB_KINESIS_DEFAULT_HTTPS_PORT 443
33-
#define FLB_KINESIS_MIN_PORT 1
34-
#define FLB_KINESIS_MAX_PORT 65535
3533

3634
/* buffers used for each flush */
3735
struct flush {
@@ -91,7 +89,7 @@ struct flb_firehose {
9189
const char *log_key;
9290
const char *external_id;
9391
char *sts_endpoint;
94-
int port;
92+
uint16_t port;
9593
char *profile;
9694
int custom_endpoint;
9795
int retry_requests;

plugins/out_kinesis_streams/kinesis.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,17 @@ static int cb_kinesis_init(struct flb_output_instance *ins,
127127
* @param ctx The Kinesis output plugin context.
128128
*/
129129
flb_plg_debug(ins, "Retrieved port from ins->host.port: %d", ins->host.port);
130-
131-
if (ins->host.port >= FLB_KINESIS_MIN_PORT && ins->host.port <= FLB_KINESIS_MAX_PORT) {
132-
ctx->port = ins->host.port;
133-
flb_plg_debug(ins, "Setting port to: %d", ctx->port);
134-
}
135-
else if (ins->host.port == 0) {
130+
131+
if (ins->host.port == 0) {
136132
ctx->port = FLB_KINESIS_DEFAULT_HTTPS_PORT;
137133
flb_plg_debug(ins, "Port not set. Using default HTTPS port: %d", ctx->port);
138134
}
135+
else if (ins->host.port == (ctx->port = (uint16_t)ins->host.port)) {
136+
flb_plg_debug(ins, "Setting port to: %d", ctx->port);
137+
}
139138
else {
140-
flb_plg_error(ins, "Invalid port number: %d. Must be between %d and %d",
141-
ins->host.port, FLB_KINESIS_MIN_PORT, FLB_KINESIS_MAX_PORT);
139+
flb_plg_error(ins, "Invalid port number: %d. Must be between %d and %d",
140+
ins->host.port, 0, (uint16_t)-1);
142141
goto error;
143142
}
144143

plugins/out_kinesis_streams/kinesis.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#define DEFAULT_TIME_KEY_FORMAT "%Y-%m-%dT%H:%M:%S"
3131

3232
#define FLB_KINESIS_DEFAULT_HTTPS_PORT 443
33-
#define FLB_KINESIS_MIN_PORT 1
34-
#define FLB_KINESIS_MAX_PORT 65535
3533

3634
/* buffers used for each flush */
3735
struct flush {
@@ -96,7 +94,7 @@ struct flb_kinesis {
9694
int retry_requests;
9795
char *sts_endpoint;
9896
int custom_endpoint;
99-
int port;
97+
uint16_t port;
10098
char *profile;
10199

102100
/* in this plugin the 'random' partition key is a uuid + fluent tag + timestamp */

0 commit comments

Comments
 (0)