Merge pull request #29617 from keszybz/efi-no-xmalloc0

efi: drop duplicate initialization to 0
This commit is contained in:
Luca Boccassi
2023-10-19 14:23:54 +01:00
committed by GitHub
2 changed files with 3 additions and 10 deletions
+3 -4
View File
@@ -25,7 +25,7 @@ static EFI_STATUS tpm1_measure_to_pcr_and_event_log(
assert(description);
desc_len = strsize16(description);
tcg_event = xmalloc0(offsetof(TCG_PCR_EVENT, Event) + desc_len);
tcg_event = xmalloc(offsetof(TCG_PCR_EVENT, Event) + desc_len);
*tcg_event = (TCG_PCR_EVENT) {
.EventSize = desc_len,
.PCRIndex = pcrindex,
@@ -62,8 +62,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_tagged_event_log(
desc_len = strsize16(description);
event_size = offsetof(EFI_TCG2_EVENT, Event) + offsetof(EFI_TCG2_TAGGED_EVENT, Event) + desc_len;
event = xmalloc0(event_size);
event = xmalloc(event_size);
*event = (struct event) {
.tcg_event = (EFI_TCG2_EVENT) {
.Size = event_size,
@@ -106,7 +105,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_event_log(
* here. */
desc_len = strsize16(description);
tcg_event = xmalloc0(offsetof(EFI_TCG2_EVENT, Event) + desc_len);
tcg_event = xmalloc(offsetof(EFI_TCG2_EVENT, Event) + desc_len);
*tcg_event = (EFI_TCG2_EVENT) {
.Size = offsetof(EFI_TCG2_EVENT, Event) + desc_len,
.Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER),
-6
View File
@@ -35,12 +35,6 @@ static inline void *xmalloc(size_t size) {
return p;
}
#define xmalloc0(size) \
({ \
size_t _size_ = (size); \
memzero(xmalloc(_size_), _size_); \
})
_malloc_ _alloc_(1, 2) _returns_nonnull_ _warn_unused_result_
static inline void *xmalloc_multiply(size_t size, size_t n) {
assert_se(!__builtin_mul_overflow(size, n, &size));