Add KEYMAP_INVALID value for enum keymap_id and properly check for it
commit6aa99fa078dd0f95f27cb08fb4679bc67bc28558
authorMiciah Dashiel Butler Masters <miciah@myrealbox.com>
Sun, 27 Jan 2008 18:47:20 +0000 (27 18:47 +0000)
committerMiciah Dashiel Butler Masters <miciah@myrealbox.com>
Sun, 27 Jan 2008 18:50:16 +0000 (27 18:50 +0000)
tree40a4b588417d0b8c0da7dd607df8b97677c7e837
parent7e0c0e14e27602e8530ad5ae336933e54920c540
Add KEYMAP_INVALID value for enum keymap_id and properly check for it

get_keymap_id returns -1 when it can't find the keymap.  Because the return
type of get_keymap_id is enum keymap_id and enum keymap_id did not have any
explicit values defined, it could be unsigned, which meant that when
get_keymap_id returned -1, it was really returning a huge positive number.
This meant that when callers checker whether the return value was negative,
they were essentially performing no check at all, so they might give
get_keymap_id an invalid keymap name, get back an invalid keymap_id, and
use that invalid keymap_id.

This commit adds KEYMAP_INVALID = -1 to enum keymap_id and makes all
functions that deal with the enumeration use that symbol.
src/config/kbdbind.c
src/config/kbdbind.h