From 403c1ad6a97c297bd45b2eb8f84bc8b0534f3467 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 14 Oct 2014 22:57:02 +0200 Subject: [PATCH] fix errors and warnings that clang reports. --- src/gmtool.c | 2 +- src/kernel/config.c | 4 ++-- src/kernel/jsonconf.c | 6 +++--- src/kernel/messages.c | 4 ++-- src/move.c | 2 +- src/spy.c | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gmtool.c b/src/gmtool.c index c0d72895d..7008c1136 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -1108,7 +1108,7 @@ static void handlekey(state * st, int c) strcpy(kbuffer, "getch:"); } sprintf(sbuffer, " 0x%x", c); - strncat(kbuffer, sbuffer, sizeof(kbuffer)); + strncat(kbuffer, sbuffer, sizeof(kbuffer)-1); statusline(st->wnd_status->handle, kbuffer); if (strlen(kbuffer) > 70) kbuffer[0] = 0; diff --git a/src/kernel/config.c b/src/kernel/config.c index 02f0a0dde..7bffa0bbf 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -572,7 +572,7 @@ void verify_data(void) int mage, alchemist; if (verbosity >= 1) - puts(" - Überprüfe Daten auf Korrektheit..."); + puts(" - checking data for correctness..."); for (f = factions; f; f = f->next) { mage = 0; @@ -960,7 +960,7 @@ const char *strcheck(const char *s, size_t maxlen) static char buffer[16 * 1024]; // FIXME: static return value if (strlen(s) > maxlen) { assert(maxlen < 16 * 1024); - log_warning("[strcheck] String wurde auf %d Zeichen verkürzt:\n%s\n", (int)maxlen, s); + log_warning("[strcheck] string was shortened to %d bytes:\n%s\n", (int)maxlen, s); strlcpy(buffer, s, maxlen); return buffer; } diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 3557992b9..d8a0e59e6 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -496,7 +496,7 @@ static void json_strings(cJSON *json) { return; } for (child=json->child;child;child=child->next) { - if ((child->type==cJSON_Object)) { + if (child->type==cJSON_Object) { struct locale *lang = get_or_create_locale(child->string); json_locale(child, lang); } else { @@ -558,7 +558,7 @@ static void json_skill(cJSON *json, struct locale *lang) { cJSON *entry; for (entry=child->child;entry;entry=entry->next) { init_skill(lang, sk, entry->valuestring); - if ((entry==child->child)) { + if (entry==child->child) { locale_setstring(lang, mkname("skill", skillnames[sk]), entry->valuestring); } } @@ -588,7 +588,7 @@ static void json_keyword(cJSON *json, struct locale *lang) { cJSON *entry; for (entry=child->child;entry;entry=entry->next) { init_keyword(lang, kwd, entry->valuestring); - if ((entry==child->child)) { + if (entry==child->child) { locale_setstring(lang, mkname("keyword", keywords[kwd]), entry->valuestring); } } diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 086ec2134..654916971 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -208,7 +208,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) m = add_message(&f->msgs, msg_message("msg_economy", "string", s)); break; case MSG_BATTLE: - assert(0 || !"battle-meldungen nicht über addmessage machen"); + assert(0 || !"battle messages must not use addmessage"); break; case MSG_MOVE: assert(f); @@ -240,7 +240,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) } break; default: - assert(!"Ungültige Msg-Klasse!"); + assert(!"invalid message class"); } if (m) msg_release(m); diff --git a/src/move.c b/src/move.c index 32d325304..2505b6449 100644 --- a/src/move.c +++ b/src/move.c @@ -917,7 +917,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD))) guard_count = guard_count - u->number; else if (sk >= stealth) { - guard_count =+ u->number; + guard_count += u->number; double prob_u = (sk - stealth) * skill_prob; /* amulet counts at most once */ prob_u += _min (1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; diff --git a/src/spy.c b/src/spy.c index 2320e7cb8..4648b529b 100644 --- a/src/spy.c +++ b/src/spy.c @@ -93,13 +93,13 @@ void spy_message(int spy, const unit * u, const unit * target) if (first == 1) { first = 0; } else { - strncat(buf, ", ", sizeof(buf)); + strncat(buf, ", ", sizeof(buf)-1); } strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale), - sizeof(buf)); - strncat(buf, " ", sizeof(buf)); + sizeof(buf)-1); + strncat(buf, " ", sizeof(buf)-1); strncat(buf, itoa10(eff_skill(target, (skill_t)sv->id, target->region)), - sizeof(buf)); + sizeof(buf)-1); } } if (found) {