Skip to content

Change GError pointer into a local variable #98

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

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions src/parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace acap_runtime {

Parameter::Parameter(bool verbose) : _verbose(verbose) {
TRACELOG << "Init" << endl;
_error = NULL;
ax_parameter = ax_parameter_new(APP_NAME, &_error);
GError* error = nullptr;
ax_parameter = ax_parameter_new(APP_NAME, &error);
if (ax_parameter == NULL) {
ERRORLOG << "Error when creating axparameter: " << _error->message << endl;
g_clear_error(&_error);
ERRORLOG << "Error when creating axparameter: " << error->message << endl;
g_clear_error(&error);
throw runtime_error{"Could not Init Parameter Service"};
}
}
Expand All @@ -51,10 +51,11 @@ Status Parameter::GetValues(ServerContext* context, const Request* request, Resp
return Status(StatusCode::INVALID_ARGUMENT, "No valid input request");
}
char* parameter_value = NULL;
if (!ax_parameter_get(ax_parameter, parameter_key, &parameter_value, &_error)) {
ERRORLOG << "Error when getting axparameter: " << _error->message << endl;
GError* error = nullptr;
if (!ax_parameter_get(ax_parameter, parameter_key, &parameter_value, &error)) {
ERRORLOG << "Error when getting axparameter: " << error->message << endl;
parameter_value = g_strdup("");
g_clear_error(&_error);
g_clear_error(&error);
}
TRACELOG << parameter_key << ": " << parameter_value << endl;

Expand Down
1 change: 0 additions & 1 deletion src/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class Parameter final : public keyvaluestore::KeyValueStore::Service {
Status GetValues(ServerContext* context, const Request* request, Response* response) override;

AXParameter* ax_parameter;
GError* _error;
bool _verbose;
};
} // namespace acap_runtime