Skip to content

Commit 2b9e0d9

Browse files
Fix clang-format-18 errors
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
1 parent 4f91ed5 commit 2b9e0d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+170
-147
lines changed

src/tss2-fapi/api/Fapi_Delete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ Fapi_Delete_Async(
404404
/* Check whether a path for exactly one policy was passed. */
405405
if (command->numPaths == 0 && ifapi_path_type_p(path, IFAPI_POLICY_PATH)) {
406406
command->numPaths = 1;
407-
command->pathlist = calloc(1, sizeof(char *));
407+
command->pathlist = (char **)calloc(1, sizeof(char *));
408408
strdup_check(command->pathlist[0], path, r, error_cleanup);
409409
}
410410

src/tss2-fapi/fapi_util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ ifapi_get_object_path(IFAPI_OBJECT *object)
328328
return "/HE";
329329
case ESYS_TR_RH_LOCKOUT:
330330
return "/LOCKOUT";
331+
default:
332+
LOG_ERROR("This code should not be reachable");
333+
return NULL;
331334
}
332335
}
333336
return NULL;

src/tss2-fapi/ifapi_eventlog_system.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ bool parse_event2body(TCG_EVENT2 const *event, UINT32 type) {
222222
}
223223
}
224224
break;
225-
226-
225+
default:
226+
/* no special handling */
227+
break;
227228
}
228229

229230
return true;

src/tss2-fapi/ifapi_helpers.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,11 @@ set_name_hierarchy_object(IFAPI_OBJECT *object)
10121012
case ESYS_TR_RH_PLATFORM_NV:
10131013
handle = TPM2_RH_PLATFORM_NV;
10141014
break;
1015+
default:
1016+
/* Invalid esys handle for a hierarchy */
1017+
LOG_ERROR("This code should not be reachable");
1018+
handle = 0xFFFFFFFF;
1019+
break;
10151020
}
10161021
Tss2_MU_TPM2_HANDLE_Marshal(handle,
10171022
&object->misc.hierarchy.name.name[0], sizeof(TPM2_HANDLE),
@@ -1214,6 +1219,9 @@ cleanup_policy_element(TPMT_POLICYELEMENT *policy)
12141219
case POLICYACTION:
12151220
SAFE_FREE(policy->element.PolicyAction.action);
12161221
break;
1222+
default:
1223+
/* Other policies do not need additional cleanup */
1224+
break;
12171225
}
12181226
}
12191227

@@ -1431,6 +1439,9 @@ copy_policy_element(const TPMT_POLICYELEMENT *from_policy, TPMT_POLICYELEMENT *t
14311439
r, error);
14321440
}
14331441
break;
1442+
default:
1443+
/* Some policies do not need extra copy work, such as POLICYACTION */
1444+
break;
14341445
}
14351446
return TSS2_RC_SUCCESS;
14361447

src/tss2-fapi/ifapi_io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ ifapi_io_dirfiles(
563563
dirname);
564564
}
565565

566-
paths = calloc(numentries, sizeof(*paths));
566+
paths = (char**)calloc(numentries, sizeof(*paths));
567567
check_oom(paths);
568568

569569
/* Iterating through the list of entries inside the directory. */
@@ -589,19 +589,19 @@ ifapi_io_dirfiles(
589589
for (int i = 0; i < numentries; i++) {
590590
free(namelist[i]);
591591
}
592-
free(namelist);
592+
free((void*) namelist);
593593

594594
return TSS2_RC_SUCCESS;
595595

596596
error_oom:
597597
for (int i = 0; i < numentries; i++) {
598598
free(namelist[i]);
599599
}
600-
free(namelist);
600+
free((void*) namelist);
601601
LOG_ERROR("Out of memory");
602602
for (size_t i = 0; i < numpaths; i++)
603603
free(paths[i]);
604-
free(paths);
604+
free((void*)paths);
605605
return TSS2_FAPI_RC_MEMORY;
606606
}
607607

