home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Test return values of _all_ *printf() calls.
[plomrogue]
/
src
/
client
/
keybindings.c
diff --git
a/src/client/keybindings.c
b/src/client/keybindings.c
index 4231da492531cf8a832f5e5bc817a8427e724682..b0b7c7a06fc496ee5cb9baa5cd5af8c70632d14a 100644
(file)
--- a/
src/client/keybindings.c
+++ b/
src/client/keybindings.c
@@
-5,6
+5,7
@@
#include <stddef.h> /* NULL */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdio.h> /* FILE, sprintf() */
#include <stddef.h> /* NULL */
#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
#include <stdio.h> /* FILE, sprintf() */
+#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "windows.h" /* draw_all_wins() */
#include "world.h" /* global world */
#include "../common/try_malloc.h" /* try_malloc() */
#include "windows.h" /* draw_all_wins() */
#include "world.h" /* global world */
@@
-49,9
+50,11
@@
static struct KeyBindingDB * char_selected_kb_db(char c)
static uint8_t try_keycode(uint16_t keycode_given, char * keyname,
uint16_t keycode_match, char * keyname_match)
{
static uint8_t try_keycode(uint16_t keycode_given, char * keyname,
uint16_t keycode_match, char * keyname_match)
{
+ char * f_name = "try_keycode()";
if (keycode_given == keycode_match)
{
if (keycode_given == keycode_match)
{
- sprintf(keyname, "%s", keyname_match);
+ int test = sprintf(keyname, "%s", keyname_match);
+ exit_trouble(test < 0, f_name, "sprintf()");
return 1;
}
return 0;
return 1;
}
return 0;
@@
-81,12
+84,12
@@
extern char * get_keyname_to_keycode(uint16_t keycode)
char * keyname = try_malloc(10, f_name); /* max keyname length + 1 */
if (32 < keycode && keycode < 127)
{
char * keyname = try_malloc(10, f_name); /* max keyname length + 1 */
if (32 < keycode && keycode < 127)
{
-
sprintf(keyname, "%c", keycode
);
+
exit_trouble(sprintf(keyname, "%c", keycode) < 0, f_name, "sprintf()"
);
}
else if (keycode >= KEY_F0 && keycode <= KEY_F(63))
{
uint16_t f = keycode - KEY_F0;
}
else if (keycode >= KEY_F0 && keycode <= KEY_F(63))
{
uint16_t f = keycode - KEY_F0;
-
sprintf(keyname, "F%d", f)
;
+
exit_trouble(sprintf(keyname, "F%d", f) < 0, f_name, "sprintf()");
;
}
else if ( try_keycode(keycode, keyname, 9, "TAB")
|| try_keycode(keycode, keyname, 10, "RETURN")
}
else if ( try_keycode(keycode, keyname, 9, "TAB")
|| try_keycode(keycode, keyname, 10, "RETURN")
@@
-108,7
+111,7
@@
extern char * get_keyname_to_keycode(uint16_t keycode)
}
else
{
}
else
{
-
sprintf(keyname, "(unknown
)");
+
exit_trouble(sprintf(keyname, "(unknown)") < 0, f_name, "sprintf(
)");
}
return keyname;
}
}
return keyname;
}