[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] FreeMiNT kernel patch cleanups



This is a patch to clear up some mirrored local variables.

Alan.
Index: sys/block_IO.c
===================================================================
RCS file: /mint/freemint/sys/block_IO.c,v
retrieving revision 1.18
diff -u -r1.18 block_IO.c
--- sys/block_IO.c	13 Jul 2007 21:32:48 -0000	1.18
+++ sys/block_IO.c	18 Jun 2008 09:35:24 -0000
@@ -1215,10 +1215,10 @@
 
 	/* sector validation */
 	{
-		ulong n = size >> di->pshift;
+		ulong n1 = size >> di->pshift;
 		ulong recno = sector << di->lshift;
 
-		if (!n)
+		if (!n1)
 		{
 			BIO_ALERT (("block_IO [%c]: bio_unit_get n = 0 failure!", di->drv+'A'));
 
@@ -1226,7 +1226,7 @@
 			return NULL;
 		}
 
-		if (di->size && (recno + n) > di->size)
+		if (di->size && (recno + n1) > di->size)
 		{
 			BIO_ALERT (("block_IO [%c]: bio_unit_get: access outside partition", di->drv+'A'));
 
@@ -1501,7 +1501,7 @@
 	else
 	{
 		unsigned char *c = (unsigned char *) (blocks + cache.count + count);
-		long i;
+		ulong i;
 		for (i = 0; i < cache.count + count; i++)
 		{
 			if (i < cache.count)
@@ -1516,7 +1516,7 @@
 
 				/* initialize block */
 				{
-					long j;
+					ulong j;
 					for (j = 0; j < cache.chunks; j++)
 					{
 						(blocks [i]).active [j] = (cache.blocks [i]).active [j];
@@ -1541,7 +1541,7 @@
 
 				/* initialize block */
 				{
-					long j;
+					ulong j;
 					for (j = 0; j < cache.chunks; j++)
 					{
 						(blocks [i]).active [j] = NULL;
@@ -1582,7 +1582,7 @@
 	if (percentage < 0)
 		return (cache.percentage / (cache.count * cache.max_size));
 
-	if (percentage > 100UL)
+	if (percentage > 100L)
 		return EBADARG;
 
 	cache.percentage = cache.count * cache.max_size * percentage;
@@ -1753,8 +1753,10 @@
 
 		if (r == E_OK)
 		{
-			r = XHInqTarget2 (di->major, di->minor, &pssize, &flags, name, sizeof(name));
-			if (r) BIO_DEBUG (("bio_get_di: XHInqTarget2(%i,%i) failed (%li)", di->major, di->minor, r));
+			r = XHInqTarget2 (di->major, di->minor, &pssize, &flags, name, (ushort)sizeof(name));
+			if (r) {
+				BIO_DEBUG (("bio_get_di: XHInqTarget2(%i,%i) failed (%li)", di->major, di->minor, r));
+			}
 		}
 
 		if ((r == E_OK) && (di->start != 0xffffffffUL))
@@ -2238,7 +2240,7 @@
 {
 	register UNIT **table = di->table;
 	register ulong end = sector + (size >> di->p_l_shift);
-	register long i;
+	register ulong i;
 
 	BIO_DEBUG (("bio_large_write: entry (sector = %lu, drv = %u, size = %lu", sector, di->drv, size));
 
@@ -2496,7 +2498,7 @@
 	/* invalid all cache units for drv */
 
 	register UNIT **table = di->table;
-	register long i;
+	register ulong i;
 
 	BIO_DEBUG (("bio_invalidate: entry (di->drv = %i)", di->drv));
 	BIO_ASSERT ((table));
@@ -2714,12 +2716,12 @@
 	if (!ret)
 	{
 		CBL *b = cache.blocks;
-		long i;
+		ulong i;
 
 		for (i = 0; i < NUM_DRIVES; i++)
 		{
 			register UNIT **table = bio_di [i].table;
-			register long j;
+			register ulong j;
 
 			if (table)
 			{
@@ -2746,7 +2748,7 @@
 		(*fp->dev->write)(fp, buf, strlen (buf));
 		for (i = 0; i < cache.count; i++)
 		{
-			long j;
+			ulong j;
 			ksprintf (buf, buflen, "buffer = %lx, buffer->stat = %lu, lock = %u, free = %u\r\n", b[i].data, b[i].stat, b[i].lock, b[i].free);
 			(*fp->dev->write)(fp, buf, strlen (buf));
 			for (j = 0; j < cache.chunks; j++)
Index: sys/dosfile.c
===================================================================
RCS file: /mint/freemint/sys/dosfile.c,v
retrieving revision 1.28
diff -u -r1.28 dosfile.c
--- sys/dosfile.c	13 Jul 2007 21:32:48 -0000	1.28
+++ sys/dosfile.c	18 Jun 2008 09:35:25 -0000
@@ -50,7 +50,7 @@
 	struct proc *p = get_curproc();
 	FILEPTR *fp = NULL;
 	short fd = MIN_OPEN - 1;
-	int global = 0;
+	int _global = 0;
 	long ret;
 
 	TRACE (("Fopen(%s, %x)", name, mode));
@@ -74,7 +74,7 @@
 		ALERT (MSG_global_handle, name);
 
 		p = rootproc;
-		global = 1;
+		_global = 1;
 	}
 # endif
 
@@ -102,7 +102,7 @@
 	FP_DONE (p, fp, fd, FD_CLOEXEC);
 
 # if O_GLOBAL
-	if (global)
+	if (_global)
 		/* we just opened a global handle */
 		fd += 100;
 # endif
@@ -480,7 +482,7 @@
 # ifdef OLDSOCKDEVEMU
 	if (f->dev == &sockdev || f->dev == &sockdevemu)
 # else
-	if (f->dev == &sockdev
+	if (f->dev == &sockdev)
 # endif
 		return so_fstat_old (f, xattr);
 
@@ -512,7 +514,7 @@
 # ifdef OLDSOCKDEVEMU
 	if (f->dev == &sockdev || f->dev == &sockdevemu)
 # else
-	if (f->dev == &sockdev
+	if (f->dev == &sockdev)
 # endif
 		return so_fstat (f, st);
 
@@ -1209,7 +1217,7 @@
 /*
  * GEMDOS extension: Fpoll (fds, nfds, timeout)
  *
- * - new Fselect() call for more than 32 filedeskriptors
+ * - new Fselect() call for more than 32 filedescriptors
  * - at the moment only a wrapper around Fselect()
  */
 
@@ -1330,7 +1338,7 @@
 	}
 
 	{
-		char *p, *_p;
+		char *pt, *_p;
 		long size;
 		int i;
 
@@ -1341,13 +1349,13 @@
 		/* if (size == 0)
 			return 0; */
 
-		p = _p = kmalloc (size);
-		if (!p) return ENOMEM;
+		pt = _p = kmalloc (size);
+		if (!pt) return ENOMEM;
 
 		for (i = 0; i < niov; ++i)
 		{
-			memcpy (p, iov[i].iov_base, iov[i].iov_len);
-			p += iov[i].iov_len;
+			memcpy (pt, iov[i].iov_base, iov[i].iov_len);
+			pt += iov[i].iov_len;
 		}
 
 		if (is_terminal (f))
@@ -1386,7 +1394,7 @@
 # ifdef OLDSOCKDEVEMU
 	if (f->dev == &sockdev || f->dev == &sockdevemu)
 # else
-	if (f->dev == &sockdev
+	if (f->dev == &sockdev)
 # endif
 	{
 		struct socket *so = (struct socket *) f->devinfo;
@@ -1395,7 +1403,7 @@
 	}
 
 	{
-		char *p, *_p;
+		char *pt, *_p;
 		long size;
 		int i;
 
@@ -1406,17 +1414,17 @@
 		/* if (size == 0)
 			return 0; */
 
-		p = _p = kmalloc (size);
-		if (!p) return ENOMEM;
+		pt = _p = kmalloc (size);
+		if (!pt) return ENOMEM;
 
 		if (is_terminal (f))
-			r = tty_read (f, p, size);
+			r = tty_read (f, pt, size);
 		else
-			r = xdd_read (f, p, size);
+			r = xdd_read (f, pt, size);
 
 		if (r <= 0)
 		{
-			kfree (p);
+			kfree (pt);
 			return r;
 		}
 
@@ -1425,9 +1433,9 @@
 			register long copy;
 
 			copy = size > iov[i].iov_len ? iov[i].iov_len : size;
-			memcpy (iov[i].iov_base, p, copy);
+			memcpy (iov[i].iov_base, pt, copy);
 
-			p += copy;
+			pt += copy;
 			size -= copy;
 		}