fix errors and warnings that clang reports.

This commit is contained in:
Enno Rehling 2014-10-14 22:57:02 +02:00
parent 7987b82c62
commit 403c1ad6a9
6 changed files with 13 additions and 13 deletions

View File

@ -1108,7 +1108,7 @@ static void handlekey(state * st, int c)
strcpy(kbuffer, "getch:"); strcpy(kbuffer, "getch:");
} }
sprintf(sbuffer, " 0x%x", c); sprintf(sbuffer, " 0x%x", c);
strncat(kbuffer, sbuffer, sizeof(kbuffer)); strncat(kbuffer, sbuffer, sizeof(kbuffer)-1);
statusline(st->wnd_status->handle, kbuffer); statusline(st->wnd_status->handle, kbuffer);
if (strlen(kbuffer) > 70) if (strlen(kbuffer) > 70)
kbuffer[0] = 0; kbuffer[0] = 0;

View File

@ -572,7 +572,7 @@ void verify_data(void)
int mage, alchemist; int mage, alchemist;
if (verbosity >= 1) if (verbosity >= 1)
puts(" - Überprüfe Daten auf Korrektheit..."); puts(" - checking data for correctness...");
for (f = factions; f; f = f->next) { for (f = factions; f; f = f->next) {
mage = 0; mage = 0;
@ -960,7 +960,7 @@ const char *strcheck(const char *s, size_t maxlen)
static char buffer[16 * 1024]; // FIXME: static return value static char buffer[16 * 1024]; // FIXME: static return value
if (strlen(s) > maxlen) { if (strlen(s) > maxlen) {
assert(maxlen < 16 * 1024); 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); strlcpy(buffer, s, maxlen);
return buffer; return buffer;
} }

View File

@ -496,7 +496,7 @@ static void json_strings(cJSON *json) {
return; return;
} }
for (child=json->child;child;child=child->next) { 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); struct locale *lang = get_or_create_locale(child->string);
json_locale(child, lang); json_locale(child, lang);
} else { } else {
@ -558,7 +558,7 @@ static void json_skill(cJSON *json, struct locale *lang) {
cJSON *entry; cJSON *entry;
for (entry=child->child;entry;entry=entry->next) { for (entry=child->child;entry;entry=entry->next) {
init_skill(lang, sk, entry->valuestring); init_skill(lang, sk, entry->valuestring);
if ((entry==child->child)) { if (entry==child->child) {
locale_setstring(lang, mkname("skill", skillnames[sk]), entry->valuestring); locale_setstring(lang, mkname("skill", skillnames[sk]), entry->valuestring);
} }
} }
@ -588,7 +588,7 @@ static void json_keyword(cJSON *json, struct locale *lang) {
cJSON *entry; cJSON *entry;
for (entry=child->child;entry;entry=entry->next) { for (entry=child->child;entry;entry=entry->next) {
init_keyword(lang, kwd, entry->valuestring); init_keyword(lang, kwd, entry->valuestring);
if ((entry==child->child)) { if (entry==child->child) {
locale_setstring(lang, mkname("keyword", keywords[kwd]), entry->valuestring); locale_setstring(lang, mkname("keyword", keywords[kwd]), entry->valuestring);
} }
} }

View File

@ -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)); m = add_message(&f->msgs, msg_message("msg_economy", "string", s));
break; break;
case MSG_BATTLE: case MSG_BATTLE:
assert(0 || !"battle-meldungen nicht über addmessage machen"); assert(0 || !"battle messages must not use addmessage");
break; break;
case MSG_MOVE: case MSG_MOVE:
assert(f); assert(f);
@ -240,7 +240,7 @@ caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
} }
break; break;
default: default:
assert(!"Ungültige Msg-Klasse!"); assert(!"invalid message class");
} }
if (m) if (m)
msg_release(m); msg_release(m);

View File

@ -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))) if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD)))
guard_count = guard_count - u->number; guard_count = guard_count - u->number;
else if (sk >= stealth) { else if (sk >= stealth) {
guard_count =+ u->number; guard_count += u->number;
double prob_u = (sk - stealth) * skill_prob; double prob_u = (sk - stealth) * skill_prob;
/* amulet counts at most once */ /* amulet counts at most once */
prob_u += _min (1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob; prob_u += _min (1, _min(u->number, i_get(u->items, ramulet->itype))) * amulet_prob;

View File

@ -93,13 +93,13 @@ void spy_message(int spy, const unit * u, const unit * target)
if (first == 1) { if (first == 1) {
first = 0; first = 0;
} else { } else {
strncat(buf, ", ", sizeof(buf)); strncat(buf, ", ", sizeof(buf)-1);
} }
strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale), strncat(buf, (const char *)skillname((skill_t)sv->id, u->faction->locale),
sizeof(buf)); sizeof(buf)-1);
strncat(buf, " ", sizeof(buf)); strncat(buf, " ", sizeof(buf)-1);
strncat(buf, itoa10(eff_skill(target, (skill_t)sv->id, target->region)), strncat(buf, itoa10(eff_skill(target, (skill_t)sv->id, target->region)),
sizeof(buf)); sizeof(buf)-1);
} }
} }
if (found) { if (found) {