summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorRuss Cox <[email protected]>2011-01-11 13:01:13 -0500
committerRuss Cox <[email protected]>2011-01-11 13:01:13 -0500
commit1a81e38b17144624415d252a521fd5a06079d681 (patch)
treeea7d895bcf77aa25861c09ee490488b6f729e0f3 /mkfs.c
parent240679608cd46649d1144408f28f83141f9f3a86 (diff)
downloadxv6-labs-1a81e38b17144624415d252a521fd5a06079d681.tar.gz
xv6-labs-1a81e38b17144624415d252a521fd5a06079d681.tar.bz2
xv6-labs-1a81e38b17144624415d252a521fd5a06079d681.zip
make new code like old code
Variable declarations at top of function, separate from initialization. Use == 0 instead of ! for checking pointers. Consistent spacing around {, *, casts. Declare 0-parameter functions as (void) not (). Integer valued functions return -1 on failure, 0 on success.
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/mkfs.c b/mkfs.c
index ffd6745..77e6791 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -35,7 +35,7 @@ ushort
xshort(ushort x)
{
ushort y;
- uchar *a = (uchar*) &y;
+ uchar *a = (uchar*)&y;
a[0] = x;
a[1] = x >> 8;
return y;
@@ -45,7 +45,7 @@ uint
xint(uint x)
{
uint y;
- uchar *a = (uchar*) &y;
+ uchar *a = (uchar*)&y;
a[0] = x;
a[1] = x >> 8;
a[2] = x >> 16;
@@ -177,7 +177,7 @@ winode(uint inum, struct dinode *ip)
bn = i2b(inum);
rsect(bn, buf);
- dip = ((struct dinode*) buf) + (inum % IPB);
+ dip = ((struct dinode*)buf) + (inum % IPB);
*dip = *ip;
wsect(bn, buf);
}
@@ -191,7 +191,7 @@ rinode(uint inum, struct dinode *ip)
bn = i2b(inum);
rsect(bn, buf);
- dip = ((struct dinode*) buf) + (inum % IPB);
+ dip = ((struct dinode*)buf) + (inum % IPB);
*ip = *dip;
}
@@ -231,7 +231,7 @@ balloc(int used)
printf("balloc: first %d blocks have been allocated\n", used);
assert(used < 512);
bzero(buf, 512);
- for(i = 0; i < used; i++) {
+ for(i = 0; i < used; i++){
buf[i/8] = buf[i/8] | (0x1 << (i%8));
}
printf("balloc: write bitmap block at sector %zu\n", ninodes/IPB + 3);
@@ -243,7 +243,7 @@ balloc(int used)
void
iappend(uint inum, void *xp, int n)
{
- char *p = (char*) xp;
+ char *p = (char*)xp;
uint fbn, off, n1;
struct dinode din;
char buf[512];
@@ -256,24 +256,24 @@ iappend(uint inum, void *xp, int n)
while(n > 0){
fbn = off / 512;
assert(fbn < MAXFILE);
- if(fbn < NDIRECT) {
- if(xint(din.addrs[fbn]) == 0) {
+ if(fbn < NDIRECT){
+ if(xint(din.addrs[fbn]) == 0){
din.addrs[fbn] = xint(freeblock++);
usedblocks++;
}
x = xint(din.addrs[fbn]);
} else {
- if(xint(din.addrs[NDIRECT]) == 0) {
+ if(xint(din.addrs[NDIRECT]) == 0){
// printf("allocate indirect block\n");
din.addrs[NDIRECT] = xint(freeblock++);
usedblocks++;
}
// printf("read indirect block\n");
- rsect(xint(din.addrs[NDIRECT]), (char*) indirect);
- if(indirect[fbn - NDIRECT] == 0) {
+ rsect(xint(din.addrs[NDIRECT]), (char*)indirect);
+ if(indirect[fbn - NDIRECT] == 0){
indirect[fbn - NDIRECT] = xint(freeblock++);
usedblocks++;
- wsect(xint(din.addrs[NDIRECT]), (char*) indirect);
+ wsect(xint(din.addrs[NDIRECT]), (char*)indirect);
}
x = xint(indirect[fbn-NDIRECT]);
}