It doesn't make sense to set kgdb_may_fault before setting up the jump buffer,
so move kgdb_set_may_fault() calls to where the buffer is known to be set up
and get rid of kgdb_unset_may_fault() calls in the error return paths.
Clean up grammar and style in some comments, while at it...

Signed-off-by: Sergei Shtylyov <[EMAIL PROTECTED]>

---
Comments needed some more fixing than had been initially noticed.
This cleanup is against the linux_2_6_21_uprev branch as usual...

 kernel/kgdb.c |   46 +++++++++++++++++++++-------------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

Index: linux-2.6/kernel/kgdb.c
===================================================================
--- linux-2.6.orig/kernel/kgdb.c
+++ linux-2.6/kernel/kgdb.c
@@ -303,17 +303,17 @@ static void put_packet(char *buffer)
 }
 
 /*
- * convert the memory pointed to by mem into hex, placing result in buf
- * return a pointer to the last char put in buf (null). May return an error.
+ * Convert the memory pointed to by mem into hex, placing result in buf.
+ * Return a pointer to the last char put in buf (null). May return an error.
  */
 char *kgdb_mem2hex(char *mem, char *buf, int count)
 {
-       kgdb_set_may_fault();
-       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
-               kgdb_unset_may_fault();
+       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
                return ERR_PTR(-EINVAL);
-       }
-       /* Accessing some registers in a single load instruction is
+
+       kgdb_set_may_fault();
+       /*
+        * Accessing some registers in a single load instruction is
         * required to avoid bad side effects for some I/O registers.
         */
        if ((count == 2) && (((long)mem & 1) == 0)) {
@@ -411,11 +411,10 @@ char *kgdb_mem2hex(char *mem, char *buf,
  */
 static char *kgdb_ebin2mem(char *buf, char *mem, int count)
 {
-       kgdb_set_may_fault();
-       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
-               kgdb_unset_may_fault();
+       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
                return ERR_PTR(-EINVAL);
-       }
+
+       kgdb_set_may_fault();
        for (; count > 0; count--, buf++) {
                if (*buf == 0x7d)
                        *mem++ = *(++buf) ^ 0x20;
@@ -427,17 +426,16 @@ static char *kgdb_ebin2mem(char *buf, ch
 }
 
 /*
- * convert the hex array pointed to by buf into binary to be placed in mem
- * return a pointer to the character AFTER the last byte written
+ * Convert the hex array pointed to by buf into binary to be placed in mem.
+ * Return a pointer to the character AFTER the last byte written.
  * May return an error.
  */
 char *kgdb_hex2mem(char *buf, char *mem, int count)
 {
-       kgdb_set_may_fault();
-       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
-               kgdb_unset_may_fault();
+       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
                return ERR_PTR(-EINVAL);
-       }
+
+       kgdb_set_may_fault();
        if ((count == 2) && (((long)mem & 1) == 0)) {
                unsigned short tmp_s = 0;
 #ifdef __BIG_ENDIAN
@@ -639,11 +637,10 @@ static void kgdb_wait(struct pt_regs *re
 
 int kgdb_get_mem(char *addr, unsigned char *buf, int count)
 {
-       kgdb_set_may_fault();
-       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
-               kgdb_unset_may_fault();
+       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
                return -EINVAL;
-       }
+
+       kgdb_set_may_fault();
        while (count) {
                if ((unsigned long)addr < TASK_SIZE) {
                        kgdb_unset_may_fault();
@@ -658,11 +655,10 @@ int kgdb_get_mem(char *addr, unsigned ch
 
 int kgdb_set_mem(char *addr, unsigned char *buf, int count)
 {
-       kgdb_set_may_fault();
-       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0) {
-               kgdb_unset_may_fault();
+       if ((kgdb_fault_setjmp(kgdb_fault_jmp_regs)) != 0)
                return -EINVAL;
-       }
+
+       kgdb_set_may_fault();
        while (count) {
                if ((unsigned long)addr < TASK_SIZE) {
                        kgdb_unset_may_fault();


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Kgdb-bugreport mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to