1
0
Fork 0

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

release/0.6
smatz 2008-03-15 13:21:31 +00:00
parent 5db7288ea9
commit bfae49aeb2
7 changed files with 15 additions and 21 deletions

View File

@ -970,12 +970,6 @@ make_cflags_and_ldflags() {
if [ $cc_version -ge 42 ]; then if [ $cc_version -ge 42 ]; then
CFLAGS="$CFLAGS -fno-strict-overflow" CFLAGS="$CFLAGS -fno-strict-overflow"
fi 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 fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then

View File

@ -4644,7 +4644,7 @@ static void DefineGotoLabel(byte *buf, int len)
} else { } else {
/* Attach the label to the end of the list */ /* Attach the label to the end of the list */
GRFLabel *l; 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; l->next = label;
} }

View File

@ -179,7 +179,7 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
const GRFConfig *c; const GRFConfig *c;
uint i = (e->we.click.pt.y - w->widget[ANGRFW_GRF_LIST].top) / 10 + w->vscroll.pos; 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; WP(w, newgrf_add_d).sel = c;
SetWindowDirty(w); SetWindowDirty(w);
break; break;
@ -304,7 +304,7 @@ static void SetupNewGRFWindow(Window *w)
const GRFConfig *c; const GRFConfig *c;
int i; 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; w->vscroll.cap = (w->widget[SNGRFS_FILE_LIST].bottom - w->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
SetVScrollCount(w, i); SetVScrollCount(w, i);
@ -327,9 +327,9 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
ReloadNewGRFData(); ReloadNewGRFData();
/* Show new, updated list */ /* 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); 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; nd->sel = c;
SetWindowDirty(w); SetWindowDirty(w);
@ -474,7 +474,7 @@ static void NewGRFWndProc(Window *w, WindowEvent *e)
GRFConfig *c; GRFConfig *c;
uint i = (e->we.click.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 14 + w->vscroll.pos; 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; WP(w, newgrf_d).sel = c;
SetWindowDirty(w); SetWindowDirty(w);

View File

@ -105,7 +105,7 @@ StringID GetStationClassName(StationClassID sclass)
uint GetNumStationClasses() uint GetNumStationClasses()
{ {
uint i; 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; return i;
} }
@ -724,7 +724,7 @@ void DeallocateSpecFromStation(Station* st, byte specindex)
/* If this was the highest spec index, reallocate */ /* If this was the highest spec index, reallocate */
if (specindex == st->num_specs - 1) { 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) { if (st->num_specs > 1) {
st->speclist = ReallocT(st->speclist, st->num_specs); st->speclist = ReallocT(st->speclist, st->num_specs);

View File

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

View File

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

View File

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