fix -Wtautological-compare warnings from clang

This commit is contained in:
Enno Rehling 2015-05-18 07:46:45 +02:00
parent f108f08d72
commit dfa45acd68
1 changed files with 13 additions and 10 deletions

View File

@ -671,7 +671,6 @@ size_t size)
for (itm = show; itm; itm = itm->next) { for (itm = show; itm; itm = itm->next) {
const char *ic; const char *ic;
int in; int in;
size_t bytes;
report_item(u, itm, f, &ic, NULL, &in, false); report_item(u, itm, f, &ic, NULL, &in, false);
if (in == 0 || ic == NULL) if (in == 0 || ic == NULL)
continue; continue;
@ -731,9 +730,10 @@ size_t size)
break; break;
} }
if (i != MAXCOMBATSPELLS) { if (i != MAXCOMBATSPELLS) {
bytes = int result =
(size_t)_snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells")); _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) size_t bytes = (size_t)result;
if (result < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
dh = 0; dh = 0;
@ -757,8 +757,9 @@ size_t size)
} }
if (sl > 0) { if (sl > 0) {
bytes = (size_t)_snprintf(bufp, size, " (%d)", sl); int result = _snprintf(bufp, size, " (%d)", sl);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) size_t bytes = (size_t)result;
if (result < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
} }
@ -2279,8 +2280,9 @@ static void eval_resources(struct opstack **stack, const void *userdata)
while (res != NULL && size > 4) { while (res != NULL && size > 4) {
const char *rname = const char *rname =
resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0); resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0);
size_t bytes = (size_t)_snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname)); int result = _snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0 || size < sizeof(buf) / 2) { size_t bytes = (size_t)result;
if (result < 0 || wrptr(&bufp, &size, bytes) != 0 || size < sizeof(buf) / 2) {
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
break; break;
} }
@ -2355,8 +2357,9 @@ static void eval_trail(struct opstack **stack, const void *userdata)
region *r = regions->regions[i]; region *r = regions->regions[i];
const char *trail = trailinto(r, lang); const char *trail = trailinto(r, lang);
const char *rn = f_regionid_s(r, report); const char *rn = f_regionid_s(r, report);
size_t bytes = (size_t)_snprintf(bufp, size, trail, rn); int result = _snprintf(bufp, size, trail, rn);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) size_t bytes = (size_t)result;
if (result < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
if (i + 2 < end) { if (i + 2 < end) {