Skip to content

Commit

Permalink
FAPI: Fix warnings unused variable.
Browse files Browse the repository at this point in the history
* In ifapi_json_TPMS_POLICYAUTHORIZE_serialize it has to be checked
  whether the number of an optional condition is greater zero.
* A warning "unused variable" if LOG_LEVEL == 0 is fixed.

Signed-off-by: Juergen Repp <[email protected]>
  • Loading branch information
JuergenReppSIT authored and AndreasFuchsTPM committed Mar 26, 2024
1 parent a50b90d commit 7c87de5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tss2-fapi/ifapi_policy_json_serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,13 @@ ifapi_json_TPMS_POLICYAUTHORIZE_serialize(const TPMS_POLICYAUTHORIZE *in,

json_object_object_add(*jso, "rsaScheme", jso2);

/* Check whether only one condition field found in policy. */
if (cond_cnt > 1) {
return_error(TSS2_FAPI_RC_BAD_VALUE,
"Exactly one conditional is allowed for policy "
"duplication select.");
}

return TSS2_RC_SUCCESS;
}

Expand Down
4 changes: 4 additions & 0 deletions src/tss2-fapi/tpm_json_deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ json_object*
ifapi_parse_json(const char *jstring) {
json_object *jso = NULL;
enum json_tokener_error jerr;
#if MAXLOGLEVEL > 0
int line = 1;
int line_offset = 0;
int char_pos;
#endif
struct json_tokener* tok = json_tokener_new();
if (!tok) {
LOG_ERROR("Could not allocate json tokener");
Expand All @@ -45,6 +47,7 @@ ifapi_parse_json(const char *jstring) {
jso = json_tokener_parse_ex(tok, jstring, -1);
jerr = json_tokener_get_error(tok);
if (jerr != json_tokener_success) {
#if MAXLOGLEVEL > 0
for (char_pos = 0; char_pos <= tok->char_offset; char_pos++) {
if (jstring[char_pos] == '\n') {
line++;
Expand All @@ -55,6 +58,7 @@ ifapi_parse_json(const char *jstring) {
}
LOG_ERROR("Invalid JSON at line %i column %i: %s.", line, line_offset,
json_tokener_error_desc(jerr));
#endif
json_tokener_free(tok);
return NULL;
}
Expand Down

0 comments on commit 7c87de5

Please sign in to comment.