From de085f22f55a88936fd93357dcfeeb5449df5e49 Mon Sep 17 00:00:00 2001 From: Sam Muhammed Date: Thu, 2 Apr 2020 18:52:33 -0400 Subject: [PATCH] sof: Avoid comparison with NULL Use (!x) instead of comparison with NULL. Signed-off-by: Sam Muhammed --- src/debug/gdb/gdb.c | 4 ++-- src/ipc/dma-copy.c | 2 +- src/ipc/handler.c | 4 ++-- test/cmocka/src/list/list_item_append.c | 5 ++--- test/cmocka/src/list/list_item_del.c | 5 ++--- test/cmocka/src/list/list_item_is_last.c | 5 ++--- test/cmocka/src/list/list_item_prepend.c | 5 ++--- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/debug/gdb/gdb.c b/src/debug/gdb/gdb.c index 3663ca7d6a8d..64e53fbbc079 100644 --- a/src/debug/gdb/gdb.c +++ b/src/debug/gdb/gdb.c @@ -445,7 +445,7 @@ static unsigned char *mem_to_hex(void *mem_, unsigned char *buf, unsigned char *mem = mem_; unsigned char ch; - if ((mem == NULL) || (buf == NULL)) + if (!mem || !buf) return NULL; while (count-- > 0) { ch = arch_gdb_load_from_memory(mem); @@ -468,7 +468,7 @@ static unsigned char *hex_to_mem(const unsigned char *buf, void *mem_, int i; unsigned char ch; - if ((mem == NULL) || (buf == NULL)) + if (!mem || !buf) return NULL; for (i = 0; i < count; i++) { ch = get_hex(*buf++) << 4; diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c index b4d04cd4d28f..363a529a53c2 100644 --- a/src/ipc/dma-copy.c +++ b/src/ipc/dma-copy.c @@ -137,7 +137,7 @@ int dma_copy_new(struct dma_copy *dc) dev = DMA_DEV_HOST; cap = 0; dc->dmac = dma_get(dir, cap, dev, DMA_ACCESS_SHARED); - if (dc->dmac == NULL) { + if (!dc->dmac) { trace_dma_error("dma_copy_new(): dc->dmac = NULL"); return -ENODEV; } diff --git a/src/ipc/handler.c b/src/ipc/handler.c index 895e2784ff89..4f740e0e28a6 100644 --- a/src/ipc/handler.c +++ b/src/ipc/handler.c @@ -239,7 +239,7 @@ static int ipc_stream_pcm_params(uint32_t stream) trace_ipc("ipc: comp %d -> params", pcm_params.comp_id); /* sanity check comp */ - if (pcm_dev->cd->pipeline == NULL) { + if (!pcm_dev->cd->pipeline) { trace_ipc_error("ipc: comp %d pipeline not found", pcm_params.comp_id); return -EINVAL; @@ -357,7 +357,7 @@ static int ipc_stream_pcm_free(uint32_t header) trace_ipc("ipc: comp %d -> free", free_req.comp_id); /* sanity check comp */ - if (pcm_dev->cd->pipeline == NULL) { + if (!pcm_dev->cd->pipeline) { trace_ipc_error("ipc: comp %d pipeline not found", free_req.comp_id); return -EINVAL; diff --git a/test/cmocka/src/list/list_item_append.c b/test/cmocka/src/list/list_item_append.c index 856e45a92869..ff4ba2f7f68c 100644 --- a/test/cmocka/src/list/list_item_append.c +++ b/test/cmocka/src/list/list_item_append.c @@ -30,9 +30,8 @@ static int setup(void **state) data->tail_minus_1 = malloc(sizeof(struct list_item)); data->tail = malloc(sizeof(struct list_item)); - if (data->head == NULL - || data->tail_minus_1 == NULL - || data->tail == NULL) { + if (!data->head || !data->tail_minus_1 + || !data->tail) { free(data->head); free(data->tail_minus_1); free(data->tail); diff --git a/test/cmocka/src/list/list_item_del.c b/test/cmocka/src/list/list_item_del.c index e9a0edffd26e..ad6bb81a1237 100644 --- a/test/cmocka/src/list/list_item_del.c +++ b/test/cmocka/src/list/list_item_del.c @@ -30,9 +30,8 @@ static int setup(void **state) data->tail_minus_1 = malloc(sizeof(struct list_item)); data->tail = malloc(sizeof(struct list_item)); - if (data->head == NULL - || data->tail_minus_1 == NULL - || data->tail == NULL) { + if (!data->head || !data->tail_minus_1 + || !data->tail) { free(data->head); free(data->tail_minus_1); free(data->tail); diff --git a/test/cmocka/src/list/list_item_is_last.c b/test/cmocka/src/list/list_item_is_last.c index 9804508e0d3d..ffd1abee50bd 100644 --- a/test/cmocka/src/list/list_item_is_last.c +++ b/test/cmocka/src/list/list_item_is_last.c @@ -30,9 +30,8 @@ static int setup(void **state) data->tail_minus_1 = malloc(sizeof(struct list_item)); data->tail = malloc(sizeof(struct list_item)); - if (data->head == NULL - || data->tail_minus_1 == NULL - || data->tail == NULL) { + if (!data->head || !data->tail_minus_1 + || !data->tail) { free(data->head); free(data->tail_minus_1); free(data->tail); diff --git a/test/cmocka/src/list/list_item_prepend.c b/test/cmocka/src/list/list_item_prepend.c index 55f61514976b..e86fa97f8a5e 100644 --- a/test/cmocka/src/list/list_item_prepend.c +++ b/test/cmocka/src/list/list_item_prepend.c @@ -30,9 +30,8 @@ static int setup(void **state) data->tail_minus_1 = malloc(sizeof(struct list_item)); data->tail = malloc(sizeof(struct list_item)); - if (data->head == NULL - || data->tail_minus_1 == NULL - || data->tail == NULL) { + if (!data->head || !data->tail_minus_1 + || !data->tail) { free(data->head); free(data->tail_minus_1); free(data->tail);