Permalink
Browse files

When a noreturn function has to return, only ever return 0.

  • Loading branch information...
1 parent 986a6e3 commit 4832491b416c4364aba26261c2205613fac58804 @johnbartholomew johnbartholomew committed Aug 21, 2011
Showing with 7 additions and 4 deletions.
  1. +2 −1 src/GeoSphere.cpp
  2. +3 −1 src/LuaUtils.cpp
  3. +2 −2 src/utils.h
View
@@ -965,7 +965,8 @@ int GeoSphere::UpdateLODThread(void *data)
SDL_Delay(10);
}
- RETURN_NONGNU_ONLY(0);
+
+ RETURN_ZERO_NONGNU_ONLY;
}
void GeoSphere::_UpdateLODs()
View
@@ -49,7 +49,9 @@ int pi_lua_panic(lua_State *L)
Error("%s", errorMsg.c_str());
// Error() is noreturn
- RETURN_NONGNU_ONLY(0);
+ // XXX when Lua management is good enough, we can probably remove panic
+ // entirely in favour of pcall and a nicer error handling system
+ RETURN_ZERO_NONGNU_ONLY;
}
void pi_lua_protected_call(lua_State* L, int nargs, int nresults) {
View
@@ -28,9 +28,9 @@
// but other compilers which don't see the noreturn attribute of course require that
// a function with a non-void return type should return something.
#ifndef __GNUC__
-#define RETURN_NONGNU_ONLY(x) return(x)
+#define RETURN_ZERO_NONGNU_ONLY return 0;
#else
-#define RETURN_NONGNU_ONLY(x) (void)(x)
+#define RETURN_ZERO_NONGNU_ONLY
#endif
void Error(const char *format, ...) __attribute((format(printf,1,2))) __attribute((noreturn));

0 comments on commit 4832491

Please sign in to comment.