Skip to content

Commit

Permalink
clang-tidy: fix bugprone-reserved-identifier (without API changes)
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Holland <johannes.holland@infineon.de>
  • Loading branch information
Johannes Holland authored and AndreasFuchsTPM committed Jul 5, 2024
1 parent 3161afd commit f5d851e
Show file tree
Hide file tree
Showing 328 changed files with 3,532 additions and 3,532 deletions.
2 changes: 1 addition & 1 deletion include/tss2/tss2_esys.h
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,7 @@ Esys_Vendor_TCG_Test_Finish(
*/
void
Esys_Free(
void *__ptr);
void *ptr);

TSS2_RC
Esys_GetSysContext(
Expand Down
42 changes: 21 additions & 21 deletions src/tss2-esys/api/Esys_ACT_SetTimeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,26 @@ Esys_ACT_SetTimeout_Async(
r = iesys_check_sequence_async(esysContext);
if (r != TSS2_RC_SUCCESS)
return r;
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;

/* Check input parameters */
r = check_session_feasibility(shandle1, shandle2, shandle3, 1);
return_state_if_error(r, _ESYS_STATE_INIT, "Check session usage");
return_state_if_error(r, ESYS_STATE_INIT, "Check session usage");

/* Retrieve the metadata objects for provided handles */
r = esys_GetResourceObject(esysContext, actHandle, &actHandleNode);
return_state_if_error(r, _ESYS_STATE_INIT, "actHandle unknown.");
return_state_if_error(r, ESYS_STATE_INIT, "actHandle unknown.");

/* Initial invocation of SAPI to prepare the command buffer with parameters */
r = Tss2_Sys_ACT_SetTimeout_Prepare(esysContext->sys,
(actHandleNode == NULL) ? TPM2_RH_NULL
: actHandleNode->rsrc.handle,
startTimeout);
return_state_if_error(r, _ESYS_STATE_INIT, "SAPI Prepare returned error.");
return_state_if_error(r, ESYS_STATE_INIT, "SAPI Prepare returned error.");

/* Calculate the cpHash Values */
r = init_session_tab(esysContext, shandle1, shandle2, shandle3);
return_state_if_error(r, _ESYS_STATE_INIT, "Initialize session resources");
return_state_if_error(r, ESYS_STATE_INIT, "Initialize session resources");
if (actHandleNode != NULL)
iesys_compute_session_value(esysContext->session_tab[0],
&actHandleNode->rsrc.name, &actHandleNode->auth);
Expand All @@ -195,21 +195,21 @@ Esys_ACT_SetTimeout_Async(

/* Generate the auth values and set them in the SAPI command buffer */
r = iesys_gen_auths(esysContext, actHandleNode, NULL, NULL, &auths);
return_state_if_error(r, _ESYS_STATE_INIT,
return_state_if_error(r, ESYS_STATE_INIT,
"Error in computation of auth values");

esysContext->authsCount = auths.count;
if (auths.count > 0) {
r = Tss2_Sys_SetCmdAuths(esysContext->sys, &auths);
return_state_if_error(r, _ESYS_STATE_INIT, "SAPI error on SetCmdAuths");
return_state_if_error(r, ESYS_STATE_INIT, "SAPI error on SetCmdAuths");
}

/* Trigger execution and finish the async invocation */
r = Tss2_Sys_ExecuteAsync(esysContext->sys);
return_state_if_error(r, _ESYS_STATE_INTERNALERROR,
return_state_if_error(r, ESYS_STATE_INTERNALERROR,
"Finish (Execute Async)");

esysContext->state = _ESYS_STATE_SENT;
esysContext->state = ESYS_STATE_SENT;

return r;
}
Expand Down Expand Up @@ -253,31 +253,31 @@ Esys_ACT_SetTimeout_Finish(
}

/* Check for correct sequence and set sequence to irregular for now */
if (esysContext->state != _ESYS_STATE_SENT &&
esysContext->state != _ESYS_STATE_RESUBMISSION) {
if (esysContext->state != ESYS_STATE_SENT &&
esysContext->state != ESYS_STATE_RESUBMISSION) {
LOG_ERROR("Esys called in bad sequence.");
return TSS2_ESYS_RC_BAD_SEQUENCE;
}
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;

/*Receive the TPM response and handle resubmissions if necessary. */
r = Tss2_Sys_ExecuteFinish(esysContext->sys, esysContext->timeout);
if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) {
LOG_DEBUG("A layer below returned TRY_AGAIN: %" PRIx32, r);
esysContext->state = _ESYS_STATE_SENT;
esysContext->state = ESYS_STATE_SENT;
return r;
}
/* This block handle the resubmission of TPM commands given a certain set of
* TPM response codes. */
if (r == TPM2_RC_RETRY || r == TPM2_RC_TESTING || r == TPM2_RC_YIELDED) {
LOG_DEBUG("TPM returned RETRY, TESTING or YIELDED, which triggers a "
"resubmission: %" PRIx32, r);
if (esysContext->submissionCount++ >= _ESYS_MAX_SUBMISSIONS) {
if (esysContext->submissionCount++ >= ESYS_MAX_SUBMISSIONS) {
LOG_WARNING("Maximum number of (re)submissions has been reached.");
esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;
return r;
}
esysContext->state = _ESYS_STATE_RESUBMISSION;
esysContext->state = ESYS_STATE_RESUBMISSION;
r = Tss2_Sys_ExecuteAsync(esysContext->sys);
if (r != TSS2_RC_SUCCESS) {
LOG_WARNING("Error attempting to resubmit");
Expand All @@ -292,11 +292,11 @@ Esys_ACT_SetTimeout_Finish(
/* The following is the "regular error" handling. */
if (iesys_tpm_error(r)) {
LOG_WARNING("Received TPM Error");
esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;
return r;
} else if (r != TSS2_RC_SUCCESS) {
LOG_ERROR("Received a non-TPM Error");
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;
return r;
}

Expand All @@ -305,18 +305,18 @@ Esys_ACT_SetTimeout_Finish(
* parameter decryption have to be done.
*/
r = iesys_check_response(esysContext);
return_state_if_error(r, _ESYS_STATE_INTERNALERROR,
return_state_if_error(r, ESYS_STATE_INTERNALERROR,
"Error: check response");

/*
* After the verification of the response we call the complete function
* to deliver the result.
*/
r = Tss2_Sys_ACT_SetTimeout_Complete(esysContext->sys);
return_state_if_error(r, _ESYS_STATE_INTERNALERROR,
return_state_if_error(r, ESYS_STATE_INTERNALERROR,
"Received error from SAPI unmarshaling");

esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;

return TSS2_RC_SUCCESS;
}
40 changes: 20 additions & 20 deletions src/tss2-esys/api/Esys_AC_GetCapability.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ TSS2_RC Esys_AC_GetCapability_Async(
r = iesys_check_sequence_async(esysContext);
if (r != TSS2_RC_SUCCESS)
return r;
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;

/* Check input parameters */
r = check_session_feasibility(optionalSession1, optionalSession2,
optionalSession3, 0);
return_state_if_error(r, _ESYS_STATE_INIT, "Check session usage");
return_state_if_error(r, ESYS_STATE_INIT, "Check session usage");

TPMI_RH_AC ac_id;
r = iesys_handle_to_tpm_handle(ac, &ac_id);
Expand All @@ -170,33 +170,33 @@ TSS2_RC Esys_AC_GetCapability_Async(
/* Initial invocation of SAPI to prepare the command buffer with parameters */
r = Tss2_Sys_AC_GetCapability_Prepare(esysContext->sys, ac_id, capability,
count);
return_state_if_error(r, _ESYS_STATE_INIT, "SAPI Prepare returned error.");
return_state_if_error(r, ESYS_STATE_INIT, "SAPI Prepare returned error.");

/* Calculate the cpHash Values */
r = init_session_tab(esysContext, optionalSession1, optionalSession2,
optionalSession3);
return_state_if_error(r, _ESYS_STATE_INIT, "Initialize session resources");\
return_state_if_error(r, ESYS_STATE_INIT, "Initialize session resources");\
iesys_compute_session_value(esysContext->session_tab[0], NULL, NULL);
iesys_compute_session_value(esysContext->session_tab[1], NULL, NULL);
iesys_compute_session_value(esysContext->session_tab[2], NULL, NULL);

/* Generate the auth values and set them in the SAPI command buffer */
r = iesys_gen_auths(esysContext, NULL, NULL, NULL, &auths);
return_state_if_error(r, _ESYS_STATE_INIT,
return_state_if_error(r, ESYS_STATE_INIT,
"Error in computation of auth values");

esysContext->authsCount = auths.count;
if (auths.count > 0) {
r = Tss2_Sys_SetCmdAuths(esysContext->sys, &auths);
return_state_if_error(r, _ESYS_STATE_INIT, "SAPI error on SetCmdAuths");
return_state_if_error(r, ESYS_STATE_INIT, "SAPI error on SetCmdAuths");
}

/* Trigger execution and finish the async invocation */
r = Tss2_Sys_ExecuteAsync(esysContext->sys);
return_state_if_error(r, _ESYS_STATE_INTERNALERROR,
return_state_if_error(r, ESYS_STATE_INTERNALERROR,
"Finish (Execute Async)");

esysContext->state = _ESYS_STATE_SENT;
esysContext->state = ESYS_STATE_SENT;

return r;
}
Expand Down Expand Up @@ -245,12 +245,12 @@ TSS2_RC Esys_AC_GetCapability_Finish(
}

/* Check for correct sequence and set sequence to irregular for now */
if (esysContext->state != _ESYS_STATE_SENT &&
esysContext->state != _ESYS_STATE_RESUBMISSION) {
if (esysContext->state != ESYS_STATE_SENT &&
esysContext->state != ESYS_STATE_RESUBMISSION) {
LOG_ERROR("Esys called in bad sequence.");
return TSS2_ESYS_RC_BAD_SEQUENCE;
}
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;

/* Allocate memory for response parameters */
if (capabilityData != NULL) {
Expand All @@ -264,20 +264,20 @@ TSS2_RC Esys_AC_GetCapability_Finish(
r = Tss2_Sys_ExecuteFinish(esysContext->sys, esysContext->timeout);
if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) {
LOG_DEBUG("A layer below returned TRY_AGAIN: %" PRIx32, r);
esysContext->state = _ESYS_STATE_SENT;
esysContext->state = ESYS_STATE_SENT;
goto error_cleanup;
}
/* This block handle the resubmission of TPM commands given a certain set of
* TPM response codes. */
if (r == TPM2_RC_RETRY || r == TPM2_RC_TESTING || r == TPM2_RC_YIELDED) {
LOG_DEBUG("TPM returned RETRY, TESTING or YIELDED, which triggers a "
"resubmission: %" PRIx32, r);
if (esysContext->submissionCount++ >= _ESYS_MAX_SUBMISSIONS) {
if (esysContext->submissionCount++ >= ESYS_MAX_SUBMISSIONS) {
LOG_WARNING("Maximum number of (re)submissions has been reached.");
esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;
goto error_cleanup;
}
esysContext->state = _ESYS_STATE_RESUBMISSION;
esysContext->state = ESYS_STATE_RESUBMISSION;
r = Tss2_Sys_ExecuteAsync(esysContext->sys);
if (r != TSS2_RC_SUCCESS) {
LOG_WARNING("Error attempting to resubmit");
Expand All @@ -292,11 +292,11 @@ TSS2_RC Esys_AC_GetCapability_Finish(
/* The following is the "regular error" handling. */
if (iesys_tpm_error(r)) {
LOG_WARNING("Received TPM Error");
esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;
goto error_cleanup;
} else if (r != TSS2_RC_SUCCESS) {
LOG_ERROR("Received a non-TPM Error");
esysContext->state = _ESYS_STATE_INTERNALERROR;
esysContext->state = ESYS_STATE_INTERNALERROR;
goto error_cleanup;
}

Expand All @@ -305,7 +305,7 @@ TSS2_RC Esys_AC_GetCapability_Finish(
* parameter decryption have to be done.
*/
r = iesys_check_response(esysContext);
goto_state_if_error(r, _ESYS_STATE_INTERNALERROR, "Error: check response",
goto_state_if_error(r, ESYS_STATE_INTERNALERROR, "Error: check response",
error_cleanup);

/*
Expand All @@ -315,11 +315,11 @@ TSS2_RC Esys_AC_GetCapability_Finish(
r = Tss2_Sys_AC_GetCapability_Complete(esysContext->sys, moreData,
(capabilityData != NULL)
? *capabilityData : NULL);
goto_state_if_error(r, _ESYS_STATE_INTERNALERROR,
goto_state_if_error(r, ESYS_STATE_INTERNALERROR,
"Received error from SAPI unmarshaling" ,
error_cleanup);

esysContext->state = _ESYS_STATE_INIT;
esysContext->state = ESYS_STATE_INIT;

return TSS2_RC_SUCCESS;

Expand Down
Loading

0 comments on commit f5d851e

Please sign in to comment.