(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
authorsmatz
Sat, 15 Mar 2008 13:21:31 +0000
changeset 9191 ae14770c829a
parent 9190 6aacd72e0d05
child 9192 7e4b0b777375
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
config.lib
src/newgrf.cpp
src/newgrf_gui.cpp
src/newgrf_station.cpp
src/settings.cpp
src/string_func.h
src/train_cmd.cpp
--- a/config.lib	Sat Mar 15 00:31:10 2008 +0000
+++ b/config.lib	Sat Mar 15 13:21:31 2008 +0000
@@ -970,12 +970,6 @@
 		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
--- a/src/newgrf.cpp	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/newgrf.cpp	Sat Mar 15 13:21:31 2008 +0000
@@ -4644,7 +4644,7 @@
 	} 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;
 	}
 
--- a/src/newgrf_gui.cpp	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/newgrf_gui.cpp	Sat Mar 15 13:21:31 2008 +0000
@@ -179,7 +179,7 @@
 					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 @@
 	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 @@
 		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 @@
 					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);
--- a/src/newgrf_station.cpp	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/newgrf_station.cpp	Sat Mar 15 13:21:31 2008 +0000
@@ -105,7 +105,7 @@
 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 @@
 
 	/* 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);
--- a/src/settings.cpp	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/settings.cpp	Sat Mar 15 13:21:31 2008 +0000
@@ -236,7 +236,7 @@
 	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 @@
 			/* 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 */
--- a/src/string_func.h	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/string_func.h	Sat Mar 15 13:21:31 2008 +0000
@@ -48,7 +48,7 @@
 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 char *Utf8PrevChar(const char *s)
 {
 	const char *ret = s;
-	while (IsUtf8Part(*--ret));
+	while (IsUtf8Part(*--ret)) {}
 	return (char*)ret;
 }
 
--- a/src/train_cmd.cpp	Sat Mar 15 00:31:10 2008 +0000
+++ b/src/train_cmd.cpp	Sat Mar 15 13:21:31 2008 +0000
@@ -1214,7 +1214,7 @@
 			{
 				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 @@
 					}
 
 					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)) {