From: Andre Noll Date: Sun, 25 Jun 2023 12:29:07 +0000 (+0200) Subject: play: Simplify and improve get_key_map_seq(). X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=2dc14c23297a9fd3225ccf0a1e7c37596949db83;p=paraslash.git play: Simplify and improve get_key_map_seq(). Combine it with get_user_key_map_seq() and replace the NULL check with an assertion since the condition can never be true here. This makes gcc's static analyzer happy, which complained about a possible NULL pointer dereference. --- diff --git a/play.c b/play.c index 29dc1317..fa1c7ef5 100644 --- a/play.c +++ b/play.c @@ -570,14 +570,17 @@ static inline char *get_internal_key_map_seq(int key) return para_strdup(default_keyseqs[get_internal_key_map_idx(key)]); } -static char *get_user_key_map_seq(int key) +static char *get_key_map_seq(int key) { - const char *kma = get_user_key_map_arg(key); - const char *p = strchr(kma + 1, ':'); + const char *kma, *p; char *result; int len; - assert(p); + if (is_internal_key(key)) + return get_internal_key_map_seq(key); + kma = get_user_key_map_arg(key); + p = strchr(kma + 1, ':'); + assert(p); /* We checked earlier that kma contains a colon */ len = p - kma; result = alloc(len + 1); memcpy(result, kma, len); @@ -585,12 +588,6 @@ static char *get_user_key_map_seq(int key) return result; } -static char *get_key_map_seq(int key) -{ - return is_internal_key(key)? - get_internal_key_map_seq(key) : get_user_key_map_seq(key); -} - static char *get_key_map_seq_safe(int key) { const char hex[] = "0123456789abcdef";