Nmap Development mailing list archives

Re: Windows warnings in NSE that I don't know how to fix


From: Kris Katterjohn <katterjohn () gmail com>
Date: Fri, 23 Mar 2007 18:03:50 -0500

kx wrote:
From nse_bitlib.cc

nse_bitlib.cc(51) : warning C4244: 'argument' : conversion from
'Integer' to 'lua_Number', possible loss of data

same for lines 51 - 58.

In VS 2005, Integer is of type __int64 while lua_Number is a double

Suggestions?

Cheers,
  kx


From nse_bitlib.cc:


typedef long long Integer;
typedef unsigned long long UInteger;

#define luaL_checkbit(L, n)  ((Integer)luaL_checknumber(L, n))
#define luaL_checkubit(L, n) ((UInteger)luaL_checkbit(L, n))

#define TDYADIC(name, op, checkbit1, checkbit2) \
  static int bit_ ## name(lua_State* L) { \
    lua_pushnumber(L, \
      checkbit1(L, 1) op checkbit2(L, 2)); \
    return 1; \
  }

#define DYADIC(name, op) \
  TDYADIC(name, op, luaL_checkbit, luaL_checkbit)

#define MONADIC(name, op) \
  static int bit_ ## name(lua_State* L) { \
    lua_pushnumber(L, op luaL_checkbit(L, 1)); \
    return 1; \
  }

#define VARIADIC(name, op) \
  static int bit_ ## name(lua_State *L) { \
    int n = lua_gettop(L), i; \
    Integer w = luaL_checkbit(L, 1); \
    for (i = 2; i <= n; i++) \
      w op luaL_checkbit(L, i); \
    lua_pushnumber(L, w); \
    return 1; \
  }

MONADIC(bnot,     ~)
VARIADIC(band,    &=)
VARIADIC(bor,     |=)
VARIADIC(bxor,    ^=)
TDYADIC(lshift,  <<, luaL_checkbit, luaL_checkubit)
TDYADIC(rshift,  >>, luaL_checkubit, luaL_checkubit)
TDYADIC(arshift, >>, luaL_checkbit, luaL_checkubit)
DYADIC(mod,      %)


^
|
|

(These *ADIC uses are the lines 51-58 for anyone not looking that the
actual file)


Hmm.. it looks intentional, doesn't it?  The casts to Integer and
UInteger make me think so.

I think VS is just eager to gives warnings :)

I don't think nse_bitlib.cc needs fixing, it just casts and VS
complains...   Thoughts?

Thanks,
Kris Katterjohn

Attachment: signature.asc
Description: OpenPGP digital signature


_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: