break single-line if statements
This commit is contained in:
parent
96d467b3a9
commit
48b824703b
21
fs.c
21
fs.c
|
@ -371,20 +371,23 @@ newblock(struct inode *ip, uint lbn)
|
||||||
if(lbn < NDIRECT) {
|
if(lbn < NDIRECT) {
|
||||||
if(ip->addrs[lbn] == 0) {
|
if(ip->addrs[lbn] == 0) {
|
||||||
b = balloc(ip->dev);
|
b = balloc(ip->dev);
|
||||||
if(b <= 0) return -1;
|
if(b <= 0)
|
||||||
|
return -1;
|
||||||
ip->addrs[lbn] = b;
|
ip->addrs[lbn] = b;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ip->addrs[INDIRECT] == 0) {
|
if(ip->addrs[INDIRECT] == 0) {
|
||||||
b = balloc(ip->dev);
|
b = balloc(ip->dev);
|
||||||
if(b <= 0) return -1;
|
if(b <= 0)
|
||||||
|
return -1;
|
||||||
ip->addrs[INDIRECT] = b;
|
ip->addrs[INDIRECT] = b;
|
||||||
}
|
}
|
||||||
inbp = bread(ip->dev, ip->addrs[INDIRECT]);
|
inbp = bread(ip->dev, ip->addrs[INDIRECT]);
|
||||||
inaddrs = (uint*) inbp->data;
|
inaddrs = (uint*) inbp->data;
|
||||||
if(inaddrs[lbn - NDIRECT] == 0) {
|
if(inaddrs[lbn - NDIRECT] == 0) {
|
||||||
b = balloc(ip->dev);
|
b = balloc(ip->dev);
|
||||||
if(b <= 0) return -1;
|
if(b <= 0)
|
||||||
|
return -1;
|
||||||
inaddrs[lbn - NDIRECT] = b;
|
inaddrs[lbn - NDIRECT] = b;
|
||||||
bwrite(inbp, ip->addrs[INDIRECT]);
|
bwrite(inbp, ip->addrs[INDIRECT]);
|
||||||
}
|
}
|
||||||
|
@ -407,7 +410,8 @@ writei(struct inode *ip, char *addr, uint off, uint n)
|
||||||
int lbn;
|
int lbn;
|
||||||
while(r < n) {
|
while(r < n) {
|
||||||
lbn = off / BSIZE;
|
lbn = off / BSIZE;
|
||||||
if(lbn >= MAXFILE) return r;
|
if(lbn >= MAXFILE)
|
||||||
|
return r;
|
||||||
if(newblock(ip, lbn) < 0) {
|
if(newblock(ip, lbn) < 0) {
|
||||||
cprintf("newblock failed\n");
|
cprintf("newblock failed\n");
|
||||||
return r;
|
return r;
|
||||||
|
@ -422,8 +426,10 @@ writei(struct inode *ip, char *addr, uint off, uint n)
|
||||||
}
|
}
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
if(off > ip->size) {
|
if(off > ip->size) {
|
||||||
if(ip->type == T_DIR) ip->size = ((off / BSIZE) + 1) * BSIZE;
|
if(ip->type == T_DIR)
|
||||||
else ip->size = off;
|
ip->size = ((off / BSIZE) + 1) * BSIZE;
|
||||||
|
else
|
||||||
|
ip->size = off;
|
||||||
}
|
}
|
||||||
iupdate(ip);
|
iupdate(ip);
|
||||||
}
|
}
|
||||||
|
@ -462,7 +468,8 @@ namei(char *path, int mode, uint *ret_off, char **ret_last, struct inode **ret_i
|
||||||
if(ret_ip)
|
if(ret_ip)
|
||||||
*ret_ip = 0;
|
*ret_ip = 0;
|
||||||
|
|
||||||
if(*cp == '/') dp = iget(rootdev, 1);
|
if(*cp == '/')
|
||||||
|
dp = iget(rootdev, 1);
|
||||||
else {
|
else {
|
||||||
dp = p->cwd;
|
dp = p->cwd;
|
||||||
iincref(dp);
|
iincref(dp);
|
||||||
|
|
3
mp.c
3
mp.c
|
@ -204,7 +204,8 @@ mp_startthem(void)
|
||||||
(uint) _binary_bootother_size);
|
(uint) _binary_bootother_size);
|
||||||
|
|
||||||
for(c = 0; c < ncpu; c++){
|
for(c = 0; c < ncpu; c++){
|
||||||
if(c == cpu()) continue;
|
if(c == cpu())
|
||||||
|
continue;
|
||||||
*(uint*)(APBOOTCODE-4) = (uint) (cpus[c].mpstack) + MPSTACK; // tell it what to use for %esp
|
*(uint*)(APBOOTCODE-4) = (uint) (cpus[c].mpstack) + MPSTACK; // tell it what to use for %esp
|
||||||
*(uint*)(APBOOTCODE-8) = (uint)mpmain; // tell it where to jump to
|
*(uint*)(APBOOTCODE-8) = (uint)mpmain; // tell it where to jump to
|
||||||
lapic_startap(cpus[c].apicid, (uint) APBOOTCODE);
|
lapic_startap(cpus[c].apicid, (uint) APBOOTCODE);
|
||||||
|
|
3
sh.c
3
sh.c
|
@ -149,7 +149,8 @@ runcmd(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(cmdlist[c].argv[0], "/cd") == 0) {
|
if(strcmp(cmdlist[c].argv[0], "/cd") == 0) {
|
||||||
if(debug) printf (2, "/cd %s is build in\n", cmdlist[c].argv[1]);
|
if(debug)
|
||||||
|
printf (2, "/cd %s is build in\n", cmdlist[c].argv[1]);
|
||||||
chdir(cmdlist[c].argv[1]);
|
chdir(cmdlist[c].argv[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue