Discussion:
[PATCH] return same error value from spk_set_key_info
Samuel Thibault
2017-02-21 12:24:07 UTC
Permalink
Retain the previous error values as debug messages
instead.
Well, they are not really useful because they are actually undocumented.
+ if (version != KEY_MAP_VER) {
+ pr_debug("Version mismatch %d\n", -1);
Rather print version and KEY_MAP_VER
+ if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) {
+ pr_debug("Data len and Shift table too big %d\n", -2);
Rather print key_data_len + SHIFT_TBL_SIZE + 4 and sizeof(spk_key_buf)
+ if (ch >= SHIFT_TBL_SIZE) {
+ pr_debug("Key table size overflow %d\n", -3);
Rather print ch and SHIFT_TBL_SIZE.
+ if (ch >= MAX_KEY) {
+ pr_debug("Max Key overflow %d\n", -4);
Rather print ch and MAX_KEY.

Apart from that, returning -EINVAL instead of different values is fine
for me.

Samuel
Samuel Thibault
2017-02-21 13:54:12 UTC
Permalink
+ if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) {
+ pr_debug("key_data_len = %d, SHIFT_TBL_SIZE + 4 = %d,\t"
+ "sizeof(spk_key_buf) = %lu\n", key_data_len,
+ SHIFT_TBL_SIZE + 4, sizeof(spk_key_buf));
Well, that's very technical, and not useful to an actual user :)
Rather print
"too many key infos (%d bytes over %d)",
key_data_len + SHIFT_TBL_SIZE + 4,
sizeof(spk_key_buf)
+ if (ch >= SHIFT_TBL_SIZE) {
+ pr_debug("ch = %d, SHIFT_TBL_SIZE = %d\n", ch,
+ SHIFT_TBL_SIZE);
similarly, rather
"ch %d is not a valid shift state (maximum %d)", ch, SHIFT_TBL_SIZE
+ if (ch >= MAX_KEY) {
+ pr_debug("ch = %d, MAX_KEY = %d\n", ch, MAX_KEY);
and
"ch %d is not a valid keycode (maximum %d)", ch, MAX_KEY

Samuel

Loading...