Skip to content

Commit

Permalink
more consistent spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 28, 2007
1 parent c1b100e commit e4d6a21
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main(int argc, char *argv[])
{
int fd, i;

if(argc <= 1) {
if(argc <= 1){
cat(0);
exit();
}
Expand Down
6 changes: 3 additions & 3 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++] = '-';

Expand Down
36 changes: 18 additions & 18 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -333,18 +333,18 @@ 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);
}
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;
}
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -447,15 +447,15 @@ 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);
bwrite(bp);
brelse(bp);
}

if(n > 0 && off > ip->size) {
if(n > 0 && off > ip->size){
ip->size = off;
iupdate(ip);
}
Expand Down
8 changes: 4 additions & 4 deletions kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
20 changes: 10 additions & 10 deletions printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++] = '-';

Expand All @@ -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)
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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++;

Expand Down
2 changes: 1 addition & 1 deletion syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sysfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions umalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit e4d6a21

Please sign in to comment.