Skip to content

Commit de085f2

Browse files
Sam Muhammeddbaluta
authored andcommitted
sof: Avoid comparison with NULL
Use (!x) instead of comparison with NULL. Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
1 parent b4e8b1e commit de085f2

7 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/debug/gdb/gdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static unsigned char *mem_to_hex(void *mem_, unsigned char *buf,
445445
unsigned char *mem = mem_;
446446
unsigned char ch;
447447

448-
if ((mem == NULL) || (buf == NULL))
448+
if (!mem || !buf)
449449
return NULL;
450450
while (count-- > 0) {
451451
ch = arch_gdb_load_from_memory(mem);
@@ -468,7 +468,7 @@ static unsigned char *hex_to_mem(const unsigned char *buf, void *mem_,
468468
int i;
469469
unsigned char ch;
470470

471-
if ((mem == NULL) || (buf == NULL))
471+
if (!mem || !buf)
472472
return NULL;
473473
for (i = 0; i < count; i++) {
474474
ch = get_hex(*buf++) << 4;

src/ipc/dma-copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int dma_copy_new(struct dma_copy *dc)
137137
dev = DMA_DEV_HOST;
138138
cap = 0;
139139
dc->dmac = dma_get(dir, cap, dev, DMA_ACCESS_SHARED);
140-
if (dc->dmac == NULL) {
140+
if (!dc->dmac) {
141141
trace_dma_error("dma_copy_new(): dc->dmac = NULL");
142142
return -ENODEV;
143143
}

src/ipc/handler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int ipc_stream_pcm_params(uint32_t stream)
239239
trace_ipc("ipc: comp %d -> params", pcm_params.comp_id);
240240

241241
/* sanity check comp */
242-
if (pcm_dev->cd->pipeline == NULL) {
242+
if (!pcm_dev->cd->pipeline) {
243243
trace_ipc_error("ipc: comp %d pipeline not found",
244244
pcm_params.comp_id);
245245
return -EINVAL;
@@ -357,7 +357,7 @@ static int ipc_stream_pcm_free(uint32_t header)
357357
trace_ipc("ipc: comp %d -> free", free_req.comp_id);
358358

359359
/* sanity check comp */
360-
if (pcm_dev->cd->pipeline == NULL) {
360+
if (!pcm_dev->cd->pipeline) {
361361
trace_ipc_error("ipc: comp %d pipeline not found",
362362
free_req.comp_id);
363363
return -EINVAL;

test/cmocka/src/list/list_item_append.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ static int setup(void **state)
3030
data->tail_minus_1 = malloc(sizeof(struct list_item));
3131
data->tail = malloc(sizeof(struct list_item));
3232

33-
if (data->head == NULL
34-
|| data->tail_minus_1 == NULL
35-
|| data->tail == NULL) {
33+
if (!data->head || !data->tail_minus_1
34+
|| !data->tail) {
3635
free(data->head);
3736
free(data->tail_minus_1);
3837
free(data->tail);

test/cmocka/src/list/list_item_del.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ static int setup(void **state)
3030
data->tail_minus_1 = malloc(sizeof(struct list_item));
3131
data->tail = malloc(sizeof(struct list_item));
3232

33-
if (data->head == NULL
34-
|| data->tail_minus_1 == NULL
35-
|| data->tail == NULL) {
33+
if (!data->head || !data->tail_minus_1
34+
|| !data->tail) {
3635
free(data->head);
3736
free(data->tail_minus_1);
3837
free(data->tail);

test/cmocka/src/list/list_item_is_last.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ static int setup(void **state)
3030
data->tail_minus_1 = malloc(sizeof(struct list_item));
3131
data->tail = malloc(sizeof(struct list_item));
3232

33-
if (data->head == NULL
34-
|| data->tail_minus_1 == NULL
35-
|| data->tail == NULL) {
33+
if (!data->head || !data->tail_minus_1
34+
|| !data->tail) {
3635
free(data->head);
3736
free(data->tail_minus_1);
3837
free(data->tail);

test/cmocka/src/list/list_item_prepend.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ static int setup(void **state)
3030
data->tail_minus_1 = malloc(sizeof(struct list_item));
3131
data->tail = malloc(sizeof(struct list_item));
3232

33-
if (data->head == NULL
34-
|| data->tail_minus_1 == NULL
35-
|| data->tail == NULL) {
33+
if (!data->head || !data->tail_minus_1
34+
|| !data->tail) {
3635
free(data->head);
3736
free(data->tail_minus_1);
3837
free(data->tail);

0 commit comments

Comments
 (0)