]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix narrowing casts of pointer differences for x64.
authorMike Pall <mike>
Tue, 29 Dec 2009 19:19:54 +0000 (20:19 +0100)
committerMike Pall <mike>
Tue, 29 Dec 2009 19:19:54 +0000 (20:19 +0100)
src/lib_base.c
src/lib_io.c
src/lj_err.c

index 34282cfc069b091788ceed4f1d59f63275a8e5d0..d9b953ee41956ebb7c8c0943f54109e07ce0139a 100644 (file)
@@ -337,7 +337,7 @@ LJLIB_CF(dofile)
   if (luaL_loadfile(L, fname ? strdata(fname) : NULL) != 0)
     lua_error(L);
   lua_call(L, 0, LUA_MULTRET);
-  return (L->top - L->base) - 1;
+  return cast_int(L->top - L->base) - 1;
 }
 
 /* -- Base library: GC control -------------------------------------------- */
index d69b99a40c0fb9d91dfc3db3a2606fbaf03cef08..6fb91609ec8125fbd9e4591a31fd18d31f9ed212 100644 (file)
@@ -194,7 +194,7 @@ static int io_file_readchars(lua_State *L, FILE *fp, size_t n)
 
 static int io_file_read(lua_State *L, FILE *fp, int start)
 {
-  int ok, n, nargs = (L->top - L->base) - start;
+  int ok, n, nargs = cast_int(L->top - L->base) - start;
   clearerr(fp);
   if (nargs == 0) {
     ok = io_file_readline(L, fp);
@@ -242,7 +242,7 @@ static int io_file_write(lua_State *L, FILE *fp, int start)
     } else if (tvisnum(tv)) {
       status = status && (fprintf(fp, LUA_NUMBER_FMT, numV(tv)) > 0);
     } else {
-      lj_lib_checkstr(L, tv-L->base+1);
+      lj_err_argt(L, cast_int(tv - L->base) + 1, LUA_TSTRING);
     }
   }
   return io_pushresult(L, status, NULL);
index 02a7c4ccdef580f744b9ccfd956ed10782e56082..da2555f9b8bfafc8489bd29b7658f1ed5ab22c33 100644 (file)
@@ -677,7 +677,7 @@ LJ_NORET LJ_NOINLINE static void err_argmsg(lua_State *L, int narg,
   const char *fname = "?";
   const char *ftype = getfuncname(L, L->base - 1, &fname);
   if (narg < 0 && narg > LUA_REGISTRYINDEX)
-    narg = (L->top - L->base) + narg + 1;
+    narg = cast_int(L->top - L->base) + narg + 1;
   if (ftype && ftype[3] == 'h' && --narg == 0)  /* Check for "method". */
     msg = lj_str_pushf(L, err2msg(LJ_ERR_BADSELF), fname, msg);
   else