Skip to content

Commit

Permalink
Remove trailing white space with:
Browse files Browse the repository at this point in the history
 for f in *.{h,c}; do sed -i .sed 's/[[:blank:]]*$//' $f; done
(Thanks to Nicolás Wolovick)
  • Loading branch information
kaashoek committed Aug 25, 2016
1 parent 6de6a3c commit 7894fcd
Show file tree
Hide file tree
Showing 32 changed files with 116 additions and 116 deletions.
6 changes: 3 additions & 3 deletions bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
// cached copies of disk block contents. Caching disk blocks
// in memory reduces the number of disk reads and also provides
// a synchronization point for disk blocks used by multiple processes.
//
//
// Interface:
// * To get a buffer for a particular disk block, call bread.
// * After changing buffer data, call bwrite to write it to disk.
// * When done with the buffer, call brelse.
// * Do not use the buffer after calling brelse.
// * Only one process at a time can use a buffer,
// so do not keep them longer than necessary.
//
//
// The implementation uses three state flags internally:
// * B_BUSY: the block has been returned from bread
// and has not been passed back to brelse.
// and has not been passed back to brelse.
// * B_VALID: the buffer data has been read from the disk.
// * B_DIRTY: the buffer data has been modified
// and needs to be written to disk.
Expand Down
2 changes: 1 addition & 1 deletion bootmain.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Boot loader.
//
//
// Part of the boot block, along with bootasm.S, which calls bootmain().
// bootasm.S has put the processor into protected 32-bit mode.
// bootmain() loads an ELF kernel image from the disk starting at
Expand Down
8 changes: 4 additions & 4 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ panic(char *s)
{
int i;
uint pcs[10];

cli();
cons.locking = 0;
cprintf("cpu%d: panic: ", cpu->id);
Expand All @@ -130,7 +130,7 @@ static void
cgaputc(int c)
{
int pos;

// Cursor position: col + 80*row.
outb(CRTPORT, 14);
pos = inb(CRTPORT+1) << 8;
Expand All @@ -146,13 +146,13 @@ cgaputc(int c)

if(pos < 0 || pos > 25*80)
panic("pos under/overflow");

if((pos/80) >= 24){ // Scroll up.
memmove(crt, crt+80, sizeof(crt[0])*23*80);
pos -= 80;
memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos));
}

outb(CRTPORT, 14);
outb(CRTPORT+1, pos>>8);
outb(CRTPORT, 15);
Expand Down
2 changes: 1 addition & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fileclose(struct file *f)
f->ref = 0;
f->type = FD_NONE;
release(&ftable.lock);

if(ff.type == FD_PIPE)
pipeclose(ff.pipe, ff.writable);
else if(ff.type == FD_INODE){
Expand Down
8 changes: 4 additions & 4 deletions forktest.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ forktest(void)
if(pid == 0)
exit();
}

if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}

for(; n > 0; n--){
if(wait() < 0){
printf(1, "wait stopped early\n");
exit();
}
}

if(wait() != -1){
printf(1, "wait got too many\n");
exit();
}

printf(1, "fork test OK\n");
}

Expand Down
14 changes: 7 additions & 7 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// + Directories: inode with special contents (list of other inodes!)
// + Names: paths like /usr/rtm/xv6/fs.c for convenient naming.
//
// This file contains the low-level file system manipulation
// This file contains the low-level file system manipulation
// routines. The (higher-level) system call implementations
// are in sysfile.c.

Expand All @@ -29,7 +29,7 @@ void
readsb(int dev, struct superblock *sb)
{
struct buf *bp;

bp = bread(dev, 1);
memmove(sb, bp->data, sizeof(*sb));
brelse(bp);
Expand All @@ -40,14 +40,14 @@ static void
bzero(int dev, int bno)
{
struct buf *bp;

bp = bread(dev, bno);
memset(bp->data, 0, BSIZE);
log_write(bp);
brelse(bp);
}

// Blocks.
// Blocks.

// Allocate a zeroed disk block.
static uint
Expand Down Expand Up @@ -348,7 +348,7 @@ iunlockput(struct inode *ip)
//
// The content (data) associated with each inode is stored
// in blocks on the disk. The first NDIRECT block numbers
// are listed in ip->addrs[]. The next NINDIRECT blocks are
// are listed in ip->addrs[]. The next NINDIRECT blocks are
// listed in block ip->addrs[NDIRECT].

// Return the disk block address of the nth block in inode ip.
Expand Down Expand Up @@ -401,7 +401,7 @@ itrunc(struct inode *ip)
ip->addrs[i] = 0;
}
}

if(ip->addrs[NDIRECT]){
bp = bread(ip->dev, ip->addrs[NDIRECT]);
a = (uint*)bp->data;
Expand Down Expand Up @@ -554,7 +554,7 @@ dirlink(struct inode *dp, char *name, uint inum)
de.inum = inum;
if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de))
panic("dirlink");

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion fs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// On-disk file system format.
// On-disk file system format.
// Both the kernel and user programs use this header file.


