Skip to content

Commit

Permalink
sof: Avoid comparison with NULL
Browse files Browse the repository at this point in the history
Use (!x) instead of comparison with NULL.

Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
  • Loading branch information
Sam Muhammed authored and dbaluta committed Apr 7, 2020
1 parent b4e8b1e commit de085f2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/debug/gdb/gdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/dma-copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ipc/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions test/cmocka/src/list/list_item_append.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/cmocka/src/list/list_item_del.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/cmocka/src/list/list_item_is_last.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/cmocka/src/list/list_item_prepend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit de085f2

Please sign in to comment.