From c298b7fd741be163ac2f815923496dc7bb4a538a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 29 Oct 2015 11:06:25 +0100 Subject: [PATCH] coverity CID 22501 imroper use of negative value explicitly use SK_MAGIC instead of a lookup. Faster, easier to reason about. --- src/kernel/item.c | 2 +- src/skill.test.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index ba6504746..63ba87a53 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -925,7 +925,7 @@ struct order *ord) user->number); 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", "unit item", user, itype->rtype)); diff --git a/src/skill.test.c b/src/skill.test.c index 451f95d7c..248228a53 100644 --- a/src/skill.test.c +++ b/src/skill.test.c @@ -29,6 +29,7 @@ static void test_init_skill(CuTest *tc) { static void test_get_skill(CuTest *tc) { test_cleanup(); CuAssertIntEquals(tc, SK_ALCHEMY, findskill("alchemy")); + CuAssertIntEquals(tc, SK_MAGIC, findskill("magic")); CuAssertIntEquals(tc, SK_CROSSBOW, findskill("crossbow")); CuAssertIntEquals(tc, NOSKILL, findskill("")); CuAssertIntEquals(tc, NOSKILL, findskill("potato"));