Skip to content

Commit

Permalink
checkpatch
Browse files Browse the repository at this point in the history
  • Loading branch information
henryZe committed Aug 15, 2022
1 parent d11fa03 commit 2672f5e
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 137 deletions.
2 changes: 0 additions & 2 deletions boot/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#
# boot/Makefile
#
# Copyright (C) 2018 Henry.Zeng <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 0 additions & 2 deletions boot/sign.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#
# boot/sign.py
#
# Copyright (C) 2018 Henry.Zeng <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
Expand Down
20 changes: 12 additions & 8 deletions checkpatch.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
./scripts/checkpatch.pl -f -q --no-tree include/*.[cSh] \
include/*/*.[cSh] \
include/arch/*/*.[cSh] \
boot/*.[cSh] \
kernel/*.[cSh] \
lib/*.[cSh] \
user/*.[cSh]
fs/*.[cSh] \
./scripts/checkpatch.pl -f -q --no-tree include/*.h \
include/*/*.h \
include/arch/i386/*.h \
boot/* \
kernel/* \
lib/* \
user/* \
fs/* \

./scripts/checkpatch.pl -f -q --no-tree Makefile \

./scripts/checkpatch.pl -f -q --no-tree net/Makefile \
net/*.[cSh] \
2 changes: 1 addition & 1 deletion fs/fs.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <lib.h>
#include <fs/fs.h>

#define BLKNO2ADDR(x) (void *)(DISKMAP + x * BLKSIZE)
#define BLKNO2ADDR(x) ((void *)(DISKMAP + x * BLKSIZE))

// --------------------------------------------------------------
// Super block
Expand Down
2 changes: 1 addition & 1 deletion fs/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fs_test(void)
panic("file_get_block returned wrong data");
cprintf("file_get_block is good\n");

*(volatile char*)blk = *(volatile char*)blk;
*(volatile char *)blk = *(volatile char *)blk;
assert((uvpt[PGNUM(blk)] & PTE_D));
file_flush(f);
assert(!(uvpt[PGNUM(blk)] & PTE_D));
Expand Down
8 changes: 4 additions & 4 deletions include/boot/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct segdesc {

// Normal segment
#define SEG(type, base, lim, dpl) \
(struct segdesc) { \
((struct segdesc) { \
((lim) >> 12) & 0xffff, \
(uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, \
Expand All @@ -90,9 +90,9 @@ struct segdesc {
1, \
1, \
(uint)(base) >> 24, \
}
})
#define SEG16(type, base, lim, dpl) \
(struct segdesc) { \
((struct segdesc) { \
(lim) & 0xffff, \
(uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, \
Expand All @@ -106,7 +106,7 @@ struct segdesc {
1, \
0, \
(uint)(base) >> 24, \
}
})
#endif

#define DPL_USER 0x3 // User DPL
Expand Down
4 changes: 2 additions & 2 deletions include/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct Segdesc {
}

#define SEG16(type, base, lim, dpl) \
(struct Segdesc) { \
((struct Segdesc) { \
(lim) & 0xffff, \
(base) & 0xffff, \
((base) >> 16) & 0xff, \
Expand All @@ -208,7 +208,7 @@ struct Segdesc {
1, \
0, \
(unsigned int) (base) >> 24, \
}
})

#endif /* !__ASSEMBLER__ */

Expand Down
7 changes: 3 additions & 4 deletions net/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ input(envid_t ns_envid)
if (ret == -E_IPC_NOT_RECV)
sys_yield();
else
panic("input: sys_ipc_try_send failed\n");
panic("%s: sys_ipc_try_send failed\n", __func__);
} else {
/*
* Actually we don't need to unmap nsipcbuf,
/* Actually we don't need to unmap nsipcbuf,
* because it will be remapped in next routine.
*/
sys_page_unmap(0, &nsipcbuf);
break;
}
}
}
}
}
6 changes: 3 additions & 3 deletions net/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ output(envid_t ns_envid)
int ret;

while (1) {
// - read a packet from the network server
// - read a packet from the network server
ret = sys_ipc_recv(&nsipcbuf);
if (ret)
continue;

if (thisenv->env_ipc_from != ns_envid ||
thisenv->env_ipc_value != NSREQ_OUTPUT)
thisenv->env_ipc_value != NSREQ_OUTPUT)
continue;

// - send the packet to the device driver
ret = sys_tx_pkt((const uint8_t *)nsipcbuf.pkt.jp_data, nsipcbuf.pkt.jp_len);
if (ret)
panic("Output ENV fail to transmit packets");
}
}
}
43 changes: 22 additions & 21 deletions net/serv.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define debug 0

int errno = 0;
int errno;

