diff --git a/src/util/virkeycode-mapgen.py b/src/util/virkeycode-mapgen.py index 22b21b4753..8360bfe525 100755 --- a/src/util/virkeycode-mapgen.py +++ b/src/util/virkeycode-mapgen.py @@ -86,12 +86,12 @@ for i in range(len(cols)): if isname: print "const char *virKeymapNames_" + name + "[] = {" else: - print "unsigned short virKeymapValues_" + name + "[] = {" + print "int virKeymapValues_" + name + "[] = {" for entry in keycodes: if isname: print " " + quotestring(entry[i] or "NULL") + "," else: - print " " + (entry[i] or "0") + "," + print " " + (entry[i] or "-1") + "," print "};\n" diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c index 50594d6580..7880a0aba2 100644 --- a/src/util/virkeycode.c +++ b/src/util/virkeycode.c @@ -50,7 +50,7 @@ static const char **virKeymapNames[] = { }; verify(ARRAY_CARDINALITY(virKeymapNames) == VIR_KEYCODE_SET_LAST); -static unsigned short *virKeymapValues[] = { +static int *virKeymapValues[] = { [VIR_KEYCODE_SET_LINUX] = virKeymapValues_linux, [VIR_KEYCODE_SET_XT] = @@ -113,7 +113,7 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset, { size_t i; - if (key_value <= 0) + if (key_value < 0) return -1; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 760dca598c..3aabd26af1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7049,7 +7049,7 @@ vshKeyCodeGetInt(const char *key_name) { unsigned int val; - if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff || !val) + if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff) return -1; return val; } @@ -7090,8 +7090,8 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if ((keycode = vshKeyCodeGetInt(opt->data)) <= 0) { - if ((keycode = virKeycodeValueFromString(codeset, opt->data)) <= 0) { + if ((keycode = vshKeyCodeGetInt(opt->data)) < 0) { + if ((keycode = virKeycodeValueFromString(codeset, opt->data)) < 0) { vshError(ctl, _("invalid keycode: '%s'"), opt->data); goto cleanup; }