shithub: riscv

Download patch

ref: 27445c5768fc9efd11efae2ac0e793fd7f4779fc
parent: dd96b1d965eb8dabb2388dce692363ce8322248e
author: cinap_lenrek <[email protected]>
date: Sun Aug 2 01:36:35 EDT 2015

kernel: cleanup qlock.c to use nil instead of 0 for pointers

--- a/sys/src/9/port/qlock.c
+++ b/sys/src/9/port/qlock.c
@@ -24,7 +24,7 @@
 		print("eqlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
 	if(up != nil && up->nlocks)
 		print("eqlock: %#p: nlocks %d\n", getcallerpc(&q), up->nlocks);
-	if(up != nil && up->eql)
+	if(up != nil && up->eql != nil)
 		print("eqlock: %#p: eql %p\n", getcallerpc(&q), up->eql);
 	if(q->use.key == 0x55555555)
 		panic("eqlock: q %#p, key 5*", q);
@@ -36,7 +36,7 @@
 		unlock(&q->use);
 		return;
 	}
-	if(up == 0)
+	if(up == nil)
 		panic("eqlock");
 	if(up->notepending){
 		up->notepending = 0;
@@ -45,22 +45,22 @@
 	}
 	rwstats.qlockq++;
 	p = q->tail;
-	if(p == 0)
+	if(p == nil)
 		q->head = up;
 	else
 		p->qnext = up;
 	q->tail = up;
 	up->eql = q;
-	up->qnext = 0;
+	up->qnext = nil;
 	up->qpc = getcallerpc(&q);
 	up->state = Queueing;
 	unlock(&q->use);
 	sched();
-	if(up->eql == 0){
+	if(up->eql == nil){
 		up->notepending = 0;
 		interrupted();
 	}
-	up->eql = 0;
+	up->eql = nil;
 }
 
 void
@@ -72,7 +72,7 @@
 		print("qlock: %#p: ilockdepth %d\n", getcallerpc(&q), m->ilockdepth);
 	if(up != nil && up->nlocks)
 		print("qlock: %#p: nlocks %d\n", getcallerpc(&q), up->nlocks);
-	if(up != nil && up->eql)
+	if(up != nil && up->eql != nil)
 		print("qlock: %#p: eql %p\n", getcallerpc(&q), up->eql);
 	if(q->use.key == 0x55555555)
 		panic("qlock: q %#p, key 5*", q);
@@ -83,17 +83,17 @@
 		unlock(&q->use);
 		return;
 	}
-	if(up == 0)
+	if(up == nil)
 		panic("qlock");
 	rwstats.qlockq++;
 	p = q->tail;
-	if(p == 0)
+	if(p == nil)
 		q->head = up;
 	else
 		p->qnext = up;
 	q->tail = up;
-	up->eql = 0;
-	up->qnext = 0;
+	up->eql = nil;
+	up->qnext = nil;
 	up->state = Queueing;
 	up->qpc = getcallerpc(&q);
 	unlock(&q->use);
@@ -124,10 +124,10 @@
 		print("qunlock called with qlock not held, from %#p\n",
 			getcallerpc(&q));
 	p = q->head;
-	if(p){
+	if(p != nil){
 		q->head = p->qnext;
-		if(q->head == 0)
-			q->tail = 0;
+		if(q->head == nil)
+			q->tail = nil;
 		unlock(&q->use);
 		ready(p);
 		return;
@@ -154,12 +154,12 @@
 	p = q->tail;
 	if(up == nil)
 		panic("rlock");
-	if(p == 0)
+	if(p == nil)
 		q->head = up;
 	else
 		p->qnext = up;
 	q->tail = up;
-	up->qnext = 0;
+	up->qnext = nil;
 	up->state = QueueingR;
 	unlock(&q->use);
 	sched();
@@ -181,8 +181,8 @@
 	if(p->state != QueueingW)
 		panic("runlock");
 	q->head = p->qnext;
-	if(q->head == 0)
-		q->tail = 0;
+	if(q->head == nil)
+		q->tail = nil;
 	q->writer = 1;
 	unlock(&q->use);
 	ready(p);
@@ -214,7 +214,7 @@
 	else
 		p->qnext = up;
 	q->tail = up;
-	up->qnext = 0;
+	up->qnext = nil;
 	up->state = QueueingW;
 	unlock(&q->use);
 	sched();