Expand Down
6 changes: 3 additions & 3 deletions grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ grep(char *pattern, int fd)
{
int n, m;
char *p, *q;

m = 0;
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
m += n;
Expand Down Expand Up @@ -40,13 +40,13 @@ main(int argc, char *argv[])
{
int fd, i;
char *pattern;

if(argc <= 1){
printf(2, "usage: grep pattern [file ...]\n");
exit();
}
pattern = argv[1];

if(argc <= 2){
grep(pattern, 0);
exit();
Expand Down
22 changes: 11 additions & 11 deletions ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ idewait(int checkerr)
{
int r;

while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY)
while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY)
;
if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0)
return -1;
Expand All @@ -50,12 +50,12 @@ void
ideinit(void)
{
int i;

initlock(&idelock, "ide");
picenable(IRQ_IDE);
ioapicenable(IRQ_IDE, ncpu - 1);
idewait(0);

// Check if disk 1 is present
outb(0x1f6, 0xe0 | (1<<4));
for(i=0; i<1000; i++){
Expand All @@ -64,7 +64,7 @@ ideinit(void)
break;
}
}

// Switch back to disk 0.
outb(0x1f6, 0xe0 | (0<<4));
}
Expand All @@ -81,9 +81,9 @@ idestart(struct buf *b)
int sector = b->blockno * sector_per_block;
int read_cmd = (sector_per_block == 1) ? IDE_CMD_READ : IDE_CMD_RDMUL;
int write_cmd = (sector_per_block == 1) ? IDE_CMD_WRITE : IDE_CMD_WRMUL;

if (sector_per_block > 7) panic("idestart");

idewait(0);
outb(0x3f6, 0); // generate interrupt
outb(0x1f2, sector_per_block); // number of sectors
Expand Down Expand Up @@ -117,12 +117,12 @@ ideintr(void)
// Read data if needed.
if(!(b->flags & B_DIRTY) && idewait(1) >= 0)
insl(0x1f0, b->data, BSIZE/4);

// Wake process waiting for this buf.
b->flags |= B_VALID;
b->flags &= ~B_DIRTY;
wakeup(b);

// Start disk on next buf in queue.
if(idequeue != 0)
idestart(idequeue);
Expand All @@ -131,7 +131,7 @@ ideintr(void)
}

//PAGEBREAK!
// Sync buf with disk.
// Sync buf with disk.
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID.
void
Expand All @@ -153,11 +153,11 @@ iderw(struct buf *b)
for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue
;
*pp = b;

// Start disk if necessary.
if(idequeue == b)
idestart(b);

// Wait for request to finish.
while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){
sleep(b, &idelock);
Expand Down
2 changes: 1 addition & 1 deletion ioapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define REG_TABLE 0x10 // Redirection table base

// The redirection table starts at REG_TABLE and uses
// two registers to configure each interrupt.
// two registers to configure each interrupt.
// The first (low) register in a pair contains configuration bits.
// The second (high) register contains a bitmask telling which
// CPUs can serve that interrupt.
Expand Down
14 changes: 7 additions & 7 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// Contents of the header block, used for both the on-disk header block
// and to keep track in memory of logged block# before commit.
struct logheader {
int n;
int n;
int block[LOGSIZE];
};

Expand Down Expand Up @@ -65,7 +65,7 @@ initlog(int dev)
}

// Copy committed blocks from log to their home location
static void
static void
install_trans(void)
{
int tail;
Expand All @@ -75,7 +75,7 @@ install_trans(void)
struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
bwrite(dbuf); // write dst to disk
brelse(lbuf);
brelse(lbuf);
brelse(dbuf);
}
}
Expand Down Expand Up @@ -114,7 +114,7 @@ write_head(void)
static void
recover_from_log(void)
{
read_head();
read_head();
install_trans(); // if committed, copy from log to disk
log.lh.n = 0;
write_head(); // clear the log
Expand Down Expand Up @@ -171,7 +171,7 @@ end_op(void)
}

// Copy modified blocks from cache to log.
static void
static void
write_log(void)
{
int tail;
Expand All @@ -181,7 +181,7 @@ write_log(void)
struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
memmove(to->data, from->data, BSIZE);
bwrite(to); // write the log
brelse(from);
brelse(from);
brelse(to);
}
}
Expand All @@ -193,7 +193,7 @@ commit()
write_log(); // Write modified blocks from cache to log
write_head(); // Write header to disk -- the real commit
install_trans(); // Now install writes to home locations
log.lh.n = 0;
log.lh.n = 0;
write_head(); // Erase the transaction from the log
}
}
Expand Down
12 changes: 6 additions & 6 deletions ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ fmtname(char *path)
{
static char buf[DIRSIZ+1];
char *p;

// Find first character after last slash.
for(p=path+strlen(path); p >= path && *p != '/'; p--)
;
p++;

// Return blank-padded name.
if(strlen(p) >= DIRSIZ)
return p;
Expand All @@ -29,23 +29,23 @@ ls(char *path)
int fd;
struct dirent de;
struct stat st;

if((fd = open(path, 0)) < 0){
printf(2, "ls: cannot open %s\n", path);
return;
}

if(fstat(fd, &st) < 0){
printf(2, "ls: cannot stat %s\n", path);
close(fd);
return;
}

switch(st.type){
case T_FILE:
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
break;

case T_DIR:
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
printf(1, "ls: path too long\n");
Expand Down
Loading

0 comments on commit 7894fcd

Please sign in to comment.