From 332dd434f1ce090652a94011a434fe61774cb61f Mon Sep 17 00:00:00 2001 From: diamant3 Date: Fri, 14 Oct 2022 22:17:02 +0800 Subject: [PATCH 1/3] fix restrict warning --- src/debug/pspdebugkb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/debug/pspdebugkb.c b/src/debug/pspdebugkb.c index facf6e6f..226367f3 100644 --- a/src/debug/pspdebugkb.c +++ b/src/debug/pspdebugkb.c @@ -251,8 +251,9 @@ void pspDebugKbInit(char* str) { break; case 1: // Space if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - snprintf(str, strlen(str)+2, "%s ", str); - pspDebugKbDrawString(str); + char out[PSP_DEBUG_KB_MAXLEN] = {0}; + snprintf(out, strlen(str), "%s ", str); + pspDebugKbDrawString(out); } break; case 2: // Back @@ -272,8 +273,9 @@ void pspDebugKbInit(char* str) { }; } else { if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - snprintf(str, strlen(str)+2, "%s%c", str, charTable[row][col]); - pspDebugKbDrawString(str); + char out[PSP_DEBUG_KB_MAXLEN] = {0}; + snprintf(out, strlen(str), "%s%c", str, charTable[row][col]); + pspDebugKbDrawString(out); } } } From 3b6e10e82db005ad3de67c3017c18ccbc194d25f Mon Sep 17 00:00:00 2001 From: diamant3 Date: Sat, 15 Oct 2022 16:42:21 +0800 Subject: [PATCH 2/3] fix indentation --- src/debug/pspdebugkb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debug/pspdebugkb.c b/src/debug/pspdebugkb.c index 226367f3..737b3ea9 100644 --- a/src/debug/pspdebugkb.c +++ b/src/debug/pspdebugkb.c @@ -251,7 +251,7 @@ void pspDebugKbInit(char* str) { break; case 1: // Space if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - char out[PSP_DEBUG_KB_MAXLEN] = {0}; + char out[PSP_DEBUG_KB_MAXLEN] = {0}; snprintf(out, strlen(str), "%s ", str); pspDebugKbDrawString(out); } @@ -273,7 +273,7 @@ void pspDebugKbInit(char* str) { }; } else { if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - char out[PSP_DEBUG_KB_MAXLEN] = {0}; + char out[PSP_DEBUG_KB_MAXLEN] = {0}; snprintf(out, strlen(str), "%s%c", str, charTable[row][col]); pspDebugKbDrawString(out); } From 7ac03aeccbf2a7b778eb1d4f960efe1cd575551a Mon Sep 17 00:00:00 2001 From: diamant3 Date: Sun, 16 Oct 2022 23:58:42 +0800 Subject: [PATCH 3/3] fix restrict warning --- src/debug/pspdebugkb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debug/pspdebugkb.c b/src/debug/pspdebugkb.c index 737b3ea9..dc0cd7e4 100644 --- a/src/debug/pspdebugkb.c +++ b/src/debug/pspdebugkb.c @@ -251,8 +251,8 @@ void pspDebugKbInit(char* str) { break; case 1: // Space if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - char out[PSP_DEBUG_KB_MAXLEN] = {0}; - snprintf(out, strlen(str), "%s ", str); + char out[PSP_DEBUG_KB_MAXLEN + 2]; + snprintf(out, sizeof(out), "%s ", str); pspDebugKbDrawString(out); } break; @@ -273,8 +273,8 @@ void pspDebugKbInit(char* str) { }; } else { if (strlen(str) < PSP_DEBUG_KB_MAXLEN) { - char out[PSP_DEBUG_KB_MAXLEN] = {0}; - snprintf(out, strlen(str), "%s%c", str, charTable[row][col]); + char out[PSP_DEBUG_KB_MAXLEN + 2]; + snprintf(out, sizeof(out), "%s%c", str, charTable[row][col]); pspDebugKbDrawString(out); } }