coverity CID 22501 imroper use of negative value

explicitly use SK_MAGIC instead of a lookup. Faster, easier to reason about.
This commit is contained in:
Enno Rehling 2015-10-29 11:06:25 +01:00
parent 8675002e68
commit c298b7fd74
2 changed files with 2 additions and 1 deletions

View File

@ -925,7 +925,7 @@ struct order *ord)
user->number); user->number);
a_add(&f->attribs, make_key(atoi36("mbst"))); a_add(&f->attribs, make_key(atoi36("mbst")));
set_level(user, findskill("magic"), 3); set_level(user, SK_MAGIC, 3);
ADDMSG(&user->faction->msgs, msg_message("use_item", ADDMSG(&user->faction->msgs, msg_message("use_item",
"unit item", user, itype->rtype)); "unit item", user, itype->rtype));

View File

@ -29,6 +29,7 @@ static void test_init_skill(CuTest *tc) {
static void test_get_skill(CuTest *tc) { static void test_get_skill(CuTest *tc) {
test_cleanup(); test_cleanup();
CuAssertIntEquals(tc, SK_ALCHEMY, findskill("alchemy")); CuAssertIntEquals(tc, SK_ALCHEMY, findskill("alchemy"));
CuAssertIntEquals(tc, SK_MAGIC, findskill("magic"));
CuAssertIntEquals(tc, SK_CROSSBOW, findskill("crossbow")); CuAssertIntEquals(tc, SK_CROSSBOW, findskill("crossbow"));
CuAssertIntEquals(tc, NOSKILL, findskill("")); CuAssertIntEquals(tc, NOSKILL, findskill(""));
CuAssertIntEquals(tc, NOSKILL, findskill("potato")); CuAssertIntEquals(tc, NOSKILL, findskill("potato"));