From f7f9e4590a75d629b3ca65887b6e477a72ba39b7 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 22 Oct 2022 12:01:47 -0700 Subject: eventTypeToString: remove unnecessary strcpy to static buffer Since the results are just passed to fprintf(), we can just return a pointer to the string constants directly. Signed-off-by: Alan Coopersmith --- printev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/printev.c b/printev.c index b556835..fc20356 100644 --- a/printev.c +++ b/printev.c @@ -32,23 +32,20 @@ #define Unknown "unknown" #define ynText(v) ((v)?Yes:No) -static char * +static const char * eventTypeToString(int evType) { - static char name[20]; - switch (evType) { case KeyPress: - strcpy(name, "KeyPress"); + return "KeyPress"; break; case KeyRelease: - strcpy(name, "KeyRelease"); + return "KeyRelease"; break; default: - strcpy(name, "unknown"); + return "unknown"; break; } - return name; } static void -- cgit v1.2.3