lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Here's a few warnings found when running Lua 5.1.3 through Gimpel PC-lint[1].

(1)

 if (s==NULL || getstr(s)==NULL)
ldump.c(63) : Info 774: Boolean within 'right side of || within if' always
   evaluates to False [Reference: file ldump.c: line 63]

getstr(s) expands to cast(const char *, (s) + 1), which expands to
((const char*)(s + 1)).  It won't be NULL unless s == (const
TString*)(-1).  Is this possible?

(2)

 int error = GetLastError();
loadlib.c(113) : Info 713: Loss of precision (initialization) (unsigned long to
   int)

GetLastError returns instead a DWORD type, which is normally used[2].
Internally, DWORD is a "typedef unsigned long DWORD;" in windef.h
despite what the MSDN docs[3] say.

(3)

lparser.c(928) : Info 818: Pointer parameter 'v' (line 908) could be declared
   as pointing to const

There's various points like this in this code where a const could be
placed on a variable if one so desired.  This is just one example.

(4)

#define SS(x)   (x==1)?"":"s"
print.c(158) : Info 773: Expression-like macro 'SS' not parenthesized

Parenthesis could be added around the macro (safer).

(5)

ldebug.c(462) : Info 750: local macro 'checkjump' (line 270) not referenced

checkjump is not referenced.

(6)

   lf.extraline = 0;
lauxlib.c(578) : Warning 539: Did not expect positive indentation from line 577

Indenting is broken.

(7)

Info 766: Header file 'D:\lib\msvs-9\VC\include\string.h' not used in module
   'lbaselib.c'

lbaselib.c compiles here without including string.h.  Does any
compiler require string.h here?


There's various other warnings about type conversions and
signed/unsigned, which given what Lua does may or may not be of
concern.  Full results without much filtering are in [4].


[1] http://www.gimpel.com/
[2] http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx
[3] http://msdn.microsoft.com/en-us/library/cc230318.aspx
[4] http://lua-users.org/files/wiki_insecure/users/DavidManura/lint.txt