kdb: Replace double memcpy() with memmove() in kdb_read()
[linux-2.6-block.git] / kernel / debug / kdb / kdb_io.c
index 2aeaf9765b248fb8ab24ebbc84987d5fd3513a4b..40617f36a6db483a3c23b389922e083d063468de 100644 (file)
@@ -269,12 +269,9 @@ poll_again:
        switch (key) {
        case 8: /* backspace */
                if (cp > buffer) {
-                       if (cp < lastchar) {
-                               memcpy(tmpbuffer, cp, lastchar - cp);
-                               memcpy(cp-1, tmpbuffer, lastchar - cp);
-                       }
-                       *(--lastchar) = '\0';
-                       --cp;
+                       memmove(cp-1, cp, lastchar - cp + 1);
+                       lastchar--;
+                       cp--;
                        kdb_printf("\b%s ", cp);
                        kdb_position_cursor(kdb_prompt_str, buffer, cp);
                }
@@ -291,9 +288,8 @@ poll_again:
                return buffer;
        case 4: /* Del */
                if (cp < lastchar) {
-                       memcpy(tmpbuffer, cp+1, lastchar - cp - 1);
-                       memcpy(cp, tmpbuffer, lastchar - cp - 1);
-                       *(--lastchar) = '\0';
+                       memmove(cp, cp+1, lastchar - cp);
+                       lastchar--;
                        kdb_printf("%s ", cp);
                        kdb_position_cursor(kdb_prompt_str, buffer, cp);
                }
@@ -398,9 +394,8 @@ poll_again:
        default:
                if (key >= 32 && lastchar < bufend) {
                        if (cp < lastchar) {
-                               memcpy(tmpbuffer, cp, lastchar - cp);
-                               memcpy(cp+1, tmpbuffer, lastchar - cp);
-                               *++lastchar = '\0';
+                               memmove(cp+1, cp, lastchar - cp + 1);
+                               lastchar++;
                                *cp = key;
                                kdb_printf("%s", cp);
                                ++cp;