Merge pull request #292 from alliedmodders/sourcepawn-fix-signed-compare
Signed comparison warning fixes.
This commit is contained in:
commit
81926ceae2
@ -53,7 +53,6 @@ compiler.sourcedeps += packed_includes
|
||||
|
||||
if compiler.cc.behavior == 'gcc':
|
||||
compiler.cflags += ['-Wno-format']
|
||||
compiler.cflags += ['-Wno-error=sign-compare']
|
||||
compiler.c_only_flags += ['-std=c99']
|
||||
if builder.target_platform == 'linux':
|
||||
compiler.postlink += ['-lm']
|
||||
|
@ -565,12 +565,12 @@ typedef enum s_optmark {
|
||||
|
||||
#define suSLEEP_INSTR 0x01 /* the "sleep" instruction was used */
|
||||
|
||||
#define FIXEDTAG 0x40000000Lu
|
||||
#define FUNCTAG 0x20000000Lu
|
||||
#define OBJECTTAG 0x10000000Lu
|
||||
#define ENUMTAG 0x08000000Lu
|
||||
#define METHODMAPTAG 0x04000000Lu
|
||||
#define STRUCTTAG 0x02000000Lu
|
||||
#define FIXEDTAG 0x40000000
|
||||
#define FUNCTAG 0x20000000
|
||||
#define OBJECTTAG 0x10000000
|
||||
#define ENUMTAG 0x08000000
|
||||
#define METHODMAPTAG 0x04000000
|
||||
#define STRUCTTAG 0x02000000
|
||||
#define TAGTYPEMASK (FUNCTAG | OBJECTTAG | ENUMTAG | METHODMAPTAG | STRUCTTAG)
|
||||
#define TAGFLAGMASK (FIXEDTAG | TAGTYPEMASK)
|
||||
#define TAGID(tag) ((tag) & ~(TAGFLAGMASK))
|
||||
|
@ -150,7 +150,7 @@ int plungequalifiedfile(char *name)
|
||||
|
||||
void *fp;
|
||||
char *ext;
|
||||
int ext_idx;
|
||||
size_t ext_idx;
|
||||
|
||||
ext_idx=0;
|
||||
do {
|
||||
@ -258,7 +258,8 @@ static void doinclude(int silent)
|
||||
{
|
||||
char name[_MAX_PATH];
|
||||
char c;
|
||||
int i, result;
|
||||
size_t i;
|
||||
int result;
|
||||
|
||||
while (*lptr<=' ' && *lptr!='\0') /* skip leading whitespace */
|
||||
lptr++;
|
||||
@ -276,7 +277,7 @@ static void doinclude(int silent)
|
||||
name[i++]=*lptr++;
|
||||
while (i>0 && name[i-1]<=' ')
|
||||
i--; /* strip trailing whitespace */
|
||||
assert(i>=0 && i<sizeof name);
|
||||
assert(i<sizeof name);
|
||||
name[i]='\0'; /* zero-terminate the string */
|
||||
|
||||
if (*lptr!=c) { /* verify correct string termination */
|
||||
@ -1029,7 +1030,7 @@ static int command(void)
|
||||
if (*lptr=='"') {
|
||||
lptr=getstring((unsigned char*)name,sizeof name,lptr);
|
||||
} else {
|
||||
int i;
|
||||
size_t i;
|
||||
for (i=0; i<sizeof name && alphanum(*lptr); i++,lptr++)
|
||||
name[i]=*lptr;
|
||||
name[i]='\0';
|
||||
@ -1058,7 +1059,7 @@ static int command(void)
|
||||
} else if (strcmp(str,"rational")==0) {
|
||||
char name[sNAMEMAX+1];
|
||||
cell digits=0;
|
||||
int i;
|
||||
size_t i;
|
||||
/* first gather all information, start with the tag name */
|
||||
while (*lptr<=' ' && *lptr!='\0')
|
||||
lptr++;
|
||||
@ -1078,9 +1079,9 @@ static int command(void)
|
||||
lptr++;
|
||||
} /* if */
|
||||
/* add the tag (make it public) and check the values */
|
||||
i=pc_addtag(name);
|
||||
if (sc_rationaltag==0 || (sc_rationaltag==i && rational_digits==(int)digits)) {
|
||||
sc_rationaltag=i;
|
||||
int tag=pc_addtag(name);
|
||||
if (sc_rationaltag==0 || (sc_rationaltag==tag && rational_digits==(int)digits)) {
|
||||
sc_rationaltag=tag;
|
||||
rational_digits=(int)digits;
|
||||
} else {
|
||||
error(69); /* rational number format already set, can only be set once */
|
||||
@ -1107,7 +1108,8 @@ static int command(void)
|
||||
sc_alignnext=TRUE;
|
||||
} else if (strcmp(str,"unused")==0) {
|
||||
char name[sNAMEMAX+1];
|
||||
int i,comma;
|
||||
size_t i;
|
||||
int comma;
|
||||
symbol *sym;
|
||||
do {
|
||||
/* get the name */
|
||||
|
@ -128,7 +128,8 @@ int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
|
||||
static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec };
|
||||
|
||||
char opername[4] = "", symbolname[sNAMEMAX+1];
|
||||
int i,swapparams,savepri,savealt;
|
||||
size_t i;
|
||||
int swapparams,savepri,savealt;
|
||||
int paramspassed;
|
||||
symbol *sym;
|
||||
|
||||
|
@ -365,7 +365,8 @@ void alignframe(int numbytes)
|
||||
{
|
||||
#if !defined NDEBUG
|
||||
/* "numbytes" should be a power of 2 for this code to work */
|
||||
int i,count=0;
|
||||
size_t i;
|
||||
int count=0;
|
||||
for (i=0; i<sizeof numbytes*8; i++)
|
||||
if (numbytes & (1 << i))
|
||||
count++;
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]);
|
||||
size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]);
|
||||
|
||||
#ifndef SCPACK
|
||||
# define SCPACK
|
||||
|
@ -49,7 +49,7 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0])
|
||||
#define NUM_WARNINGS (int)(sizeof warnmsg / sizeof warnmsg[0])
|
||||
static unsigned char warndisable[(NUM_WARNINGS + 7) / 8]; /* 8 flags in a char */
|
||||
|
||||
static int errflag;
|
||||
|
@ -598,7 +598,7 @@ class VerifyOpcodeSorting
|
||||
public:
|
||||
VerifyOpcodeSorting() {
|
||||
assert(opcodelist[1].name!=NULL);
|
||||
for (int i = 2; i<(sizeof opcodelist / sizeof opcodelist[0]); i++) {
|
||||
for (size_t i = 2; i<(sizeof opcodelist / sizeof opcodelist[0]); i++) {
|
||||
assert(opcodelist[i].name!=NULL);
|
||||
assert(stricmp(opcodelist[i].name,opcodelist[i-1].name)>0);
|
||||
} /* for */
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]);
|
||||
size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2]);
|
||||
|
||||
#define SCPACK_TERMINATOR , /* end each section with a comma */
|
||||
|
||||
|
@ -400,7 +400,7 @@ static SEQUENCE *sequences;
|
||||
|
||||
int phopt_init(void)
|
||||
{
|
||||
int number, i, len;
|
||||
size_t number, i, len;
|
||||
char str[160];
|
||||
|
||||
/* count number of sequences */
|
||||
@ -422,13 +422,13 @@ int phopt_init(void)
|
||||
for (i=0; i<number-1; i++) {
|
||||
len = strexpand(str,(unsigned char*)sequences_cmp[i].find,sizeof str,SCPACK_TABLE);
|
||||
assert(len<=sizeof str);
|
||||
assert(len==(int)strlen(str)+1);
|
||||
assert(len==strlen(str)+1);
|
||||
sequences[i].find=(char*)malloc(len);
|
||||
if (sequences[i].find!=NULL)
|
||||
strcpy(sequences[i].find,str);
|
||||
len = strexpand(str,(unsigned char*)sequences_cmp[i].replace,sizeof str,SCPACK_TABLE);
|
||||
assert(len<=sizeof str);
|
||||
assert(len==(int)strlen(str)+1);
|
||||
assert(len==strlen(str)+1);
|
||||
sequences[i].replace=(char*)malloc(len);
|
||||
if (sequences[i].replace!=NULL)
|
||||
strcpy(sequences[i].replace,str);
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
#define STACKSIZE 16
|
||||
|
||||
int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
|
||||
size_t strexpand(char *dest, unsigned char *source, size_t maxlen, unsigned char pairtable[128][2])
|
||||
{
|
||||
unsigned char stack[STACKSIZE];
|
||||
short c, top = 0;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
assert(maxlen > 0);
|
||||
len = 1; /* already 1 byte for '\0' */
|
||||
|
@ -359,7 +359,7 @@ int delete_subst(char *name,int length)
|
||||
|
||||
void delete_substtable(void)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
delete_stringpairtable(&substpair);
|
||||
for (i=0; i<sizeof substindex/sizeof substindex[0]; i++)
|
||||
substindex[i]=NULL;
|
||||
|
@ -258,9 +258,11 @@ enum OPCODE {
|
||||
#define _(op, text) OP_##op,
|
||||
OPCODE_LIST(_)
|
||||
#undef _
|
||||
OPCODES_TOTAL
|
||||
OPCODES_LAST
|
||||
};
|
||||
|
||||
#define OPCODES_TOTAL (ucell_t)OPCODES_LAST
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif // _INCLUDE_SPFILE_HEADERS_v1_opcodes_H
|
||||
|
@ -38,7 +38,7 @@ FileReader::FileReader(FILE *fp)
|
||||
return;
|
||||
|
||||
ke::AutoArray<uint8_t> bytes(new uint8_t[size]);
|
||||
if (!bytes || fread(bytes, sizeof(uint8_t), size, fp) != size)
|
||||
if (!bytes || fread(bytes, sizeof(uint8_t), size, fp) != (size_t)size)
|
||||
return;
|
||||
|
||||
buffer_ = bytes.take();
|
||||
|
@ -21,7 +21,7 @@ using namespace ke;
|
||||
using namespace sp;
|
||||
using namespace SourcePawn;
|
||||
|
||||
InvokeFrame::InvokeFrame(PluginContext *cx, cell_t entry_cip)
|
||||
InvokeFrame::InvokeFrame(PluginContext *cx, ucell_t entry_cip)
|
||||
: prev_(Environment::get()->top()),
|
||||
cx_(cx),
|
||||
prev_exit_frame_(Environment::get()->exit_frame()),
|
||||
@ -82,7 +82,7 @@ FrameIterator::nextInvokeFrame()
|
||||
assert(sp_stop_ >= sp_iter_);
|
||||
|
||||
runtime_ = ivk_->cx()->runtime();
|
||||
function_cip_ = -1;
|
||||
function_cip_ = kInvalidCip;
|
||||
pc_ = nullptr;
|
||||
cip_ = kInvalidCip;
|
||||
|
||||
@ -170,7 +170,7 @@ FrameIterator::findCip() const
|
||||
unsigned
|
||||
FrameIterator::LineNumber() const
|
||||
{
|
||||
cell_t cip = findCip();
|
||||
ucell_t cip = findCip();
|
||||
if (cip == kInvalidCip)
|
||||
return 0;
|
||||
|
||||
@ -184,7 +184,7 @@ FrameIterator::LineNumber() const
|
||||
const char *
|
||||
FrameIterator::FilePath() const
|
||||
{
|
||||
cell_t cip = findCip();
|
||||
ucell_t cip = findCip();
|
||||
if (cip == kInvalidCip)
|
||||
return runtime_->image()->LookupFile(function_cip_);
|
||||
|
||||
|
@ -64,7 +64,7 @@ class ExitFrame
|
||||
class InvokeFrame
|
||||
{
|
||||
public:
|
||||
InvokeFrame(PluginContext *cx, cell_t cip);
|
||||
InvokeFrame(PluginContext *cx, ucell_t cip);
|
||||
~InvokeFrame();
|
||||
|
||||
InvokeFrame *prev() const {
|
||||
@ -80,7 +80,7 @@ class InvokeFrame
|
||||
const intptr_t *entry_sp() const {
|
||||
return entry_sp_;
|
||||
}
|
||||
cell_t entry_cip() const {
|
||||
ucell_t entry_cip() const {
|
||||
return entry_cip_;
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class InvokeFrame
|
||||
InvokeFrame *prev_;
|
||||
PluginContext *cx_;
|
||||
ExitFrame prev_exit_frame_;
|
||||
cell_t entry_cip_;
|
||||
ucell_t entry_cip_;
|
||||
const intptr_t *entry_sp_;
|
||||
};
|
||||
|
||||
@ -125,8 +125,8 @@ class FrameIterator : public SourcePawn::IFrameIterator
|
||||
PluginRuntime *runtime_;
|
||||
const intptr_t *sp_iter_;
|
||||
const intptr_t *sp_stop_;
|
||||
cell_t function_cip_;
|
||||
mutable cell_t cip_;
|
||||
ucell_t function_cip_;
|
||||
mutable ucell_t cip_;
|
||||
void *pc_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user