Skip to content

Commit

Permalink
Merge branch 'try/fix_warning'
Browse files Browse the repository at this point in the history
  • Loading branch information
flaneur2020 committed Apr 5, 2012
2 parents 4e9ea39 + a058a87 commit e7c35fe
Show file tree
Hide file tree
Showing 44 changed files with 369 additions and 214 deletions.
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
werror = '-Werror' if ENV['werror']

cinc = '-Isrc/inc -Isrc/inc/usr'
cflag = %w{
-Wall
cflag = %{
-Wall #{werror}
-nostdinc -fno-builtin -fno-stack-protector
-finline-functions -finline-small-functions -findirect-inlining -finline-functions -finline-functions-called-once
} * ' '
}.split(/\s/).join(' ')

mkdir_p 'bin'
mkdir_p 'bin/usr'
Expand Down
19 changes: 8 additions & 11 deletions src/blk/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ struct buf* getblk(int dev, uint blkno){
panic("error devtab. ");
}
// 1. found in the dev's cache list
if (bp=incore(dev, blkno)) {
if ((bp=incore(dev, blkno))) {
// 2. found in the dev's cache list but busy
cli();
if (bp->b_flag & B_BUSY) {
bp->b_flag |= B_WANTED;
sleep(bp, PRIBIO);
sleep((uint)bp, PRIBIO);
sti();
goto _loop;
}
Expand All @@ -81,7 +81,7 @@ struct buf* getblk(int dev, uint blkno){
cli();
if (bfreelist.av_next==&bfreelist) {
bfreelist.b_flag |= B_WANTED;
sleep(&bfreelist, PRIBIO);
sleep((uint)&bfreelist, PRIBIO);
sti();
goto _loop;
}
Expand All @@ -100,10 +100,8 @@ struct buf* getblk(int dev, uint blkno){
cli();
bp->b_prev->b_next = bp->b_next;
bp->b_next->b_prev = bp->b_prev;
bp->b_next = dtp->b_next;
bp->b_prev = (struct buf *)dtp;
// prepend it into the target dev's cache list.
bp->b_prev = dtp;
bp->b_prev = (struct buf*)dtp;
bp->b_next = dtp->b_next;
dtp->b_next->b_prev = bp;
dtp->b_next = bp;
Expand All @@ -121,14 +119,13 @@ struct buf* getblk(int dev, uint blkno){
* TODO: consider B_ERROR
* */
void brelse(struct buf *bp){
struct buf *tmp;

if (bp->b_flag & B_WANTED) {
wakeup(bp);
wakeup((uint)bp);
}
if (bfreelist.b_flag & B_WANTED) {
bfreelist.b_flag &= ~B_WANTED;
wakeup(&bfreelist);
wakeup((uint)&bfreelist);
}
if (bp->b_flag & B_ERROR) {
bp->b_dev = NODEV;
Expand All @@ -151,15 +148,15 @@ void notavail(struct buf *bp){

void iowait(struct buf *bp){
while((bp->b_flag&B_DONE)==0){
sleep(bp, PRIBIO);
sleep((uint)bp, PRIBIO);
}
}

void iodone(struct buf *bp){
bp->b_flag |= B_DONE;
bp->b_flag &= ~B_WANTED;
//brelse(bp);
wakeup(bp);
wakeup((uint)bp);
}

/**********************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/blk/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ struct bdevsw bdevsw[NBLKDEV] = {

struct cdevsw cdevsw[NCHRDEV] = {
{ 0, }, /* NODEV */
{ &tty_open, &nulldev, &tty_read, &tty_write, &nulldev}
{ &tty_open, (void*)&nulldev, &tty_read, &tty_write, (void*)&nulldev }
};

12 changes: 9 additions & 3 deletions src/blk/hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int hd_cmd(uint drive, uint cmd, uint lba, uchar ns) {
outb(0x1F5, (lba >> 16) & 0xFF);
outb(0x1F6, 0xE0 | ((drive&1)<<4) | ((lba>>24)&0x0F));
outb(HD_CMD, cmd);
return 0;
}

/*
Expand All @@ -58,14 +59,15 @@ int hd_wait_ready(){
* */
int hd_request(struct buf *bp){
// prepend into the waiting list
bp->av_prev = &hdtab;
bp->av_prev = (struct buf*)&hdtab;
bp->av_next = hdtab.av_next;
hdtab.av_next->av_prev = bp;
hdtab.av_next = bp;
// if the device's not busy
if (hdtab.d_active == 0) {
hd_start();
}
return 0;
}

/* if waiting list is not empty, then take the tail, send a request
Expand All @@ -77,7 +79,7 @@ int hd_request(struct buf *bp){
void hd_start(){
struct buf *bp;
// if waiting list is empty
if (hdtab.av_next == &hdtab) {
if ((struct devtab*)hdtab.av_next == &hdtab) {
return;
}
// take the tail
Expand All @@ -102,7 +104,7 @@ int do_hd_intr(struct trap *tf){
struct buf *bp;

if (hdtab.d_active == 0) {
return;
return 0;
}
hdtab.d_active = 0;
bp = hdtab.av_prev;
Expand All @@ -114,6 +116,7 @@ int do_hd_intr(struct trap *tf){
}
iodone(bp);
hd_start();
return 0;
}

/*
Expand All @@ -129,9 +132,12 @@ void hd_init(){

/* empty routine */
int nulldev(){
return 0;
}

/* it should raise an ENODEV error when being called.*/
int nodev(){
syserr(ENODEV);
return 0;
}

8 changes: 5 additions & 3 deletions src/chr/keybd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ char shift(char sc){
* */
int do_keybd_intr(struct trap *tf){
uchar sc, ch, m;
char *map = keybd_map;
uchar *map = keybd_map;

// got no data
if ((inb(KB_STAT) & KB_STAT_DIB)==0){
Expand All @@ -60,7 +60,7 @@ int do_keybd_intr(struct trap *tf){
mode |= E0ESC;

// check shift, ctrl and alt
if (m = shift(sc)) {
if ((m = shift(sc))) {
if (sc & 0x80)
mode &= ~m;
else
Expand All @@ -83,13 +83,15 @@ int do_keybd_intr(struct trap *tf){
}

// on pressed
if ((sc & 0x80)==0 && ch!=NULL) {
if ((sc & 0x80)==0 && ch!='\0') {
tty_input(&tty[0], ch);
}
// on released
else {
mode &= ~E0ESC;
}

return 0;
}

void keybd_init(){
Expand Down
13 changes: 8 additions & 5 deletions src/chr/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
//
#include <conf.h>
#include <tty.h>
#include <keybd.h>

struct tty tty[NTTY];

/* ---------------------------------------------- */
int tty_start(struct tty *tp);


/*
* Append a character into a tty buf.
Expand Down Expand Up @@ -82,6 +83,7 @@ int tty_canon(struct tty *tp){
break;
}
}
return 0;
}

/* output characters with buffering */
Expand Down Expand Up @@ -129,22 +131,24 @@ int tty_input(struct tty *tp, char ch){
}
if (ch==CEOF || ch=='\n') {
eraseq(&tp->t_canq);
wakeup(tp);
wakeup((uint)tp);
return 0;
}
return 0;
}

/* ---------------------------------------- */

/* output actually starts here. */
int tty_start(struct tty *tp){
int (*putc)(char);
void (*putc)(char);
char ch;

putc = tp->t_putc;
while((ch=getq(&tp->t_outq)) >= 0){
putc(ch);
}
return 0;
}

/* ---------------------------------------------- */
Expand Down Expand Up @@ -178,7 +182,6 @@ int tty_close(ushort dev){
* */
int tty_read(ushort dev, char *buf, uint cnt){
struct tty *tp;
struct qbuf qb;
char ch;
int i;

Expand All @@ -189,7 +192,7 @@ int tty_read(ushort dev, char *buf, uint cnt){
tp = &tty[MINOR(dev)];
// if no data on canonical list
if (tp->t_canq.q_count < cnt) {
sleep(tp, PRITTY);
sleep((uint)tp, PRITTY);
}
//
for (i=0; i<cnt; i++) {
Expand Down
13 changes: 7 additions & 6 deletions src/chr/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void flush_csr(){

/* clear screen */
void cls(){
memsetw(vgamem, VC_BLANK, 80*25);
memsetw((short*)vgamem, VC_BLANK, 80*25);
px = 0;
py = 0;
flush_csr();
Expand All @@ -53,7 +53,7 @@ void scroll(void) {
if(py >= 25) {
uint pos = py-25+1;
memcpy(vgamem, &vgamem[pos][0], (25-pos)*80*sizeof(struct vchar));
memsetw(&vgamem[25-pos][0], VC_BLANK, 80);
memsetw((short*)&vgamem[25-pos][0], VC_BLANK, 80);
py = 25-1;
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ void puts(char *str){
void printn(uint n, uint b){
static char *ntab = "0123456789ABCDEF";
uint a, m;
if (a = n / b){
if ((a = n / b)){
printn(a, b);
}
m = n % b;
Expand All @@ -118,9 +118,10 @@ void printn(uint n, uint b){
* refer to unix v6
* */
void printk(char *fmt, ...){
char c, *s;
char c;
int n;
int *adx = (uint*)(void*)&fmt + 1;
int *adx = (int*)(void*)&fmt + 1;

_loop:
while((c = *fmt++) != '%'){
if (c == '\0') return;
Expand All @@ -142,7 +143,7 @@ void printk(char *fmt, ...){
putch(*adx);
}
if (c == 's'){
puts(*adx);
puts((char*)*adx);
}
adx++;
goto _loop;
Expand Down
2 changes: 1 addition & 1 deletion src/fs/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int bfree(ushort dev, uint nr){
bwrite(bp);
brelse(bp);
unlk_sp(sp);
return 0;
}

/* zero one disk block.
Expand All @@ -82,7 +83,6 @@ int bzero(ushort dev, uint bn){
int ialloc(ushort dev){
uint nr, ino;
int r;
struct inode *ip;
struct super *sp;
struct buf *bp;

Expand Down
3 changes: 2 additions & 1 deletion src/fs/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int bmap(struct inode *ip, ushort nr, uchar creat) {
// read the secondary indirect zone map.
bp2 = bread(dev, zmap[nr/NINDBLK]);
zmap2 = (short*)bp2->b_data;
if (zmap2[nr%NINDBLK]==0 & creat) {
if ((zmap2[nr%NINDBLK]==0) & creat) {
zmap2[nr%NINDBLK] = balloc(dev);
bwrite(bp2);
}
Expand Down Expand Up @@ -163,4 +163,5 @@ int itrunc(struct inode *ip){
}
ip->i_size = 0;
iupdate(ip);
return 0;
}
11 changes: 4 additions & 7 deletions src/fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct inode inode[NINODE];
*
* */
struct inode* iget(ushort dev, uint num){
struct buf *bp;
struct inode *ip;
struct super *sp;

Expand All @@ -47,7 +46,7 @@ struct inode* iget(ushort dev, uint num){
// if found but locked.
if (ip->i_flag & I_LOCK) {
ip->i_flag |= I_WANTED;
sleep(ip, PINOD);
sleep((uint)ip, PINOD);
goto _loop;
}
// if this is an mount point, redirect to the mount
Expand Down Expand Up @@ -129,7 +128,6 @@ int iload(struct inode *ip){
struct super *sp;
struct d_inode *itab; /* note this is an d_inode, 32 bytes. */
struct buf *bp;
uint lba;

sp = getsp(ip->i_dev);
if (sp==NULL){
Expand All @@ -151,7 +149,6 @@ void iupdate(struct inode *ip){
struct super *sp;
struct d_inode *itab;
struct buf *bp;
uint lba;

/*
if ((ip->i_flag & I_DIRTY)==0){
Expand All @@ -174,14 +171,14 @@ void iupdate(struct inode *ip){
ip->i_flag &= ~I_DIRTY;
bwrite(bp);
brelse(bp);
return 0;
return;
}

/*************************************************************/

void lock_ino(struct inode *ip){
while(ip->i_flag & I_LOCK){
sleep(ip, PINOD);
sleep((uint)ip, PINOD);
}
ip->i_flag |= I_LOCK;
}
Expand All @@ -190,7 +187,7 @@ void lock_ino(struct inode *ip){
void unlk_ino(struct inode *ip){
cli();
if (ip->i_flag & I_WANTED) {
wakeup(ip);
wakeup((uint)ip);
}
ip->i_flag &= ~(I_LOCK | I_WANTED);
sti();
Expand Down
Loading

0 comments on commit e7c35fe

Please sign in to comment.