(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script

pull/155/head
smatz 16 years ago
parent 8d7f246b55
commit 1f13638d03

@ -970,12 +970,6 @@ make_cflags_and_ldflags() {
if [ $cc_version -ge 42 ]; then
CFLAGS="$CFLAGS -fno-strict-overflow"
fi
# GCC 4.3+ gives a warning about empty body of
# loops and conditions
if [ $cc_version -ge 43 ]; then
CFLAGS="$CFLAGS -Wno-empty-body"
fi
fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then

@ -4644,7 +4644,7 @@ static void DefineGotoLabel(byte *buf, int len)
} else {
/* Attach the label to the end of the list */
GRFLabel *l;
for (l = _cur_grffile->label; l->next != NULL; l = l->next);
for (l = _cur_grffile->label; l->next != NULL; l = l->next) {}
l->next = label;
}

@ -179,7 +179,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
const GRFConfig *c;
uint i = (e->we.click.pt.y - w->widget[ANGRFW_GRF_LIST].top) / 10 + w->vscroll.pos;
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--);
for (c = _all_grfs; c != NULL && i > 0; c = c->next, i--) {}
WP(w, newgrf_add_d).sel = c;
SetWindowDirty(w);
break;
@ -304,7 +304,7 @@ static void SetupNewGRFWindow(Window *w)
const GRFConfig *c;
int i;
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++);
for (c = *WP(w, newgrf_d).list, i = 0; c != NULL; c = c->next, i++) {}
w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
SetVScrollCount(w, i);
@ -327,9 +327,9 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
ReloadNewGRFData();
/* Show new, updated list */
for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++);
for (c = *nd->list; c != NULL && c != nd->sel; c = c->next, i++) {}
CopyGRFConfigList(nd->list, *nd->orig_list, false);
for (c = *nd->list; c != NULL && i > 0; c = c->next, i--);
for (c = *nd->list; c != NULL && i > 0; c = c->next, i--) {}
nd->sel = c;
SetWindowDirty(w);
@ -474,7 +474,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
GRFConfig *c;
uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos;
for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--);
for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--) {}
WP(w, newgrf_d).sel = c;
SetWindowDirty(w);

@ -105,7 +105,7 @@ StringID GetStationClassName(StationClassID sclass)
uint GetNumStationClasses()
{
uint i;
for (i = 0; i < STAT_CLASS_MAX && _station_classes[i].id != 0; i++);
for (i = 0; i < STAT_CLASS_MAX && _station_classes[i].id != 0; i++) {}
return i;
}
@ -724,7 +724,7 @@ void DeallocateSpecFromStation(Station* st, byte specindex)
/* If this was the highest spec index, reallocate */
if (specindex == st->num_specs - 1) {
for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--);
for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--) {}
if (st->num_specs > 1) {
st->speclist = ReallocT(st->speclist, st->num_specs);

@ -236,7 +236,7 @@ static IniFile *ini_load(const char *filename)
while (fgets(buffer, sizeof(buffer), in)) {
/* trim whitespace from the left side */
for (s = buffer; *s == ' ' || *s == '\t'; s++);
for (s = buffer; *s == ' ' || *s == '\t'; s++) {}
/* trim whitespace from right side. */
e = s + strlen(s);
@ -278,10 +278,10 @@ static IniFile *ini_load(const char *filename)
/* find end of keyname */
if (*s == '\"') {
s++;
for (t = s; *t != '\0' && *t != '\"'; t++);
for (t = s; *t != '\0' && *t != '\"'; t++) {}
if (*t == '\"') *t = ' ';
} else {
for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++) {}
}
/* it's an item in an existing group */

@ -48,7 +48,7 @@ static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
static inline int ttd_strnlen(const char *str, int maxlen)
{
const char *t;
for (t = str; *t != '\0' && t - str < maxlen; t++);
for (t = str; *t != '\0' && t - str < maxlen; t++) {}
return t - str;
}
@ -128,7 +128,7 @@ static inline bool IsUtf8Part(char c)
static inline char *Utf8PrevChar(const char *s)
{
const char *ret = s;
while (IsUtf8Part(*--ret));
while (IsUtf8Part(*--ret)) {}
return (char*)ret;
}

@ -1214,7 +1214,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
{
Vehicle *v;
for (v = src; GetNextVehicle(v) != NULL; v = GetNextVehicle(v));
for (v = src; GetNextVehicle(v) != NULL; v = GetNextVehicle(v)) {}
GetLastEnginePart(v)->SetNext(dst->Next());
}
dst->SetNext(src);
@ -3745,7 +3745,7 @@ void ConnectMultiheadedTrains()
}
Vehicle *w;
for (w = u->Next(); w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w));
for (w = u->Next(); w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w)) {}
if (w != NULL) {
/* we found a car to partner with this engine. Now we will make sure it face the right way */
if (IsTrainEngine(w)) {

Loading…
Cancel
Save