aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-09-26 02:33:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:49:05 -0400
commit91b165c0594ab78c64f26d26e3174e6dfd60ed9d (patch)
tree0730eefa9d4ce786f7f561e3b40700418d6d0970 /arch/um/sys-i386
parent13c06be399902c9ebda08e092edb1614bb4a3761 (diff)
[PATCH] uml: Use ARRAY_SIZE more assiduously
There were a bunch of missed ARRAY_SIZE opportunities. Also, some formatting fixes in the affected areas of code. Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/sys-i386')
-rw-r--r--arch/um/sys-i386/bugs.c9
-rw-r--r--arch/um/sys-i386/ldt.c3
-rw-r--r--arch/um/sys-i386/ptrace_user.c5
3 files changed, 9 insertions, 8 deletions
diff --git a/arch/um/sys-i386/bugs.c b/arch/um/sys-i386/bugs.c
index 41b0ab2fe830..f1bcd399ac90 100644
--- a/arch/um/sys-i386/bugs.c
+++ b/arch/um/sys-i386/bugs.c
@@ -13,6 +13,7 @@
13#include "sysdep/ptrace.h" 13#include "sysdep/ptrace.h"
14#include "task.h" 14#include "task.h"
15#include "os.h" 15#include "os.h"
16#include "user_util.h"
16 17
17#define MAXTOKEN 64 18#define MAXTOKEN 64
18 19
@@ -104,17 +105,17 @@ int cpu_feature(char *what, char *buf, int len)
104static int check_cpu_flag(char *feature, int *have_it) 105static int check_cpu_flag(char *feature, int *have_it)
105{ 106{
106 char buf[MAXTOKEN], c; 107 char buf[MAXTOKEN], c;
107 int fd, len = sizeof(buf)/sizeof(buf[0]); 108 int fd, len = ARRAY_SIZE(buf);
108 109
109 printk("Checking for host processor %s support...", feature); 110 printk("Checking for host processor %s support...", feature);
110 fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0); 111 fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0);
111 if(fd < 0){ 112 if(fd < 0){
112 printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd); 113 printk("Couldn't open /proc/cpuinfo, err = %d\n", -fd);
113 return(0); 114 return 0;
114 } 115 }
115 116
116 *have_it = 0; 117 *have_it = 0;
117 if(!find_cpuinfo_line(fd, "flags", buf, sizeof(buf) / sizeof(buf[0]))) 118 if(!find_cpuinfo_line(fd, "flags", buf, ARRAY_SIZE(buf)))
118 goto out; 119 goto out;
119 120
120 c = token(fd, buf, len - 1, ' '); 121 c = token(fd, buf, len - 1, ' ');
@@ -138,7 +139,7 @@ static int check_cpu_flag(char *feature, int *have_it)
138 if(*have_it == 0) printk("No\n"); 139 if(*have_it == 0) printk("No\n");
139 else if(*have_it == 1) printk("Yes\n"); 140 else if(*have_it == 1) printk("Yes\n");
140 os_close_file(fd); 141 os_close_file(fd);
141 return(1); 142 return 1;
142} 143}
143 144
144#if 0 /* This doesn't work in tt mode, plus it's causing compilation problems 145#if 0 /* This doesn't work in tt mode, plus it's causing compilation problems
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index fe0877b3509c..69971b78beaf 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -424,9 +424,8 @@ void ldt_get_host_info(void)
424 size++; 424 size++;
425 } 425 }
426 426
427 if(size < sizeof(dummy_list)/sizeof(dummy_list[0])) { 427 if(size < ARRAY_SIZE(dummy_list))
428 host_ldt_entries = dummy_list; 428 host_ldt_entries = dummy_list;
429 }
430 else { 429 else {
431 size = (size + 1) * sizeof(dummy_list[0]); 430 size = (size + 1) * sizeof(dummy_list[0]);
432 host_ldt_entries = (short *)kmalloc(size, GFP_KERNEL); 431 host_ldt_entries = (short *)kmalloc(size, GFP_KERNEL);
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 40aa88531446..5f3cc6685820 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -15,6 +15,7 @@
15#include "user.h" 15#include "user.h"
16#include "os.h" 16#include "os.h"
17#include "uml-config.h" 17#include "uml-config.h"
18#include "user_util.h"
18 19
19int ptrace_getregs(long pid, unsigned long *regs_out) 20int ptrace_getregs(long pid, unsigned long *regs_out)
20{ 21{
@@ -51,7 +52,7 @@ static void write_debugregs(int pid, unsigned long *regs)
51 int nregs, i; 52 int nregs, i;
52 53
53 dummy = NULL; 54 dummy = NULL;
54 nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]); 55 nregs = ARRAY_SIZE(dummy->u_debugreg);
55 for(i = 0; i < nregs; i++){ 56 for(i = 0; i < nregs; i++){
56 if((i == 4) || (i == 5)) continue; 57 if((i == 4) || (i == 5)) continue;
57 if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i], 58 if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
@@ -68,7 +69,7 @@ static void read_debugregs(int pid, unsigned long *regs)
68 int nregs, i; 69 int nregs, i;
69 70
70 dummy = NULL; 71 dummy = NULL;
71 nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]); 72 nregs = ARRAY_SIZE(dummy->u_debugreg);
72 for(i = 0; i < nregs; i++){ 73 for(i = 0; i < nregs; i++){
73 regs[i] = ptrace(PTRACE_PEEKUSR, pid, 74 regs[i] = ptrace(PTRACE_PEEKUSR, pid,
74 &dummy->u_debugreg[i], 0); 75 &dummy->u_debugreg[i], 0);