Skip to content

Commit

Permalink
Fix build errors pointed by CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Jan 1, 2020
1 parent 0ee9ff7 commit 44aff71
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 54 deletions.
4 changes: 2 additions & 2 deletions include/lib/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <types.h>

void *memcpy (void *__restrict, const void *__restrict, size_t);
void *memset (void *, int, size_t);
void *memcpy(void *__restrict, const void *__restrict, size_t);
void *memset(void *, int, size_t);
int strcmp(const char *l, const char *r);

#endif /* LIB_STRING_H_ */
6 changes: 3 additions & 3 deletions kernel/fpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DECLARE_KTABLE(fpage_t, fpage_table, CONFIG_MAX_FPAGES);
} \
else { \
while (!end && fpprev->next != (fpage)) { \
if (fpprev->next == NULL) \
if (!fpprev->next) \
end = 1; \
fpprev = fpprev->next; \
} \
Expand Down Expand Up @@ -74,7 +74,7 @@ static void insert_fpage_chain_to_as(as_t *as, fpage_t *first, fpage_t *last)
as->first = first;
} else {
/* Search for chain in the middle */
while (fp->as_next != NULL) {
while (fp->as_next) {
if (FPAGE_BASE(last) < FPAGE_BASE(fp->as_next)) {
last->as_next = fp->as_next;
break;
Expand Down Expand Up @@ -121,7 +121,7 @@ static fpage_t *create_fpage(memptr_t base, size_t shift, int mpid)
{
fpage_t *fpage = (fpage_t *) ktable_alloc(&fpage_table);

assert(fpage != NULL);
assert((intptr_t) fpage);

fpage->as_next = NULL;
fpage->map_next = fpage; /* That is first fpage in mapping */
Expand Down
28 changes: 14 additions & 14 deletions kernel/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static struct user_irq_queue user_irq_queue;

static int user_irq_queue_is_empty(void)
{
return (user_irq_queue.head == NULL);
return (!user_irq_queue.head);
}

static void user_irq_queue_push(struct user_irq *uirq)
Expand Down Expand Up @@ -87,7 +87,7 @@ static struct user_irq *user_irq_queue_pop(void)
static void user_irq_queue_delete(int irq)
{
struct user_irq *uirq = user_irqs[irq];
for (struct user_irq **iter = &user_irq_queue.head ; *iter != NULL ;
for (struct user_irq **iter = &user_irq_queue.head ; *iter;
iter = &(*iter)->next) {
if (*iter == uirq) {
*iter = uirq->next;
Expand Down Expand Up @@ -130,7 +130,7 @@ static void user_irq_release(int irq)
if (IS_VALID_IRQ_NUM(irq)) {
struct user_irq *uirq = user_irqs[irq];

if (uirq != NULL) {
if (uirq) {
ktable_free(&user_irq_table, uirq);
user_irqs[irq] = NULL;
}
Expand All @@ -139,7 +139,7 @@ static void user_irq_release(int irq)

static void irq_handler_ipc(struct user_irq *uirq)
{
if (uirq == NULL || uirq->thr == NULL)
if (!uirq| !uirq->thr)
return;

/* Prepare ipc for user interrupt thread */
Expand All @@ -161,9 +161,9 @@ static int irq_handler_enable(int irq)
{
struct user_irq *uirq = user_irqs[irq];

assert(uirq != NULL);
assert((intptr_t) uirq);

if (uirq->thr == NULL)
if (!uirq->thr)
return -1;

tcb_t *thr = uirq->thr;
Expand Down Expand Up @@ -198,7 +198,7 @@ static tcb_t *irq_handler_sched(struct sched_slot *slot)
irq_disable();
struct user_irq *uirq = user_irq_queue_pop();

if (uirq != NULL && (thr = uirq->thr) != NULL &&
if (uirq && (thr = uirq->thr) &&
thr->state == T_RECV_BLOCKED) {
thr->state = T_RUNNABLE;
sched_slot_dispatch(SSI_INTR_THREAD, thr);
Expand All @@ -213,9 +213,9 @@ void __interrupt_handler(int irq)
{
struct user_irq *uirq = user_irq_fetch(irq);

if (uirq == NULL ||
uirq->thr == NULL ||
uirq->handler == NULL ||
if (!uirq ||
!uirq->thr ||
!uirq->handler ||
uirq->action != USER_IRQ_ENABLE) {
return;
}
Expand Down Expand Up @@ -252,7 +252,7 @@ void user_interrupt_config(tcb_t *from)

struct user_irq *uirq = user_irq_fetch(irq);

if (uirq == NULL)
if (!uirq)
return;

/* update user irq config */
Expand All @@ -261,7 +261,7 @@ void user_interrupt_config(tcb_t *from)

uirq->action = (uint16_t) action;

if (handler != NULL)
if (handler)
uirq->handler = handler;

if (priority > 0)
Expand All @@ -270,12 +270,12 @@ void user_interrupt_config(tcb_t *from)

void user_interrupt_handler_update(tcb_t *thr)
{
if (thr == NULL)
if (!thr)
return;

for (int irq = 0 ; irq < IRQn_NUM ; irq++) {
struct user_irq *uirq = user_irq_fetch(irq);
if (uirq == NULL)
if (!uirq)
continue;

if (uirq->thr == thr) {
Expand Down
12 changes: 6 additions & 6 deletions kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INIT_HOOK(kprobe_init, INIT_LEVEL_KERNEL);
struct kprobe *kplist_search(void *addr)
{
struct kprobe *cur = kp_list;
while (cur != NULL) {
while (cur) {
if (cur->addr == addr)
return cur;
cur = cur->next;
Expand All @@ -43,7 +43,7 @@ void kplist_del(struct kprobe *kp)
kp_list = kp->next;
return;
}
while (cur != NULL) {
while (cur) {
if (cur->next == kp) {
cur->next = kp->next;
break;
Expand Down Expand Up @@ -118,7 +118,7 @@ int kretprobe_unregister(struct kretprobe *rp)
void kprobe_prebreak(uint32_t *stack, uint32_t *kp_regs)
{
struct kprobe *kp = kp_list;
while (kp != NULL) {
while (kp) {
if ((uint32_t) kp->addr == stack[REG_PC] && kp->pre_handler)
kp->pre_handler(kp, stack, kp_regs);
kp = kp->next;
Expand All @@ -128,7 +128,7 @@ void kprobe_prebreak(uint32_t *stack, uint32_t *kp_regs)
void kprobe_postbreak(uint32_t *stack, uint32_t *kp_regs)
{
struct kprobe *kp = kp_list;
while (kp != NULL) {
while (kp) {
if ((uint32_t) kp->step_addr == stack[REG_PC] &&
kp->post_handler)
kp->post_handler(kp, stack, kp_regs);
Expand All @@ -139,7 +139,7 @@ void kprobe_postbreak(uint32_t *stack, uint32_t *kp_regs)
void kprobe_breakpoint_enable(uint32_t *stack)
{
struct kprobe *kp = kp_list;
while (kp != NULL) {
while (kp) {
if ((uint32_t) kp->step_addr == stack[REG_PC])
enable_breakpoint(kp->bkpt);
kp = kp->next;
Expand All @@ -149,7 +149,7 @@ void kprobe_breakpoint_enable(uint32_t *stack)
void kprobe_breakpoint_disable(uint32_t *stack)
{
struct kprobe *kp = kp_list;
while (kp != NULL) {
while (kp) {
if ((uint32_t) kp->addr == stack[REG_PC])
disable_breakpoint(kp->bkpt);
kp = kp->next;
Expand Down
2 changes: 1 addition & 1 deletion kernel/ksym.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int ksym_lookup(void *addr)
sizeof(__ksym_tbl[0]), cmp_key);
}

if (found == NULL)
if (!found)
return -1;
return prev_index = (found - __ksym_tbl);
}
Expand Down
4 changes: 2 additions & 2 deletions kernel/ktimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int ktimer_event_schedule(uint32_t ticks, ktimer_event_t *kte)
ticks -= ktimer_time;
kte->next = NULL;

if (event_queue == NULL) {
if (!event_queue) {
/* All other events are already handled, so simply schedule
* and enable timer
*/
Expand Down Expand Up @@ -222,7 +222,7 @@ ktimer_event_t *ktimer_event_create(uint32_t ticks,
kte = (ktimer_event_t *) ktable_alloc(&ktimer_event_table);

/* No available slots */
if (kte == NULL)
if (!kte)
goto ret;

kte->next = NULL;
Expand Down
10 changes: 5 additions & 5 deletions kernel/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void as_setup_mpu(as_t *as, memptr_t sp, memptr_t pc,
/* Find stack fpages */
fp = as->first;
i = 0;
while (i < 8 && fp != NULL && start < end) {
while (i < 8 && fp && start < end) {
if (addr_in_fpage(start, fp, 0)) {
if (!mpu_stack_first)
mpu_stack_first = fp;
Expand All @@ -219,12 +219,12 @@ void as_setup_mpu(as_t *as, memptr_t sp, memptr_t pc,
* mpu_fp[2] are others
*/
fp = as->mpu_first;
if (fp == NULL) {
if (!fp) {
fpage_t *mpu_first[3] = {NULL};
fpage_t *mpu_fp[3] = {NULL};

fp = as->first;
while (fp != NULL) {
while (fp) {
int priv = 2;

if (addr_in_fpage(pc, fp, 0)) {
Expand All @@ -233,7 +233,7 @@ void as_setup_mpu(as_t *as, memptr_t sp, memptr_t pc,
priv = 1;
}

if (mpu_first[priv] == NULL) {
if (!mpu_first[priv]) {
mpu_first[priv] = fp;
mpu_fp[priv] = fp;
} else {
Expand All @@ -258,7 +258,7 @@ void as_setup_mpu(as_t *as, memptr_t sp, memptr_t pc,
}

/* Prevent link to stack pages */
for (fp = as->mpu_first; i < 8 && fp != NULL; fp = fp->mpu_next) {
for (fp = as->mpu_first; i < 8 && fp; fp = fp->mpu_next) {
for (j = 0; j < mpu_first_i; j++) {
if (fp == mpu[j]) {
break;
Expand Down
14 changes: 7 additions & 7 deletions kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ tcb_t *thread_create(l4_thread_t globalid, utcb_t *utcb)
{
int id = GLOBALID_TO_TID(globalid);

assert(caller != NULL);
assert((intptr_t) caller);

if (id < THREAD_SYS ||
globalid == L4_ANYTHREAD ||
Expand Down Expand Up @@ -320,7 +320,7 @@ void thread_init_ctx(void *sp, void *pc, void *regs, tcb_t *thr)
thr->ctx.ctl = 0x0;
}

if (regs == NULL) {
if (!regs) {
((uint32_t *) sp)[REG_R0] = 0x0;
((uint32_t *) sp)[REG_R1] = 0x0;
((uint32_t *) sp)[REG_R2] = 0x0;
Expand Down Expand Up @@ -384,7 +384,7 @@ int thread_ispriviliged(tcb_t *thread)
/* Switch context */
void thread_switch(tcb_t *thr)
{
assert(thr != NULL);
assert((intptr_t) thr);
assert(thread_isrunnable(thr));

current = thr;
Expand All @@ -402,19 +402,19 @@ void thread_switch(tcb_t *thr)
static tcb_t *thread_select(tcb_t *parent)
{
tcb_t *thr = parent->t_child;
if (thr == NULL)
if (!thr)
return NULL;

while (1) {
if (thread_isrunnable(thr))
return thr;

if (thr->t_child != NULL) {
if (thr->t_child) {
thr = thr->t_child;
continue;
}

if (thr->t_sibling != NULL) {
if (thr->t_sibling) {
thr = thr->t_sibling;
continue;
}
Expand All @@ -423,7 +423,7 @@ static tcb_t *thread_select(tcb_t *parent)
if (thr->t_parent == parent)
return NULL;
thr = thr->t_parent;
} while (thr->t_sibling == NULL);
} while (!thr->t_sibling);

thr = thr->t_sibling;
}
Expand Down
2 changes: 1 addition & 1 deletion loader/elf/elf32.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ char *elf32_getSectionName(struct Elf32_Header *elfFile, int i)
{
struct Elf32_Shdr *sections = elf32_getSectionTable(elfFile);
char *str_table = elf32_getSegmentStringTable(elfFile);
if (str_table == NULL) {
if (!str_table) {
return "<corrupted>";
} else {
return str_table + sections[i].sh_name;
Expand Down
1 change: 1 addition & 0 deletions mk/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CFLAGS_WARN = \
-Wall -Werror -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration -Wno-format-security \
-Wno-error=maybe-uninitialized \
-fno-delete-null-pointer-checks -Wno-pointer-sign \
-fno-strict-overflow -fconserve-stack
CFLAGS_OPT = \
Expand Down
6 changes: 3 additions & 3 deletions platform/kprobes-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ int kprobe_arch_add(struct kprobe *kp)
* otherwise share the existing bkpt.
*/

if (found == NULL) {
if (!found) {
b = breakpoint_install((uint32_t) kp->addr);
if (b != NULL) {
if (b) {
kp->bkpt = b;
enable_breakpoint(b);
} else
Expand All @@ -50,7 +50,7 @@ int kprobe_arch_del(struct kprobe *kp)
struct kprobe *found = kplist_search(kp->addr);

/* Free bkpt when there is no kprobe at this addr */
if (found == NULL)
if (!found)
breakpoint_uninstall(kp->bkpt);
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions platform/stm32-common/mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int mpu_select_lru(as_t *as, uint32_t addr)
int i;

/* Kernel fault? */
if (as == NULL)
if (!as)
return 1;

if (addr_in_mpu(addr))
Expand All @@ -81,15 +81,15 @@ int mpu_select_lru(as_t *as, uint32_t addr)

/* Get first avalible MPU index */
i = 0;
while (sfp != NULL) {
while (sfp) {
++i;
sfp = sfp->mpu_next;
}

/* Update MPU */
mpu_setup_region(i++, fp);

while (i < 8 && fp->mpu_next != NULL) {
while (i < 8 && fp->mpu_next) {
mpu_setup_region(i++, fp->mpu_next);
fp = fp->mpu_next;
}
Expand Down
2 changes: 1 addition & 1 deletion user/apps/l4test/l4test.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ L4_INLINE bool l4_has_feature( const char *feature_name )
void *kip = L4_GetKernelInterface();
char *name;

for (L4_Word_t i = 0; (name = L4_Feature(kip,i)) != '\0'; i++)
for (L4_Word_t i = 0; (name = L4_Feature(kip,i)); i++)
if (!strcmp(feature_name, name))
return true;
return false;
Expand Down
Loading

0 comments on commit 44aff71

Please sign in to comment.