struct timer_thread {
uint32_t msec;
Expand Down Expand Up @@ -52,18 +52,17 @@ tcpip_init_done(void *arg)

static void
lwip_init(struct netif *nif, void *if_state,
uint32_t init_addr, uint32_t init_mask, uint32_t init_gw)
uint32_t init_addr, uint32_t init_mask, uint32_t init_gw)
{
struct ip_addr ipaddr, netmask, gateway;

ipaddr.addr = init_addr;
netmask.addr = init_mask;
gateway.addr = init_gw;

if (0 == netif_add(nif, &ipaddr, &netmask, &gateway,
if_state,
jif_init,
ip_input))
panic("lwip_init: error in netif_add\n");
if (netif_add(nif, &ipaddr, &netmask, &gateway,
if_state, jif_init, ip_input) == 0)
panic("%s: error in netif_add\n", __func__);

netif_set_default(nif);
netif_set_up(nif);
Expand Down Expand Up @@ -105,6 +104,7 @@ serve_init(uint32_t ipaddr, uint32_t netmask, uint32_t gw)
lwip_core_lock();

uint32_t done = 0;

tcpip_init(&tcpip_init_done, &done);
lwip_core_unlock();
thread_wait(&done, 0, (uint32_t)~0);
Expand All @@ -117,8 +117,8 @@ serve_init(uint32_t ipaddr, uint32_t netmask, uint32_t gw)
start_timer(&t_tcps, &tcp_slowtmr, "tcp s timer", TCP_SLOW_INTERVAL);

struct in_addr ia = {ipaddr};
cprintf("ns: %02x:%02x:%02x:%02x:%02x:%02x"
" bound to static IP %s\n",

cprintf("ns: %02x:%02x:%02x:%02x:%02x:%02x bound to static IP %s\n",
nif.hwaddr[0], nif.hwaddr[1], nif.hwaddr[2],
nif.hwaddr[3], nif.hwaddr[4], nif.hwaddr[5],
inet_ntoa(ia));
Expand Down Expand Up @@ -153,6 +153,7 @@ static void
put_buffer(void *va)
{
int i = ((uint32_t)va - REQVA) / PGSIZE;

buse[i] = 0;
}

Expand All @@ -162,16 +163,15 @@ process_timer(envid_t envid)
uint32_t start, now, to;

if (envid != timer_envid) {
cprintf("NS: received timer interrupt from envid %x"
" not timer env\n", envid);
cprintf("NS: received timer interrupt from envid %x not timer env\n", envid);
return;
}

start = sys_time_msec();
thread_yield();
now = sys_time_msec();

to = TIMER_INTERVAL - (now -start);
to = TIMER_INTERVAL - (now - start);
ipc_send(envid, to, NULL, 0);
}

Expand Down Expand Up @@ -217,7 +217,7 @@ serve_thread(uint32_t a)
// Note that we read the request fields before we
// overwrite it with the response data.
r = lwip_recv(req->recv.req_s, req->recvRet.ret_buf,
req->recv.req_len, req->recv.req_flags);
req->recv.req_len, req->recv.req_flags);
break;

case NSREQ_SEND:
Expand All @@ -243,6 +243,7 @@ serve_thread(uint32_t a)

if (r < 0) {
char buf[100];

snprintf(buf, sizeof(buf), "ns req type %d", args->reqno);
perror(buf);
}
Expand Down Expand Up @@ -292,6 +293,7 @@ serve(void)
// Since some lwIP socket calls will block, create a thread and
// process the rest of the request in the thread.
struct st_args *args = malloc(sizeof(struct st_args));

if (!args)
panic("could not allocate thread args structure");

Expand All @@ -302,7 +304,6 @@ serve(void)
thread_create(NULL, "serve_thread", serve_thread, (uint32_t)args);
thread_yield(); // let the thread created run
}

}

static void
Expand All @@ -321,28 +322,28 @@ umain(int argc, char **argv)

// fork off the timer thread which will send us periodic messages
timer_envid = fork();
if (timer_envid < 0)
if (timer_envid < 0) {
panic("error forking");
else if (timer_envid == 0) {
} else if (timer_envid == 0) {
/* as the timer of thread scheduler */
timer(ns_envid, TIMER_INTERVAL);
return;
}

// fork off the input thread which will poll the NIC driver for input packets
input_envid = fork();
if (input_envid < 0)
if (input_envid < 0) {
panic("error forking");
else if (input_envid == 0) {
} else if (input_envid == 0) {
input(ns_envid);
return;
}

// fork off the output thread that will send the packets to the NIC driver
output_envid = fork();
if (output_envid < 0)
if (output_envid < 0) {
panic("error forking");
else if (output_envid == 0) {
} else if (output_envid == 0) {
output(ns_envid);
return;
}
Expand All @@ -353,4 +354,4 @@ umain(int argc, char **argv)
thread_create(NULL, "main", tmain, 0);
thread_yield();
// never coming here!
}
}
Loading

0 comments on commit 2672f5e

Please sign in to comment.