diff options
author | Elyes Haouas <ehaouas@noos.fr> | 2022-09-13 09:56:22 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-09-15 13:02:33 +0000 |
commit | aebccac7e10eb581e8e7d3354289cfed76860a3e (patch) | |
tree | ffb8e6a5bb256f8675e0496f27c6991c524d1e9b | |
parent | a6b41f2fd05c61ea74bea4a40d02250e9b37bee0 (diff) |
src/security: Use "if (!ptr)" in preference to "if (ptr == NULL)"
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Change-Id: I3def65c016015d8213824e6b8561d8a67b6d5cf0
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67579
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
-rw-r--r-- | src/security/intel/stm/SmmStm.c | 4 | ||||
-rw-r--r-- | src/security/tpm/tss/tcg-2.0/tss.c | 4 | ||||
-rw-r--r-- | src/security/tpm/tss/tcg-2.0/tss_marshaling.c | 2 | ||||
-rw-r--r-- | src/security/tpm/tss/vendor/cr50/cr50.c | 2 | ||||
-rw-r--r-- | src/security/vboot/common.c | 6 | ||||
-rw-r--r-- | src/security/vboot/ec_sync.c | 2 |
6 files changed, 10 insertions, 10 deletions
diff --git a/src/security/intel/stm/SmmStm.c b/src/security/intel/stm/SmmStm.c index 4cb2d0126c..a062bda25b 100644 --- a/src/security/intel/stm/SmmStm.c +++ b/src/security/intel/stm/SmmStm.c @@ -481,7 +481,7 @@ int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries) if (resource_size == 0) return -1; // INVALID_PARAMETER; - if (m_stm_resources_ptr == NULL) { + if (!m_stm_resources_ptr) { // Copy EndResource for initialization m_stm_resources_ptr = stm_resource_heap; @@ -522,7 +522,7 @@ int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries) */ int32_t delete_pi_resource(STM_RSC *resource_list, uint32_t num_entries) { - if (resource_list != NULL) { + if (resource_list) { // ASSERT (false); return -1; // UNSUPPORTED; } diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c index 8c9d12f7b0..5d6cbf89b6 100644 --- a/src/security/tpm/tss/tcg-2.0/tss.c +++ b/src/security/tpm/tss/tcg-2.0/tss.c @@ -55,7 +55,7 @@ static uint32_t tlcl_send_startup(TPM_SU type) response = tpm_process_command(TPM2_Startup, &startup); /* IO error, tpm2_response pointer is empty. */ - if (response == NULL) { + if (!response) { printk(BIOS_ERR, "%s: TPM communication error\n", __func__); return TPM_E_IOERROR; } @@ -89,7 +89,7 @@ static uint32_t tlcl_send_shutdown(TPM_SU type) response = tpm_process_command(TPM2_Shutdown, &shutdown); /* IO error, tpm2_response pointer is empty. */ - if (response == NULL) { + if (!response) { printk(BIOS_ERR, "%s: TPM communication error\n", __func__); return TPM_E_IOERROR; } diff --git a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c index ae623043e6..f1b9522e6c 100644 --- a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c +++ b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c @@ -517,7 +517,7 @@ static int unmarshal_TPM2B_MAX_NV_BUFFER(struct ibuf *ib, nv_buffer->t.buffer = ibuf_oob_drain(ib, nv_buffer->t.size); - if (nv_buffer->t.buffer == NULL) { + if (!nv_buffer->t.buffer) { printk(BIOS_ERR, "%s:%d - " "size mismatch: expected %d, remaining %zd\n", __func__, __LINE__, nv_buffer->t.size, diff --git a/src/security/tpm/tss/vendor/cr50/cr50.c b/src/security/tpm/tss/vendor/cr50/cr50.c index e38ca30ad4..57d0b61a24 100644 --- a/src/security/tpm/tss/vendor/cr50/cr50.c +++ b/src/security/tpm/tss/vendor/cr50/cr50.c @@ -18,7 +18,7 @@ uint32_t tlcl_cr50_enable_nvcommits(void) response = tpm_process_command(TPM2_CR50_VENDOR_COMMAND, &sub_command); - if (response == NULL || (response && response->hdr.tpm_code)) { + if (!response || (response && response->hdr.tpm_code)) { if (response) printk(BIOS_INFO, "%s: failed %x\n", __func__, response->hdr.tpm_code); diff --git a/src/security/vboot/common.c b/src/security/vboot/common.c index c2d9340217..7f1aee1820 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -17,10 +17,10 @@ static void *vboot_get_workbuf(void) if (cbmem_possibly_online()) wb = cbmem_find(CBMEM_ID_VBOOT_WORKBUF); - if (wb == NULL && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) && preram_symbols_available()) + if (!wb && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) && preram_symbols_available()) wb = _vboot2_work; - assert(wb != NULL); + assert(wb); return wb; } @@ -72,7 +72,7 @@ static void vboot_setup_cbmem(int unused) vb2_error_t rv; const size_t cbmem_size = VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE; void *wb_cbmem = cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size); - assert(wb_cbmem != NULL); + assert(wb_cbmem); /* * On platforms where VBOOT_STARTS_BEFORE_BOOTBLOCK, the verification * occurs before the main processor starts running. The vboot data- diff --git a/src/security/vboot/ec_sync.c b/src/security/vboot/ec_sync.c index 5b3287ed13..b3b17dd10e 100644 --- a/src/security/vboot/ec_sync.c +++ b/src/security/vboot/ec_sync.c @@ -383,7 +383,7 @@ static vb2_error_t ec_get_expected_hash(enum vb2_firmware_selection select, /* vboot has no API to return this memory, so must permanently leak a mapping here. */ const uint8_t *file = cbfs_map(filename, &size); - if (file == NULL) + if (!file) return VB2_ERROR_UNKNOWN; *hash = file; |