Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_calyptia_fleet: rewrite error handling code for get_calyptia_file to fix warnings. #8271

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions plugins/in_calyptia_fleet/in_calyptia_fleet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,33 +1012,34 @@ static int get_calyptia_file(struct flb_in_calyptia_fleet_config *ctx,
fname = flb_sds_create_len(dst, strlen(dst));
}

if (fname == NULL) {
goto file_name_error;
}

if (access(fname, F_OK) == 0) {
ret = 0;
goto file_exists;
goto file_error;
}

if (fname == NULL) {
goto client_error;
}

fp = fopen(fname, "w+");

if (fp == NULL) {
goto client_error;
goto file_error;
}

if (hdr != NULL) {
len = fwrite(hdr, strlen(hdr), 1, fp);
if (len < 1) {
flb_plg_error(ctx->ins, "truncated write: %s", dst);
goto file_error;
goto file_write_error;
}
}

len = fwrite(client->resp.payload, client->resp.payload_size, 1, fp);
if (len < 1) {
flb_plg_error(ctx->ins, "truncated write: %s", dst);
goto file_error;
goto file_write_error;
}

if (time_last_modified) {
Expand All @@ -1047,11 +1048,12 @@ static int get_calyptia_file(struct flb_in_calyptia_fleet_config *ctx,

ret = 1;

file_error:
file_write_error:
fclose(fp);
client_error:
file_name_error:
file_error:
flb_sds_destroy(fname);
file_exists:
client_error:
flb_http_client_destroy(client);
return ret;
}
Expand Down
Loading