mirror of
https://github.com/OpenAMP/open-amp.git
synced 2025-12-11 17:26:22 +08:00
lib: fix COMPARISON_TO_NULL reported by checkpatch
Align coding rule with checkpatch recommendation concerning the comparison to null. Some comparisons in macro have not be fixed for readability. Examples of code not updated: VQ_PARAM_CHK(ring == NULL, status, ERROR_VQUEUE_INVLD_PARAM); VQASSERT(vq, cookie != NULL, "enqueuing with no cookie"); Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
This commit is contained in:
@@ -23,7 +23,7 @@ static int rpmsg_rpc_ept_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
(void)priv;
|
||||
(void)src;
|
||||
|
||||
if (data != NULL && ept != NULL) {
|
||||
if (data && ept) {
|
||||
syscall = data;
|
||||
if (syscall->id == TERM_SYSCALL_ID) {
|
||||
rpmsg_destroy_ept(ept);
|
||||
@@ -34,7 +34,7 @@ static int rpmsg_rpc_ept_cb(struct rpmsg_endpoint *ept, void *data, size_t len,
|
||||
struct rpmsg_rpc_data,
|
||||
ept);
|
||||
metal_spinlock_acquire(&rpc->buflock);
|
||||
if (rpc->respbuf != NULL && rpc->respbuf_len != 0) {
|
||||
if (rpc->respbuf && rpc->respbuf_len != 0) {
|
||||
if (len > rpc->respbuf_len)
|
||||
len = rpc->respbuf_len;
|
||||
memcpy(rpc->respbuf, data, len);
|
||||
@@ -68,7 +68,7 @@ int rpmsg_rpc_init(struct rpmsg_rpc_data *rpc,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rpc == NULL || rdev == NULL)
|
||||
if (!rpc || !rdev)
|
||||
return -EINVAL;
|
||||
metal_spinlock_init(&rpc->buflock);
|
||||
metal_mutex_init(&rpc->lock);
|
||||
@@ -95,7 +95,7 @@ int rpmsg_rpc_init(struct rpmsg_rpc_data *rpc,
|
||||
|
||||
void rpmsg_rpc_release(struct rpmsg_rpc_data *rpc)
|
||||
{
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return;
|
||||
if (rpc->ept_destroyed == 0)
|
||||
rpmsg_destroy_ept(&rpc->ept);
|
||||
@@ -114,7 +114,7 @@ int rpmsg_rpc_send(struct rpmsg_rpc_data *rpc,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return -EINVAL;
|
||||
metal_spinlock_acquire(&rpc->buflock);
|
||||
rpc->respbuf = resp;
|
||||
@@ -135,7 +135,7 @@ int rpmsg_rpc_send(struct rpmsg_rpc_data *rpc,
|
||||
|
||||
void rpmsg_set_default_rpc(struct rpmsg_rpc_data *rpc)
|
||||
{
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return;
|
||||
rpmsg_default_rpc = rpc;
|
||||
}
|
||||
@@ -163,11 +163,11 @@ int _open(const char *filename, int flags, int mode)
|
||||
unsigned char tmpbuf[MAX_BUF_LEN];
|
||||
int ret;
|
||||
|
||||
if (filename == NULL || payload_size > (int)MAX_BUF_LEN) {
|
||||
if (!filename || payload_size > (int)MAX_BUF_LEN) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return -EINVAL;
|
||||
|
||||
/* Construct rpc payload */
|
||||
@@ -212,7 +212,7 @@ int _read(int fd, char *buffer, int buflen)
|
||||
unsigned char tmpbuf[MAX_BUF_LEN];
|
||||
int ret;
|
||||
|
||||
if (rpc == NULL || buffer == NULL || buflen == 0)
|
||||
if (!rpc || !buffer || buflen == 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Construct rpc payload */
|
||||
@@ -269,7 +269,7 @@ int _write(int fd, const char *ptr, int len)
|
||||
unsigned char *tmpptr;
|
||||
int null_term = 0;
|
||||
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return -EINVAL;
|
||||
if (fd == 1)
|
||||
null_term = 1;
|
||||
@@ -319,7 +319,7 @@ int _close(int fd)
|
||||
int payload_size = sizeof(syscall);
|
||||
struct rpmsg_rpc_data *rpc = rpmsg_default_rpc;
|
||||
|
||||
if (rpc == NULL)
|
||||
if (!rpc)
|
||||
return -EINVAL;
|
||||
syscall.id = CLOSE_SYSCALL_ID;
|
||||
syscall.args.int_field1 = fd;
|
||||
|
||||
@@ -23,7 +23,7 @@ static int elf_is_64(const void *elf_info)
|
||||
|
||||
static size_t elf_ehdr_size(const void *elf_info)
|
||||
{
|
||||
if (elf_info == NULL)
|
||||
if (!elf_info)
|
||||
return sizeof(Elf64_Ehdr);
|
||||
else if (elf_is_64(elf_info) != 0)
|
||||
return sizeof(Elf64_Ehdr);
|
||||
@@ -183,32 +183,32 @@ static void elf_parse_segment(void *elf_info, const void *elf_phdr,
|
||||
if (elf_is_64(elf_info) == 0) {
|
||||
const Elf32_Phdr *phdr = elf_phdr;
|
||||
|
||||
if (p_type != NULL)
|
||||
if (p_type)
|
||||
*p_type = (unsigned int)phdr->p_type;
|
||||
if (p_offset != NULL)
|
||||
if (p_offset)
|
||||
*p_offset = (size_t)phdr->p_offset;
|
||||
if (p_vaddr != NULL)
|
||||
if (p_vaddr)
|
||||
*p_vaddr = (metal_phys_addr_t)phdr->p_vaddr;
|
||||
if (p_paddr != NULL)
|
||||
if (p_paddr)
|
||||
*p_paddr = (metal_phys_addr_t)phdr->p_paddr;
|
||||
if (p_filesz != NULL)
|
||||
if (p_filesz)
|
||||
*p_filesz = (size_t)phdr->p_filesz;
|
||||
if (p_memsz != NULL)
|
||||
if (p_memsz)
|
||||
*p_memsz = (size_t)phdr->p_memsz;
|
||||
} else {
|
||||
const Elf64_Phdr *phdr = elf_phdr;
|
||||
|
||||
if (p_type != NULL)
|
||||
if (p_type)
|
||||
*p_type = (unsigned int)phdr->p_type;
|
||||
if (p_offset != NULL)
|
||||
if (p_offset)
|
||||
*p_offset = (size_t)phdr->p_offset;
|
||||
if (p_vaddr != NULL)
|
||||
if (p_vaddr)
|
||||
*p_vaddr = (metal_phys_addr_t)phdr->p_vaddr;
|
||||
if (p_paddr != NULL)
|
||||
if (p_paddr)
|
||||
*p_paddr = (metal_phys_addr_t)phdr->p_paddr;
|
||||
if (p_filesz != NULL)
|
||||
if (p_filesz)
|
||||
*p_filesz = (size_t)phdr->p_filesz;
|
||||
if (p_memsz != NULL)
|
||||
if (p_memsz)
|
||||
*p_memsz = (size_t)phdr->p_memsz;
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ static const void *elf_get_segment_from_index(void *elf_info, int index)
|
||||
const Elf32_Ehdr *ehdr = &einfo->ehdr;
|
||||
const Elf32_Phdr *phdrs = einfo->phdrs;
|
||||
|
||||
if (phdrs == NULL)
|
||||
if (!phdrs)
|
||||
return NULL;
|
||||
if (index < 0 || index >= ehdr->e_phnum)
|
||||
return NULL;
|
||||
@@ -230,7 +230,7 @@ static const void *elf_get_segment_from_index(void *elf_info, int index)
|
||||
const Elf64_Ehdr *ehdr = &einfo->ehdr;
|
||||
const Elf64_Phdr *phdrs = einfo->phdrs;
|
||||
|
||||
if (phdrs == NULL)
|
||||
if (!phdrs)
|
||||
return NULL;
|
||||
if (index < 0 || index >= ehdr->e_phnum)
|
||||
return NULL;
|
||||
@@ -249,7 +249,7 @@ static void *elf_get_section_from_name(void *elf_info, const char *name)
|
||||
Elf32_Shdr *shdr = einfo->shdrs;
|
||||
|
||||
name_table = einfo->shstrtab;
|
||||
if (shdr == NULL || name_table == NULL)
|
||||
if (!shdr || !name_table)
|
||||
return NULL;
|
||||
for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
|
||||
if (strcmp(name, name_table + shdr->sh_name))
|
||||
@@ -263,7 +263,7 @@ static void *elf_get_section_from_name(void *elf_info, const char *name)
|
||||
Elf64_Shdr *shdr = einfo->shdrs;
|
||||
|
||||
name_table = einfo->shstrtab;
|
||||
if (shdr == NULL || name_table == NULL)
|
||||
if (!shdr || !name_table)
|
||||
return NULL;
|
||||
for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
|
||||
if (strcmp(name, name_table + shdr->sh_name))
|
||||
@@ -282,7 +282,7 @@ static void *elf_get_section_from_index(void *elf_info, int index)
|
||||
Elf32_Ehdr *ehdr = &einfo->ehdr;
|
||||
Elf32_Shdr *shdr = einfo->shdrs;
|
||||
|
||||
if (shdr == NULL)
|
||||
if (!shdr)
|
||||
return NULL;
|
||||
if (index < 0 || index >= ehdr->e_shnum)
|
||||
return NULL;
|
||||
@@ -292,7 +292,7 @@ static void *elf_get_section_from_index(void *elf_info, int index)
|
||||
Elf64_Ehdr *ehdr = &einfo->ehdr;
|
||||
Elf64_Shdr *shdr = einfo->shdrs;
|
||||
|
||||
if (shdr == NULL)
|
||||
if (!shdr)
|
||||
return NULL;
|
||||
if (index < 0 || index >= ehdr->e_shnum)
|
||||
return NULL;
|
||||
@@ -311,44 +311,44 @@ static void elf_parse_section(void *elf_info, void *elf_shdr,
|
||||
if (elf_is_64(elf_info) == 0) {
|
||||
Elf32_Shdr *shdr = elf_shdr;
|
||||
|
||||
if (sh_type != NULL)
|
||||
if (sh_type)
|
||||
*sh_type = shdr->sh_type;
|
||||
if (sh_flags != NULL)
|
||||
if (sh_flags)
|
||||
*sh_flags = shdr->sh_flags;
|
||||
if (sh_addr != NULL)
|
||||
if (sh_addr)
|
||||
*sh_addr = (metal_phys_addr_t)shdr->sh_addr;
|
||||
if (sh_offset != NULL)
|
||||
if (sh_offset)
|
||||
*sh_offset = shdr->sh_offset;
|
||||
if (sh_size != NULL)
|
||||
if (sh_size)
|
||||
*sh_size = shdr->sh_size;
|
||||
if (sh_link != NULL)
|
||||
if (sh_link)
|
||||
*sh_link = shdr->sh_link;
|
||||
if (sh_info != NULL)
|
||||
if (sh_info)
|
||||
*sh_info = shdr->sh_info;
|
||||
if (sh_addralign != NULL)
|
||||
if (sh_addralign)
|
||||
*sh_addralign = shdr->sh_addralign;
|
||||
if (sh_entsize != NULL)
|
||||
if (sh_entsize)
|
||||
*sh_entsize = shdr->sh_entsize;
|
||||
} else {
|
||||
Elf64_Shdr *shdr = elf_shdr;
|
||||
|
||||
if (sh_type != NULL)
|
||||
if (sh_type)
|
||||
*sh_type = shdr->sh_type;
|
||||
if (sh_flags != NULL)
|
||||
if (sh_flags)
|
||||
*sh_flags = shdr->sh_flags;
|
||||
if (sh_addr != NULL)
|
||||
if (sh_addr)
|
||||
*sh_addr = (metal_phys_addr_t)shdr->sh_addr;
|
||||
if (sh_offset != NULL)
|
||||
if (sh_offset)
|
||||
*sh_offset = shdr->sh_offset;
|
||||
if (sh_size != NULL)
|
||||
if (sh_size)
|
||||
*sh_size = shdr->sh_size;
|
||||
if (sh_link != NULL)
|
||||
if (sh_link)
|
||||
*sh_link = shdr->sh_link;
|
||||
if (sh_info != NULL)
|
||||
if (sh_info)
|
||||
*sh_info = shdr->sh_info;
|
||||
if (sh_addralign != NULL)
|
||||
if (sh_addralign)
|
||||
*sh_addralign = shdr->sh_addralign;
|
||||
if (sh_entsize != NULL)
|
||||
if (sh_entsize)
|
||||
*sh_entsize = shdr->sh_entsize;
|
||||
}
|
||||
}
|
||||
@@ -361,11 +361,11 @@ static const void *elf_next_load_segment(void *elf_info, int *nseg,
|
||||
const void *phdr = PT_NULL;
|
||||
unsigned int p_type = PT_NULL;
|
||||
|
||||
if (elf_info == NULL || nseg == NULL)
|
||||
if (!elf_info || !nseg)
|
||||
return NULL;
|
||||
while (p_type != PT_LOAD) {
|
||||
phdr = elf_get_segment_from_index(elf_info, *nseg);
|
||||
if (phdr == NULL)
|
||||
if (!phdr)
|
||||
return NULL;
|
||||
elf_parse_segment(elf_info, phdr, &p_type, noffset,
|
||||
da, NULL, nfsize, nmsize);
|
||||
@@ -384,7 +384,7 @@ static size_t elf_info_size(const void *img_data)
|
||||
|
||||
int elf_identify(const void *img_data, size_t len)
|
||||
{
|
||||
if (len < SELFMAG || img_data == NULL)
|
||||
if (len < SELFMAG || !img_data)
|
||||
return -RPROC_EINVAL;
|
||||
if (memcmp(img_data, ELFMAG, SELFMAG) != 0)
|
||||
return -RPROC_EINVAL;
|
||||
@@ -398,8 +398,8 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
{
|
||||
int *load_state;
|
||||
|
||||
metal_assert(noffset != NULL);
|
||||
metal_assert(nlen != NULL);
|
||||
metal_assert(noffset);
|
||||
metal_assert(nlen);
|
||||
/* Get ELF header */
|
||||
if (last_load_state == ELF_STATE_INIT) {
|
||||
size_t tmpsize;
|
||||
@@ -413,9 +413,9 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
} else {
|
||||
size_t infosize = elf_info_size(img_data);
|
||||
|
||||
if (*img_info == NULL) {
|
||||
if (!*img_info) {
|
||||
*img_info = metal_allocate_memory(infosize);
|
||||
if (*img_info == NULL)
|
||||
if (!*img_info)
|
||||
return -RPROC_ENOMEM;
|
||||
memset(*img_info, 0, infosize);
|
||||
}
|
||||
@@ -425,7 +425,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
last_load_state = ELF_STATE_WAIT_FOR_PHDRS;
|
||||
}
|
||||
}
|
||||
metal_assert(*img_info != NULL);
|
||||
metal_assert(*img_info);
|
||||
load_state = elf_load_state(*img_info);
|
||||
if (last_load_state != *load_state)
|
||||
return -RPROC_EINVAL;
|
||||
@@ -450,7 +450,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
img_phdrs = (const char *)img_data + phdrs_offset;
|
||||
phdrs = elf_phtable_ptr(*img_info);
|
||||
*phdrs = metal_allocate_memory(phdrs_size);
|
||||
if (*phdrs == NULL)
|
||||
if (!*phdrs)
|
||||
return -RPROC_ENOMEM;
|
||||
memcpy(*phdrs, img_phdrs, phdrs_size);
|
||||
*load_state = ELF_STATE_WAIT_FOR_SHDRS |
|
||||
@@ -483,7 +483,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
img_shdrs = (const char *)img_data + shdrs_offset;
|
||||
shdrs = elf_shtable_ptr(*img_info);
|
||||
*shdrs = metal_allocate_memory(shdrs_size);
|
||||
if (*shdrs == NULL)
|
||||
if (!*shdrs)
|
||||
return -RPROC_ENOMEM;
|
||||
memcpy(*shdrs, img_shdrs, shdrs_size);
|
||||
*load_state = (*load_state & (~ELF_STATE_MASK)) |
|
||||
@@ -502,7 +502,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
metal_log(METAL_LOG_DEBUG, "Loading ELF shstrtab.\r\n");
|
||||
shstrndx = elf_shstrndx(*img_info);
|
||||
shdr = elf_get_section_from_index(*img_info, shstrndx);
|
||||
if (shdr == NULL)
|
||||
if (!shdr)
|
||||
return -RPROC_EINVAL;
|
||||
elf_parse_section(*img_info, shdr, NULL, NULL,
|
||||
NULL, &shstrtab_offset,
|
||||
@@ -518,7 +518,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
|
||||
shstrtab_offset -= offset;
|
||||
shstrtab = elf_shstrtab_ptr(*img_info);
|
||||
*shstrtab = metal_allocate_memory(shstrtab_size);
|
||||
if (*shstrtab == NULL)
|
||||
if (!*shstrtab)
|
||||
return -RPROC_ENOMEM;
|
||||
memcpy(*shstrtab,
|
||||
(const char *)img_data + shstrtab_offset,
|
||||
@@ -542,9 +542,9 @@ int elf_load(struct remoteproc *rproc,
|
||||
const void *phdr;
|
||||
|
||||
(void)rproc;
|
||||
metal_assert(da != NULL);
|
||||
metal_assert(noffset != NULL);
|
||||
metal_assert(nlen != NULL);
|
||||
metal_assert(da);
|
||||
metal_assert(noffset);
|
||||
metal_assert(nlen);
|
||||
if ((last_load_state & RPROC_LOADER_MASK) == RPROC_LOADER_NOT_READY) {
|
||||
metal_log(METAL_LOG_DEBUG,
|
||||
"needs to load header first\r\n");
|
||||
@@ -557,10 +557,10 @@ int elf_load(struct remoteproc *rproc,
|
||||
return last_load_state;
|
||||
}
|
||||
}
|
||||
metal_assert(img_info != NULL && *img_info != NULL);
|
||||
metal_assert(img_info && *img_info);
|
||||
load_state = elf_load_state(*img_info);
|
||||
/* For ELF, segment padding value is 0 */
|
||||
if (padding != NULL)
|
||||
if (padding)
|
||||
*padding = 0;
|
||||
if ((*load_state & RPROC_LOADER_READY_TO_LOAD) != 0) {
|
||||
int nsegment;
|
||||
@@ -571,7 +571,7 @@ int elf_load(struct remoteproc *rproc,
|
||||
nsegment = *load_state & ELF_NEXT_SEGMENT_MASK;
|
||||
phdr = elf_next_load_segment(*img_info, &nsegment, da,
|
||||
noffset, &nsize, &nsegmsize);
|
||||
if (phdr == NULL) {
|
||||
if (!phdr) {
|
||||
metal_log(METAL_LOG_DEBUG, "cannot find more segment\r\n");
|
||||
*load_state = (*load_state & (~ELF_NEXT_SEGMENT_MASK)) |
|
||||
(nsegment & ELF_NEXT_SEGMENT_MASK);
|
||||
@@ -616,27 +616,27 @@ int elf_load(struct remoteproc *rproc,
|
||||
|
||||
void elf_release(void *img_info)
|
||||
{
|
||||
if (img_info == NULL)
|
||||
if (!img_info)
|
||||
return;
|
||||
if (elf_is_64(img_info) == 0) {
|
||||
struct elf32_info *elf_info = img_info;
|
||||
|
||||
if (elf_info->phdrs != NULL)
|
||||
if (elf_info->phdrs)
|
||||
metal_free_memory(elf_info->phdrs);
|
||||
if (elf_info->shdrs != NULL)
|
||||
if (elf_info->shdrs)
|
||||
metal_free_memory(elf_info->shdrs);
|
||||
if (elf_info->shstrtab != NULL)
|
||||
if (elf_info->shstrtab)
|
||||
metal_free_memory(elf_info->shstrtab);
|
||||
metal_free_memory(img_info);
|
||||
|
||||
} else {
|
||||
struct elf64_info *elf_info = img_info;
|
||||
|
||||
if (elf_info->phdrs != NULL)
|
||||
if (elf_info->phdrs)
|
||||
metal_free_memory(elf_info->phdrs);
|
||||
if (elf_info->shdrs != NULL)
|
||||
if (elf_info->shdrs)
|
||||
metal_free_memory(elf_info->shdrs);
|
||||
if (elf_info->shstrtab != NULL)
|
||||
if (elf_info->shstrtab)
|
||||
metal_free_memory(elf_info->shstrtab);
|
||||
metal_free_memory(img_info);
|
||||
}
|
||||
@@ -669,15 +669,15 @@ int elf_locate_rsc_table(void *elf_info, metal_phys_addr_t *da,
|
||||
void *shdr;
|
||||
int *load_state;
|
||||
|
||||
if (elf_info == NULL)
|
||||
if (!elf_info)
|
||||
return -RPROC_EINVAL;
|
||||
|
||||
load_state = elf_load_state(elf_info);
|
||||
if ((*load_state & ELF_STATE_HDRS_COMPLETE) == 0)
|
||||
return -RPROC_ERR_LOADER_STATE;
|
||||
shdr = elf_get_section_from_name(elf_info, sect_name);
|
||||
if (shdr == NULL) {
|
||||
metal_assert(size != NULL);
|
||||
if (!shdr) {
|
||||
metal_assert(size);
|
||||
*size = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -691,7 +691,7 @@ int elf_get_load_state(void *img_info)
|
||||
{
|
||||
int *load_state;
|
||||
|
||||
if (img_info == NULL)
|
||||
if (!img_info)
|
||||
return -RPROC_EINVAL;
|
||||
load_state = elf_load_state(img_info);
|
||||
return *load_state;
|
||||
|
||||
@@ -112,7 +112,7 @@ static void *remoteproc_get_rsc_table(struct remoteproc *rproc,
|
||||
}
|
||||
ret = store_ops->load(store, offset, len, &img_data, RPROC_LOAD_ANYADDR,
|
||||
NULL, 1);
|
||||
if (ret < 0 || ret < (int)len || img_data == NULL) {
|
||||
if (ret < 0 || ret < (int)len || !img_data) {
|
||||
metal_log(METAL_LOG_ERROR,
|
||||
"get rsc failed: 0x%llx, 0x%llx\r\n", offset, len);
|
||||
rsc_table = RPROC_ERR_PTR(-RPROC_EINVAL);
|
||||
@@ -427,7 +427,7 @@ int remoteproc_load(struct remoteproc *rproc, const char *path,
|
||||
return -RPROC_EINVAL;
|
||||
}
|
||||
len = ret;
|
||||
metal_assert(img_data != NULL);
|
||||
metal_assert(img_data);
|
||||
|
||||
/* Check executable format to select a parser */
|
||||
loader = rproc->loader;
|
||||
@@ -529,8 +529,9 @@ int remoteproc_load(struct remoteproc *rproc, const char *path,
|
||||
img_data = NULL;
|
||||
/* get the I/O region from remoteproc */
|
||||
pa = METAL_BAD_PHYS;
|
||||
(void)remoteproc_mmap(rproc, &pa, &da, nmemsize, 0, &io);
|
||||
if (pa == METAL_BAD_PHYS || io == NULL) {
|
||||
(void)remoteproc_mmap(rproc, &pa, &da, nmemsize, 0,
|
||||
&io);
|
||||
if (pa == METAL_BAD_PHYS || !io) {
|
||||
metal_log(METAL_LOG_ERROR,
|
||||
"load failed, no mapping for 0x%llx.\r\n",
|
||||
da);
|
||||
@@ -667,12 +668,12 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
if (!rproc)
|
||||
return -RPROC_ENODEV;
|
||||
|
||||
metal_assert(pa != NULL);
|
||||
metal_assert(io != NULL);
|
||||
metal_assert(noffset != NULL);
|
||||
metal_assert(nlen != NULL);
|
||||
metal_assert(nmlen != NULL);
|
||||
metal_assert(padding != NULL);
|
||||
metal_assert(pa);
|
||||
metal_assert(io);
|
||||
metal_assert(noffset);
|
||||
metal_assert(nlen);
|
||||
metal_assert(nmlen);
|
||||
metal_assert(padding);
|
||||
|
||||
metal_mutex_acquire(&rproc->lock);
|
||||
metal_log(METAL_LOG_DEBUG, "%s: check remoteproc status\r\n", __func__);
|
||||
@@ -689,7 +690,7 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
loader = rproc->loader;
|
||||
if (!loader) {
|
||||
metal_log(METAL_LOG_DEBUG, "%s: check loader\r\n", __func__);
|
||||
if (img_data == NULL || offset != 0 || len == 0) {
|
||||
if (!img_data || offset != 0 || len == 0) {
|
||||
metal_log(METAL_LOG_ERROR,
|
||||
"load failure, invalid inputs, not able to identify image.\r\n");
|
||||
metal_mutex_release(&rproc->lock);
|
||||
@@ -704,7 +705,7 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
}
|
||||
rproc->loader = loader;
|
||||
}
|
||||
if (img_info == NULL || *img_info == NULL) {
|
||||
if (!img_info || !*img_info) {
|
||||
last_load_state = 0;
|
||||
} else {
|
||||
limg_info = *img_info;
|
||||
@@ -760,7 +761,7 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
/* get the I/O region from remoteproc */
|
||||
*pa = METAL_BAD_PHYS;
|
||||
(void)remoteproc_mmap(rproc, pa, &da, *nmlen, 0, io);
|
||||
if (*pa == METAL_BAD_PHYS || io == NULL) {
|
||||
if (*pa == METAL_BAD_PHYS || !io) {
|
||||
metal_log(METAL_LOG_ERROR,
|
||||
"load failed, no mapping for 0x%llx.\r\n",
|
||||
da);
|
||||
@@ -780,13 +781,13 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
&rsc_offset, &rsc_size);
|
||||
if (ret == 0 && rsc_size > 0) {
|
||||
lrsc_table = metal_allocate_memory(rsc_size);
|
||||
if (lrsc_table == NULL) {
|
||||
if (!lrsc_table) {
|
||||
ret = -RPROC_ENOMEM;
|
||||
goto error1;
|
||||
}
|
||||
rsc_table = remoteproc_mmap(rproc, NULL, &rsc_da,
|
||||
rsc_size, 0, io);
|
||||
if (*io == NULL) {
|
||||
if (!*io) {
|
||||
metal_log(METAL_LOG_ERROR,
|
||||
"load failed: failed to mmap rsc\r\n");
|
||||
metal_free_memory(lrsc_table);
|
||||
@@ -826,7 +827,7 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
|
||||
rproc->bootaddr = loader->get_entry(limg_info);
|
||||
}
|
||||
out:
|
||||
if (img_info != NULL)
|
||||
if (img_info)
|
||||
*img_info = limg_info;
|
||||
else
|
||||
loader->release(limg_info);
|
||||
|
||||
@@ -143,7 +143,7 @@ static void *rpmsg_virtio_get_tx_buffer(struct rpmsg_virtio_device *rvdev,
|
||||
#ifndef VIRTIO_SLAVE_ONLY
|
||||
if (role == RPMSG_MASTER) {
|
||||
data = virtqueue_get_buffer(rvdev->svq, len, idx);
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
data = rpmsg_virtio_shm_pool_get_buffer(rvdev->shpool,
|
||||
RPMSG_BUFFER_SIZE);
|
||||
*len = RPMSG_BUFFER_SIZE;
|
||||
@@ -422,7 +422,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
|
||||
rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
|
||||
|
||||
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
|
||||
if (rp_hdr == NULL) {
|
||||
if (!rp_hdr) {
|
||||
/* tell peer we return some rx buffer */
|
||||
virtqueue_kick(rvdev->rvq);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ const char *virtio_dev_name(unsigned short devid)
|
||||
{
|
||||
const struct virtio_ident *ident;
|
||||
|
||||
for (ident = virtio_ident_table; ident->name != NULL; ident++) {
|
||||
for (ident = virtio_ident_table; ident->name; ident++) {
|
||||
if (ident->devid == devid)
|
||||
return ident->name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user