summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-28 18:32:08 +0000
committerrsc <rsc>2007-08-28 18:32:08 +0000
commite4d6a21165c01dd743a68e323fb06708ef820ab7 (patch)
tree3088155cccccdfbed6348199021907587cee15b3
parentc1b100e93044469de30c634107bc645361cc1a73 (diff)
downloadxv6-labs-e4d6a21165c01dd743a68e323fb06708ef820ab7.tar.gz
xv6-labs-e4d6a21165c01dd743a68e323fb06708ef820ab7.tar.bz2
xv6-labs-e4d6a21165c01dd743a68e323fb06708ef820ab7.zip
more consistent spacing
-rw-r--r--cat.c2
-rw-r--r--console.c6
-rw-r--r--fs.c36
-rw-r--r--kbd.c8
-rw-r--r--mkdir.c2
-rw-r--r--mp.c2
-rw-r--r--pipe.c2
-rw-r--r--printf.c20
-rw-r--r--proc.c6
-rw-r--r--rm.c2
-rw-r--r--sh.c2
-rw-r--r--string.c6
-rw-r--r--syscall.c2
-rw-r--r--sysfile.c2
-rw-r--r--trap.c2
-rw-r--r--umalloc.c16
-rw-r--r--wc.c2
17 files changed, 59 insertions, 59 deletions
diff --git a/cat.c b/cat.c
index eb8153a..2b2dcc7 100644
--- a/cat.c
+++ b/cat.c
@@ -22,7 +22,7 @@ main(int argc, char *argv[])
{
int fd, i;
- if(argc <= 1) {
+ if(argc <= 1){
cat(0);
exit();
}
diff --git a/console.c b/console.c
index d849860..8acc242 100644
--- a/console.c
+++ b/console.c
@@ -91,13 +91,13 @@ printint(int xx, int base, int sgn)
if(sgn && xx < 0){
neg = 1;
x = 0 - xx;
- } else {
+ }else{
x = xx;
}
- do {
+ do{
buf[i++] = digits[x % base];
- } while((x /= base) != 0);
+ }while((x /= base) != 0);
if(neg)
buf[i++] = '-';
diff --git a/fs.c b/fs.c
index 732b721..3521881 100644
--- a/fs.c
+++ b/fs.c
@@ -237,7 +237,7 @@ void
iput(struct inode *ip)
{
acquire(&icache.lock);
- if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0) {
+ if(ip->ref == 1 && (ip->flags & I_VALID) && ip->nlink == 0){
// inode is no longer used: truncate and free inode.
if(ip->flags & I_BUSY)
panic("iput busy");
@@ -273,10 +273,10 @@ ialloc(uint dev, short type)
struct superblock sb;
readsb(dev, &sb);
- for(inum = 1; inum < sb.ninodes; inum++) { // loop over inode blocks
+ for(inum = 1; inum < sb.ninodes; inum++){ // loop over inode blocks
bp = bread(dev, IBLOCK(inum));
dip = (struct dinode*)bp->data + inum%IPB;
- if(dip->type == 0) { // a free inode
+ if(dip->type == 0){ // a free inode
memset(dip, 0, sizeof(*dip));
dip->type = type;
bwrite(bp); // mark it allocated on the disk
@@ -323,8 +323,8 @@ bmap(struct inode *ip, uint bn, int alloc)
uint addr, *a;
struct buf *bp;
- if(bn < NDIRECT) {
- if((addr = ip->addrs[bn]) == 0) {
+ if(bn < NDIRECT){
+ if((addr = ip->addrs[bn]) == 0){
if(!alloc)
return -1;
ip->addrs[bn] = addr = balloc(ip->dev);
@@ -333,9 +333,9 @@ bmap(struct inode *ip, uint bn, int alloc)
}
bn -= NDIRECT;
- if(bn < NINDIRECT) {
+ if(bn < NINDIRECT){
// Load indirect block, allocating if necessary.
- if((addr = ip->addrs[INDIRECT]) == 0) {
+ if((addr = ip->addrs[INDIRECT]) == 0){
if(!alloc)
return -1;
ip->addrs[INDIRECT] = addr = balloc(ip->dev);
@@ -343,8 +343,8 @@ bmap(struct inode *ip, uint bn, int alloc)
bp = bread(ip->dev, addr);
a = (uint*)bp->data;
- if((addr = a[bn]) == 0) {
- if(!alloc) {
+ if((addr = a[bn]) == 0){
+ if(!alloc){
brelse(bp);
return -1;
}
@@ -367,17 +367,17 @@ itrunc(struct inode *ip)
struct buf *bp;
uint *a;
- for(i = 0; i < NDIRECT; i++) {
- if(ip->addrs[i]) {
+ for(i = 0; i < NDIRECT; i++){
+ if(ip->addrs[i]){
bfree(ip->dev, ip->addrs[i]);
ip->addrs[i] = 0;
}
}
- if(ip->addrs[INDIRECT]) {
+ if(ip->addrs[INDIRECT]){
bp = bread(ip->dev, ip->addrs[INDIRECT]);
a = (uint*)bp->data;
- for(j = 0; j < NINDIRECT; j++) {
+ for(j = 0; j < NINDIRECT; j++){
if(a[j])
bfree(ip->dev, a[j]);
}
@@ -408,7 +408,7 @@ readi(struct inode *ip, char *dst, uint off, uint n)
uint tot, m;
struct buf *bp;
- if(ip->type == T_DEV) {
+ if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
return -1;
return devsw[ip->major].read(ip, dst, n);
@@ -419,7 +419,7 @@ readi(struct inode *ip, char *dst, uint off, uint n)
if(off + n > ip->size)
n = ip->size - off;
- for(tot=0; tot<n; tot+=m, off+=m, dst+=m) {
+ for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
bp = bread(ip->dev, bmap(ip, off/BSIZE, 0));
m = min(n - tot, BSIZE - off%BSIZE);
memmove(dst, bp->data + off%BSIZE, m);
@@ -436,7 +436,7 @@ writei(struct inode *ip, char *src, uint off, uint n)
uint tot, m;
struct buf *bp;
- if(ip->type == T_DEV) {
+ if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
return -1;
return devsw[ip->major].write(ip, src, n);
@@ -447,7 +447,7 @@ writei(struct inode *ip, char *src, uint off, uint n)
if(off + n > MAXFILE*BSIZE)
n = MAXFILE*BSIZE - off;
- for(tot=0; tot<n; tot+=m, off+=m, src+=m) {
+ for(tot=0; tot<n; tot+=m, off+=m, src+=m){
bp = bread(ip->dev, bmap(ip, off/BSIZE, 1));
m = min(n - tot, BSIZE - off%BSIZE);
memmove(bp->data + off%BSIZE, src, m);
@@ -455,7 +455,7 @@ writei(struct inode *ip, char *src, uint off, uint n)
brelse(bp);
}
- if(n > 0 && off > ip->size) {
+ if(n > 0 && off > ip->size){
ip->size = off;
iupdate(ip);
}
diff --git a/kbd.c b/kbd.c
index a4dd381..6f5970f 100644
--- a/kbd.c
+++ b/kbd.c
@@ -17,15 +17,15 @@ kbd_getc(void)
return -1;
data = inb(KBDATAP);
- if(data == 0xE0) {
+ if(data == 0xE0){
shift |= E0ESC;
return 0;
- } else if(data & 0x80) {
+ }else if(data & 0x80){
// Key released
data = (shift & E0ESC ? data : data & 0x7F);
shift &= ~(shiftcode[data] | E0ESC);
return 0;
- } else if(shift & E0ESC) {
+ }else if(shift & E0ESC){
// Last character was an E0 escape; or with 0x80
data |= 0x80;
shift &= ~E0ESC;
@@ -34,7 +34,7 @@ kbd_getc(void)
shift |= shiftcode[data];
shift ^= togglecode[data];
c = charcode[shift & (CTL | SHIFT)][data];
- if(shift & CAPSLOCK) {
+ if(shift & CAPSLOCK){
if('a' <= c && c <= 'z')
c += 'A' - 'a';
else if('A' <= c && c <= 'Z')
diff --git a/mkdir.c b/mkdir.c
index ac2c7a6..6e4c954 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -13,7 +13,7 @@ main(int argc, char *argv[])
}
for(i = 1; i < argc; i++){
- if(mkdir(argv[i]) < 0) {
+ if(mkdir(argv[i]) < 0){
printf(2, "mkdir: %s failed to create\n", argv[i]);
break;
}
diff --git a/mp.c b/mp.c
index 563a401..5298ccc 100644
--- a/mp.c
+++ b/mp.c
@@ -134,7 +134,7 @@ mp_init(void)
}
}
- if(mp->imcrp) {
+ if(mp->imcrp){
// Bochs doesn't support IMCR, so this doesn't run on Bochs.
// But it would on real hardware.
outb(0x22, 0x70); // Select IMCR
diff --git a/pipe.c b/pipe.c
index 43f623a..c2c9d75 100644
--- a/pipe.c
+++ b/pipe.c
@@ -65,7 +65,7 @@ pipeclose(struct pipe *p, int writable)
if(writable){
p->writeopen = 0;
wakeup(&p->readp);
- } else {
+ }else{
p->readopen = 0;
wakeup(&p->writep);
}
diff --git a/printf.c b/printf.c
index ad9c758..a5c660a 100644
--- a/printf.c
+++ b/printf.c
@@ -20,14 +20,14 @@ printint(int fd, int xx, int base, int sgn)
if(sgn && xx < 0){
neg = 1;
x = -xx;
- } else {
+ }else{
x = xx;
}
i = 0;
- do {
+ do{
buf[i++] = digits[x % base];
- } while((x /= base) != 0);
+ }while((x /= base) != 0);
if(neg)
buf[i++] = '-';
@@ -50,17 +50,17 @@ printf(int fd, char *fmt, ...)
if(state == 0){
if(c == '%'){
state = '%';
- } else {
+ }else{
putc(fd, c);
}
- } else if(state == '%'){
+ }else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
- } else if(c == 'x' || c == 'p'){
+ }else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
- } else if(c == 's'){
+ }else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
@@ -69,12 +69,12 @@ printf(int fd, char *fmt, ...)
putc(fd, *s);
s++;
}
- } else if(c == 'c'){
+ }else if(c == 'c'){
putc(fd, *ap);
ap++;
- } else if(c == '%'){
+ }else if(c == '%'){
putc(fd, c);
- } else {
+ }else{
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
diff --git a/proc.c b/proc.c
index 3991832..2bd4215 100644
--- a/proc.c
+++ b/proc.c
@@ -86,7 +86,7 @@ setupsegs(struct proc *p)
if(p){
c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, (uint)p->mem, p->sz-1, DPL_USER);
c->gdt[SEG_UDATA] = SEG(STA_W, (uint)p->mem, p->sz-1, DPL_USER);
- } else {
+ }else{
c->gdt[SEG_UCODE] = SEG_NULL;
c->gdt[SEG_UDATA] = SEG_NULL;
}
@@ -444,7 +444,7 @@ procdump(void)
char *state;
uint pc[10];
- for(i = 0; i < NPROC; i++) {
+ for(i = 0; i < NPROC; i++){
p = &proc[i];
if(p->state == UNUSED)
continue;
@@ -453,7 +453,7 @@ procdump(void)
else
state = "???";
cprintf("%d %s %s", p->pid, state, p->name);
- if(p->state == SLEEPING) {
+ if(p->state == SLEEPING){
getcallerpcs((uint*)p->context.ebp+2, pc);
for(j=0; j<10 && pc[j] != 0; j++)
cprintf(" %p", pc[j]);
diff --git a/rm.c b/rm.c
index 0306f11..4fd33c8 100644
--- a/rm.c
+++ b/rm.c
@@ -13,7 +13,7 @@ main(int argc, char *argv[])
}
for(i = 1; i < argc; i++){
- if(unlink(argv[i]) < 0) {
+ if(unlink(argv[i]) < 0){
printf(2, "rm: %s failed to delete\n", argv[i]);
break;
}
diff --git a/sh.c b/sh.c
index 3e596ba..7a7c4c2 100644
--- a/sh.c
+++ b/sh.c
@@ -156,7 +156,7 @@ main(void)
}
// Read and run input commands.
- while(getcmd(buf, sizeof(buf)) >= 0) {
+ while(getcmd(buf, sizeof(buf)) >= 0){
if(fork1() == 0)
runcmd(parsecmd(buf));
wait();
diff --git a/string.c b/string.c
index 5720245..0cab242 100644
--- a/string.c
+++ b/string.c
@@ -19,7 +19,7 @@ memcmp(const void *v1, const void *v2, uint n)
s1 = v1;
s2 = v2;
- while(n-- > 0) {
+ while(n-- > 0){
if(*s1 != *s2)
return *s1 - *s2;
s1++, s2++;
@@ -36,12 +36,12 @@ memmove(void *dst, const void *src, uint n)
s = src;
d = dst;
- if(s < d && s + n > d) {
+ if(s < d && s + n > d){
s += n;
d += n;
while(n-- > 0)
*--d = *--s;
- } else
+ }else
while(n-- > 0)
*d++ = *s++;
diff --git a/syscall.c b/syscall.c
index 2a037d1..bd0ed02 100644
--- a/syscall.c
+++ b/syscall.c
@@ -128,7 +128,7 @@ syscall(void)
num = cp->tf->eax;
if(num >= 0 && num < NELEM(syscalls) && syscalls[num])
cp->tf->eax = syscalls[num]();
- else {
+ else{
cprintf("%d %s: unknown sys call %d\n",
cp->pid, cp->name, num);
cp->tf->eax = -1;
diff --git a/sysfile.c b/sysfile.c
index 0b7cb9e..400d395 100644
--- a/sysfile.c
+++ b/sysfile.c
@@ -335,7 +335,7 @@ sys_chdir(void)
if(argstr(0, &path) < 0 || (ip = namei(path)) == 0)
return -1;
ilock(ip);
- if(ip->type != T_DIR) {
+ if(ip->type != T_DIR){
iunlockput(ip);
return -1;
}
diff --git a/trap.c b/trap.c
index ab5b7cc..3120994 100644
--- a/trap.c
+++ b/trap.c
@@ -72,7 +72,7 @@ trap(struct trapframe *tf)
break;
default:
- if(cp == 0) {
+ if(cp == 0){
// Otherwise it's our mistake.
cprintf("unexpected trap %d from cpu %d eip %x\n",
tf->trapno, cpu(), tf->eip);
diff --git a/umalloc.c b/umalloc.c
index 401ee6a..ca31aa7 100644
--- a/umalloc.c
+++ b/umalloc.c
@@ -30,15 +30,15 @@ free(void *ap)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
- if(bp + bp->s.size == p->s.ptr) {
+ if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
- } else
+ }else
bp->s.ptr = p->s.ptr;
- if(p + p->s.size == bp) {
+ if(p + p->s.size == bp){
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
- } else
+ }else
p->s.ptr = bp;
freep = p;
}
@@ -67,15 +67,15 @@ malloc(uint nbytes)
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
- if((prevp = freep) == 0) {
+ if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
- for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr) {
- if(p->s.size >= nunits) {
+ for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
+ if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
- else {
+ else{
p->s.size -= nunits;
p += p->s.size;
p->s.size = nunits;
diff --git a/wc.c b/wc.c
index eb25e92..b728d27 100644
--- a/wc.c
+++ b/wc.c
@@ -37,7 +37,7 @@ main(int argc, char *argv[])
{
int fd, i;
- if(argc <= 1) {
+ if(argc <= 1){
wc(0, "");
exit();
}