lkml.org 
[lkml]   [2005]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 2/2] kernel/power/disk.c string fix and if-less iterator
From: Ricardo Nabinger Sanchez <rnsanchez@terra.com.br>



The attached patch:

o Fixes kernel/power/disk.c string declared as 'char *p = "...";' to be
declared as 'char p[] = "...";', as pointed by Jeff Garzik.

o Replaces:
i++:
if (i > 3) i = 0;
By:
i = (i + 1) % (sizeof(p) - 1);

Which is if-less, and the adjust value is evaluated by the compiler in
compile-time in case the string related to this loop is modified.


---
disk.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
Index: quilt/kernel/power/disk.c
===================================================================
--- quilt.orig/kernel/power/disk.c
+++ quilt/kernel/power/disk.c
@@ -91,15 +91,13 @@ static void free_some_memory(void)
unsigned int i = 0;
unsigned int tmp;
unsigned long pages = 0;
- char *p = "-\\|/";
+ char p[] = "-\\|/";

printk("Freeing memory... ");
while ((tmp = shrink_all_memory(10000))) {
pages += tmp;
printk("\b%c", p[i]);
- i++;
- if (i > 3)
- i = 0;
+ i = (i + 1) % (sizeof(p) - 1);
}
printk("\bdone (%li pages freed)\n", pages);
}
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-21 07:47    [from the cache]
©2003-2011 Jasper Spaans