@@ -719,7 +719,7 @@ ifapi_io_dirfiles_all(
719719

720720
if (*numPaths > 0) {
721721
size_t size_path_list = *numPaths * sizeof(char *);
722-
pathlist2 = calloc(1, size_path_list);
722+
pathlist2 = (char**) calloc(1, size_path_list);
723723
goto_if_null2(pathlist2, "Out of memory.", r, TSS2_FAPI_RC_MEMORY,
724724
cleanup);
725725
n = *numPaths;

src/tss2-fapi/ifapi_json_eventlog_serialize.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ TSS2_RC ifapi_json_TCG_EVENT2_serialize(const TCG_EVENT2 *in, UINT32 event_type,
448448
LOGBLOB_TRACE(&data->DevicePath[0], data->LengthOfDevicePath, "DevicePath:");
449449
}
450450
break;
451+
default:
452+
LOG_WARNING("Unknown event type %"PRIu32"", event_type);
453+
break;
451454
}
452455
/* Check whether data has already been added (for legacy events). */
453456
if (!ifapi_get_sub_object(*jso, "event_data", &jso2)) {
@@ -459,7 +462,7 @@ TSS2_RC ifapi_json_TCG_EVENT2_serialize(const TCG_EVENT2 *in, UINT32 event_type,
459462
return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "Could not add json object.");
460463
}
461464
}
462-
return TSS2_RC_SUCCESS;
465+
return TSS2_RC_SUCCESS;
463466
}
464467

465468
bool ifapi_json_TCG_EVENT2_cb(const TCG_EVENT2 *in, UINT32 event_type, void *data)

src/tss2-fapi/ifapi_keystore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ keystore_list_all_abs(
881881
if (*numresults > 0) {
882882

883883
/* Move file names from list to combined array */
884-
file_ary = calloc(*numresults, sizeof(char *));
884+
file_ary = (char**) calloc(*numresults, sizeof(char *));
885885
goto_if_null(file_ary, "Out of memory.", TSS2_FAPI_RC_MEMORY,
886886
cleanup);
887887
i = 0;
@@ -1210,7 +1210,7 @@ keystore_search_obj(
12101210
cleanup:
12111211
for (i = 0; i < keystore->key_search.numPaths; i++)
12121212
free(keystore->key_search.pathlist[i]);
1213-
free(keystore->key_search.pathlist);
1213+
free((void*)keystore->key_search.pathlist);
12141214
if (!*found_path) {
12151215
LOG_ERROR("Object not found");
12161216
r = TSS2_FAPI_RC_KEY_NOT_FOUND;

src/tss2-fapi/ifapi_policy_callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ ifapi_exec_auth_policy(
13891389
for (branch = current_policy->policy_list; branch->next;
13901390
branch = branch->next)
13911391
n += 1;
1392-
names = malloc(sizeof(char *) * n);
1392+
names = (const char**) malloc(sizeof(char *) * n);
13931393
return_if_null(names, "Out of memory.", TSS2_FAPI_RC_MEMORY);
13941394
i = 0;
13951395
branch = current_policy->policy_list;

src/tss2-fapi/ifapi_policy_instantiate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* All rights reserved.
55
*******************************************************************************/
66

7+
#include "tss2_common.h"
78
#ifdef HAVE_CONFIG_H
89
#include "config.h" // IWYU pragma: keep
910
#endif
@@ -433,6 +434,9 @@ ifapi_policyeval_instantiate_finish(
433434
/* Clear key path, only public data will be needed */
434435
SAFE_FREE(pol_element->element.PolicyAuthorize.keyPath);
435436
break;
437+
default:
438+
/* Other policy elements do not need instatiation. */
439+
break;
436440
}
437441
/* Cleanup head of list and use next policy element */
438442
context->policy_elements = first_in_pol_list->next;

src/tss2-fapi/ifapi_profiles.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ ifapi_profiles_initialize_async(
119119
#ifdef HAVE_REALLOCARRAY
120120
profiles->profiles = reallocarray(profiles->profiles, profiles->num_profiles,
121121
sizeof(profiles->profiles[0]));
122-
profiles->filenames = reallocarray(profiles->filenames, profiles->num_profiles,
122+
profiles->filenames = (char **)reallocarray((void *)profiles->filenames, profiles->num_profiles,
123123
sizeof(profiles->filenames[0]));
124124
#else /* HAVE_REALLOCARRAY */
125125
profiles->profiles = realloc(profiles->profiles, profiles->num_profiles *
126126
sizeof(profiles->profiles[0]));
127-
profiles->filenames = realloc(profiles->filenames, profiles->num_profiles *
127+
profiles->filenames = (char **)realloc((void *)profiles->filenames, profiles->num_profiles *
128128
sizeof(profiles->filenames[0]));
129129
#endif /* HAVE_REALLOCARRAY */
130130
/* No need for OOM checks, since num_profiles may only have become smaller */

0 commit comments

Comments
 (0)