Browse Source

lint (unreachable code)

Roberto Ierusalimschy 14 years ago
parent
commit
e24f1ee9ff
2 changed files with 11 additions and 11 deletions
  1. 9 9
      lapi.c
  2. 2 2
      lparser.c

+ 9 - 9
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 2.151 2011/08/17 20:26:47 roberto Exp roberto $
+** $Id: lapi.c,v 2.152 2011/09/26 20:17:27 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -306,17 +306,17 @@ LUA_API void  lua_arith (lua_State *L, int op) {
 
 
 LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
 LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
   StkId o1, o2;
   StkId o1, o2;
-  int i;
+  int i = 0;
   lua_lock(L);  /* may call tag method */
   lua_lock(L);  /* may call tag method */
   o1 = index2addr(L, index1);
   o1 = index2addr(L, index1);
   o2 = index2addr(L, index2);
   o2 = index2addr(L, index2);
-  if (!isvalid(o1) || !isvalid(o2))
-    i = 0;
-  else switch (op) {
-    case LUA_OPEQ: i = equalobj(L, o1, o2); break;
-    case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
-    case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
-    default: api_check(L, 0, "invalid option"); i = 0;
+  if (isvalid(o1) && isvalid(o2)) {
+    switch (op) {
+      case LUA_OPEQ: i = equalobj(L, o1, o2); break;
+      case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
+      case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
+      default: api_check(L, 0, "invalid option");
+    }
   }
   }
   lua_unlock(L);
   lua_unlock(L);
   return i;
   return i;

+ 2 - 2
lparser.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lparser.c,v 2.118 2011/08/30 16:38:58 roberto Exp roberto $
+** $Id: lparser.c,v 2.119 2011/09/14 17:40:26 roberto Exp roberto $
 ** Lua Parser
 ** Lua Parser
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -1611,8 +1611,8 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
   close_func(&lexstate);
   close_func(&lexstate);
   L->top--;  /* pop name */
   L->top--;  /* pop name */
   lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
   lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
-  return funcstate.f;
   /* all scopes should be correctly finished */
   /* all scopes should be correctly finished */
   lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);
   lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);
+  return funcstate.f;
 }
 }