coverity warning: NEGATIVE_RETURNS

This commit is contained in:
Enno Rehling 2016-11-14 02:21:49 +01:00
parent 03a94d1264
commit 5e48eac26a
4 changed files with 8 additions and 3 deletions

View File

@ -144,7 +144,7 @@ typedef enum {
P_TREES,
P_ALLIANCE,
MAXPARAMS,
NOPARAM = -1
NOPARAM
} param_t;
typedef enum { /* Fehler und Meldungen im Report */

View File

@ -14,6 +14,9 @@
const char * keyword(keyword_t kwd)
{
static char result[32]; // FIXME: static return value
if (kwd==NOKEYWORD) {
return NULL;
}
if (!result[0]) {
strcpy(result, "keyword::");
}

View File

@ -70,7 +70,7 @@ extern "C"
K_PAY,
K_LOOT,
MAXKEYWORDS,
NOKEYWORD = -1
NOKEYWORD
} keyword_t;
extern const char *keywords[MAXKEYWORDS];

View File

@ -11,11 +11,13 @@
static void test_init_keywords(CuTest *tc) {
struct locale *lang;
test_cleanup();
test_setup();
lang = get_or_create_locale("en");
locale_setstring(lang, "keyword::move", "MOVE");
init_keywords(lang);
CuAssertIntEquals(tc, K_MOVE, get_keyword("move", lang));
CuAssertStrEquals(tc, "keyword::move", keyword(K_MOVE));
CuAssertPtrEquals(tc, NULL, (void *)keyword(NOKEYWORD));
test_cleanup();
}