more consistent spacing

This commit is contained in:
rsc 2007-08-28 18:32:08 +00:00
parent c1b100e930
commit e4d6a21165
17 changed files with 59 additions and 59 deletions

2
cat.c
View file

@ -22,7 +22,7 @@ main(int argc, char *argv[])
{
int fd, i;
if(argc <= 1) {
if(argc <= 1){
cat(0);
exit();
}

View file

@ -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++] = '-';

36
fs.c
View file

@ -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);
}

8
kbd.c
View file

@ -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')

View file

@ -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;
}

2
mp.c
View file

@ -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

2
pipe.c
View file

@ -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);
}

View file

@ -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);

6
proc.c
View file

@ -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]);

2
rm.c
View file

@ -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;
}

2
sh.c
View file

@ -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();

View file

@ -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++;

View file

@ -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;

View file

@ -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;
}

2
trap.c
View file

@ -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);

View file

@ -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;

2
wc.c
View file

@ -37,7 +37,7 @@ main(int argc, char *argv[])
{
int fd, i;
if(argc <= 1) {
if(argc <= 1){
wc(0, "");
exit();
}