Fix "possible loss of data" warnings in x64 Windows build

This commit is contained in:
Zeex 2014-05-01 15:53:24 +07:00
parent e35f9c9a21
commit e5dc717491
8 changed files with 49 additions and 49 deletions

View File

@ -76,7 +76,7 @@ size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize)
memcpy(buffer, mf->base + mf->offs, maxsize); memcpy(buffer, mf->base + mf->offs, maxsize);
mf->offs += maxsize; mf->offs += (long)maxsize;
return maxsize; return maxsize;
} }
@ -98,7 +98,7 @@ int memfile_write(memfile_t *mf, const void *buffer, size_t size)
mf->size = newsize; mf->size = newsize;
} }
memcpy(mf->base + mf->offs, buffer, size); memcpy(mf->base + mf->offs, buffer, size);
mf->offs += size; mf->offs += (long)size;
if (mf->offs > mf->usedoffs) if (mf->offs > mf->usedoffs)
{ {

View File

@ -1043,7 +1043,7 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
#endif #endif
case 'i': case 'i':
strlcpy(str,option_value(ptr),sizeof str); /* set name of include directory */ strlcpy(str,option_value(ptr),sizeof str); /* set name of include directory */
i=strlen(str); i=(int)strlen(str);
if (i>0) { if (i>0) {
if (str[i-1]!=DIRSEP_CHAR) { if (str[i-1]!=DIRSEP_CHAR) {
str[i]=DIRSEP_CHAR; str[i]=DIRSEP_CHAR;
@ -1316,7 +1316,7 @@ static void setconfig(char *root)
*(ptr+1)='\0'; *(ptr+1)='\0';
base=ptr; base=ptr;
strcat(path,"include"); strcat(path,"include");
len=strlen(path); len=(int)strlen(path);
path[len]=DIRSEP_CHAR; path[len]=DIRSEP_CHAR;
path[len+1]='\0'; path[len+1]='\0';
/* see if it exists */ /* see if it exists */
@ -1329,7 +1329,7 @@ static void setconfig(char *root)
if ((ptr=strrchr(path,DIRSEP_CHAR))!=NULL) { if ((ptr=strrchr(path,DIRSEP_CHAR))!=NULL) {
*(ptr+1)='\0'; *(ptr+1)='\0';
strcat(path,"include"); strcat(path,"include");
len=strlen(path); len=(int)strlen(path);
path[len]=DIRSEP_CHAR; path[len]=DIRSEP_CHAR;
path[len+1]='\0'; path[len+1]='\0';
} else { } else {
@ -4008,9 +4008,9 @@ static int find_xmltag(char *source,char *xmltag,char *xmlparam,char *xmlvalue,
/* both NULL or both non-NULL */ /* both NULL or both non-NULL */
assert(xmlvalue!=NULL && xmlparam!=NULL || xmlvalue==NULL && xmlparam==NULL); assert(xmlvalue!=NULL && xmlparam!=NULL || xmlvalue==NULL && xmlparam==NULL);
xmltag_len=strlen(xmltag); xmltag_len=(int)strlen(xmltag);
xmlparam_len= (xmlparam!=NULL) ? strlen(xmlparam) : 0; xmlparam_len= (xmlparam!=NULL) ? (int)strlen(xmlparam) : 0;
xmlvalue_len= (xmlvalue!=NULL) ? strlen(xmlvalue) : 0; xmlvalue_len= (xmlvalue!=NULL) ? (int)strlen(xmlvalue) : 0;
ptr=source; ptr=source;
/* find an opening '<' */ /* find an opening '<' */
while ((ptr=strchr(ptr,'<'))!=NULL) { while ((ptr=strchr(ptr,'<'))!=NULL) {
@ -5924,10 +5924,10 @@ static void dostate(void)
listid=-1; listid=-1;
} /* if */ } /* if */
listindex=0; listindex=0;
length=strlen(name)+70; /* +70 for the fixed part "<transition ... />\n" */ length=(int)strlen(name)+70; /* +70 for the fixed part "<transition ... />\n" */
/* see if there are any condition strings to attach */ /* see if there are any condition strings to attach */
for (index=0; (str=get_autolist(index))!=NULL; index++) for (index=0; (str=get_autolist(index))!=NULL; index++)
length+=strlen(str); length+=(int)strlen(str);
if ((doc=(char*)malloc(length*sizeof(char)))!=NULL) { if ((doc=(char*)malloc(length*sizeof(char)))!=NULL) {
do { do {
sprintf(doc,"<transition target=\"%s\"",name); sprintf(doc,"<transition target=\"%s\"",name);

View File

@ -377,7 +377,7 @@ static void readline(unsigned char *line)
*ptr='\0'; /* erase '\n' (and any trailing whitespace) */ *ptr='\0'; /* erase '\n' (and any trailing whitespace) */
} /* if */ } /* if */
} /* if */ } /* if */
num-=strlen((char*)line); num-=(int)strlen((char*)line);
line+=strlen((char*)line); line+=strlen((char*)line);
} /* if */ } /* if */
fline+=1; fline+=1;
@ -1385,7 +1385,7 @@ static int command(void)
case tpUNDEF: case tpUNDEF:
if (!SKIPPING) { if (!SKIPPING) {
if (lex(&val,&str)==tSYMBOL) { if (lex(&val,&str)==tSYMBOL) {
ret=delete_subst(str,strlen(str)); ret=delete_subst(str,(int)strlen(str));
if (!ret) { if (!ret) {
/* also undefine normal constants */ /* also undefine normal constants */
symbol *sym=findconst(str,NULL); symbol *sym=findconst(str,NULL);
@ -1632,7 +1632,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
arg=*(e+1)-'0'; arg=*(e+1)-'0';
assert(arg>=0 && arg<=9); assert(arg>=0 && arg<=9);
if (args[arg]!=NULL) if (args[arg]!=NULL)
len+=strlen((char*)args[arg]); len+=(int)strlen((char*)args[arg]);
else else
len+=2; /* copy '%' plus digit */ len+=2; /* copy '%' plus digit */
e++; /* skip %, digit is skipped later */ e++; /* skip %, digit is skipped later */
@ -2699,7 +2699,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
SC_FUNC uint32_t namehash(const char *name) SC_FUNC uint32_t namehash(const char *name)
{ {
const unsigned char *ptr=(const unsigned char *)name; const unsigned char *ptr=(const unsigned char *)name;
int len=strlen(name); int len=(int)strlen(name);
if (len==0) if (len==0)
return 0L; return 0L;
assert(len<256); assert(len<256);

View File

@ -1310,7 +1310,7 @@ static int hier2(value *lval)
if (sym!=NULL && sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0) if (sym!=NULL && sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0)
sym=NULL; /* symbol is not a function, it is in the table, but not "defined" */ sym=NULL; /* symbol is not a function, it is in the table, but not "defined" */
val= (sym!=NULL); val= (sym!=NULL);
if (!val && find_subst(st,strlen(st))!=NULL) if (!val && find_subst(st,(int)strlen(st))!=NULL)
val=1; val=1;
clear_value(lval); clear_value(lval);
lval->ident=iCONSTEXPR; lval->ident=iCONSTEXPR;

View File

@ -755,7 +755,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
assert(strlen(sym->name)<=sNAMEMAX); assert(strlen(sym->name)<=sNAMEMAX);
strcpy(alias,sym->name); strcpy(alias,sym->name);
} /* if */ } /* if */
nametablesize+=strlen(alias)+1; nametablesize+=(int)strlen(alias)+1;
} /* if */ } /* if */
} /* for */ } /* for */
assert(numnatives==ntv_funcid); assert(numnatives==ntv_funcid);
@ -767,7 +767,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
if (constptr->value>0) { if (constptr->value>0) {
assert(strlen(constptr->name)>0); assert(strlen(constptr->name)>0);
numlibraries++; numlibraries++;
nametablesize+=strlen(constptr->name)+1; nametablesize+=(int)strlen(constptr->name)+1;
} /* if */ } /* if */
} /* for */ } /* for */
} /* if */ } /* if */
@ -778,7 +778,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
if ((constptr->value & PUBLICTAG)!=0) { if ((constptr->value & PUBLICTAG)!=0) {
assert(strlen(constptr->name)>0); assert(strlen(constptr->name)>0);
numtags++; numtags++;
nametablesize+=strlen(constptr->name)+1; nametablesize+=(int)strlen(constptr->name)+1;
} /* if */ } /* if */
} /* for */ } /* for */
@ -841,8 +841,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.publics+count*sizeof(AMX_FUNCSTUBNT)); pc_resetbin(fout,hdr.publics+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func); pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs); pc_resetbin(fout,nameofs);
pc_writebin(fout,sym->name,strlen(sym->name)+1); pc_writebin(fout,sym->name,(int)strlen(sym->name)+1);
nameofs+=strlen(sym->name)+1; nameofs+=(int)strlen(sym->name)+1;
count++; count++;
} /* if */ } /* if */
} /* for */ } /* for */
@ -890,8 +890,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.natives+count*sizeof(AMX_FUNCSTUBNT)); pc_resetbin(fout,hdr.natives+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func); pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs); pc_resetbin(fout,nameofs);
pc_writebin(fout,alias,strlen(alias)+1); pc_writebin(fout,alias,(int)strlen(alias)+1);
nameofs+=strlen(alias)+1; nameofs+=(int)strlen(alias)+1;
count++; count++;
} /* for */ } /* for */
free(nativelist); free(nativelist);
@ -912,8 +912,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.libraries+count*sizeof(AMX_FUNCSTUBNT)); pc_resetbin(fout,hdr.libraries+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func); pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs); pc_resetbin(fout,nameofs);
pc_writebin(fout,constptr->name,strlen(constptr->name)+1); pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
nameofs+=strlen(constptr->name)+1; nameofs+=(int)strlen(constptr->name)+1;
count++; count++;
} /* if */ } /* if */
} /* for */ } /* for */
@ -934,8 +934,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.pubvars+count*sizeof(AMX_FUNCSTUBNT)); pc_resetbin(fout,hdr.pubvars+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func); pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs); pc_resetbin(fout,nameofs);
pc_writebin(fout,sym->name,strlen(sym->name)+1); pc_writebin(fout,sym->name,(int)strlen(sym->name)+1);
nameofs+=strlen(sym->name)+1; nameofs+=(int)strlen(sym->name)+1;
count++; count++;
} /* if */ } /* if */
} /* for */ } /* for */
@ -954,8 +954,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
pc_resetbin(fout,hdr.tags+count*sizeof(AMX_FUNCSTUBNT)); pc_resetbin(fout,hdr.tags+count*sizeof(AMX_FUNCSTUBNT));
pc_writebin(fout,&func,sizeof func); pc_writebin(fout,&func,sizeof func);
pc_resetbin(fout,nameofs); pc_resetbin(fout,nameofs);
pc_writebin(fout,constptr->name,strlen(constptr->name)+1); pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
nameofs+=strlen(constptr->name)+1; nameofs+=(int)strlen(constptr->name)+1;
count++; count++;
} /* if */ } /* if */
} /* for */ } /* for */
@ -1119,7 +1119,7 @@ static void append_dbginfo(FILE *fout)
if (prevstr!=NULL) { if (prevstr!=NULL) {
assert(prevname!=NULL); assert(prevname!=NULL);
dbghdr.files++; dbghdr.files++;
dbghdr.size+=sizeof(cell)+strlen(prevname)+1; dbghdr.size+=(int)(sizeof(cell)+strlen(prevname)+1);
} /* if */ } /* if */
previdx=codeidx; previdx=codeidx;
} /* if */ } /* if */
@ -1130,7 +1130,7 @@ static void append_dbginfo(FILE *fout)
if (prevstr!=NULL) { if (prevstr!=NULL) {
assert(prevname!=NULL); assert(prevname!=NULL);
dbghdr.files++; dbghdr.files++;
dbghdr.size+=sizeof(cell)+strlen(prevname)+1; dbghdr.size+=(int)(sizeof(cell)+strlen(prevname)+1);
} /* if */ } /* if */
/* line number table */ /* line number table */
@ -1151,7 +1151,7 @@ static void append_dbginfo(FILE *fout)
dbghdr.symbols++; dbghdr.symbols++;
name=strchr(str+2,':'); name=strchr(str+2,':');
assert(name!=NULL); assert(name!=NULL);
dbghdr.size+=sizeof(AMX_DBG_SYMBOL)+strlen(skipwhitespace(name+1)); dbghdr.size+=(int)(sizeof(AMX_DBG_SYMBOL)+strlen(skipwhitespace(name+1)));
if ((prevstr=strchr(name,'['))!=NULL) if ((prevstr=strchr(name,'['))!=NULL)
while ((prevstr=strchr(prevstr+1,':'))!=NULL) while ((prevstr=strchr(prevstr+1,':'))!=NULL)
dbghdr.size+=sizeof(AMX_DBG_SYMDIM); dbghdr.size+=sizeof(AMX_DBG_SYMDIM);
@ -1162,21 +1162,21 @@ static void append_dbginfo(FILE *fout)
for (constptr=tagname_tab.next; constptr!=NULL; constptr=constptr->next) { for (constptr=tagname_tab.next; constptr!=NULL; constptr=constptr->next) {
assert(strlen(constptr->name)>0); assert(strlen(constptr->name)>0);
dbghdr.tags++; dbghdr.tags++;
dbghdr.size+=sizeof(AMX_DBG_TAG)+strlen(constptr->name); dbghdr.size+=(int)(sizeof(AMX_DBG_TAG)+strlen(constptr->name));
} /* for */ } /* for */
/* automaton table */ /* automaton table */
for (constptr=sc_automaton_tab.next; constptr!=NULL; constptr=constptr->next) { for (constptr=sc_automaton_tab.next; constptr!=NULL; constptr=constptr->next) {
assert(constptr->index==0 && strlen(constptr->name)==0 || strlen(constptr->name)>0); assert(constptr->index==0 && strlen(constptr->name)==0 || strlen(constptr->name)>0);
dbghdr.automatons++; dbghdr.automatons++;
dbghdr.size+=sizeof(AMX_DBG_MACHINE)+strlen(constptr->name); dbghdr.size+=(int)(sizeof(AMX_DBG_MACHINE)+strlen(constptr->name));
} /* for */ } /* for */
/* state table */ /* state table */
for (constptr=sc_state_tab.next; constptr!=NULL; constptr=constptr->next) { for (constptr=sc_state_tab.next; constptr!=NULL; constptr=constptr->next) {
assert(strlen(constptr->name)>0); assert(strlen(constptr->name)>0);
dbghdr.states++; dbghdr.states++;
dbghdr.size+=sizeof(AMX_DBG_STATE)+strlen(constptr->name); dbghdr.size+=(int)(sizeof(AMX_DBG_STATE)+strlen(constptr->name));
} /* for */ } /* for */
@ -1210,7 +1210,7 @@ static void append_dbginfo(FILE *fout)
aligncell(&previdx); aligncell(&previdx);
#endif #endif
writeerror |= !pc_writebin(fout,&previdx,sizeof previdx); writeerror |= !pc_writebin(fout,&previdx,sizeof previdx);
writeerror |= !pc_writebin(fout,prevname,strlen(prevname)+1); writeerror |= !pc_writebin(fout,prevname,(int)strlen(prevname)+1);
} /* if */ } /* if */
previdx=codeidx; previdx=codeidx;
} /* if */ } /* if */
@ -1224,7 +1224,7 @@ static void append_dbginfo(FILE *fout)
aligncell(&previdx); aligncell(&previdx);
#endif #endif
writeerror |= !pc_writebin(fout,&previdx,sizeof previdx); writeerror |= !pc_writebin(fout,&previdx,sizeof previdx);
writeerror |= !pc_writebin(fout,prevname,strlen(prevname)+1); writeerror |= !pc_writebin(fout,prevname,(int)strlen(prevname)+1);
} /* if */ } /* if */
/* line number table */ /* line number table */
@ -1280,7 +1280,7 @@ static void append_dbginfo(FILE *fout)
align16(&dbgsym.dim); align16(&dbgsym.dim);
#endif #endif
writeerror |= !pc_writebin(fout,&dbgsym,offsetof(AMX_DBG_SYMBOL, name)); writeerror |= !pc_writebin(fout,&dbgsym,offsetof(AMX_DBG_SYMBOL, name));
writeerror |= !pc_writebin(fout,symname,strlen(symname)+1); writeerror |= !pc_writebin(fout,symname,(int)strlen(symname)+1);
for (dim=0; dim<dbgsymdim; dim++) { for (dim=0; dim<dbgsymdim; dim++) {
#if BYTE_ORDER==BIG_ENDIAN #if BYTE_ORDER==BIG_ENDIAN
align16(&dbgidxtag[dim].tag); align16(&dbgidxtag[dim].tag);
@ -1299,7 +1299,7 @@ static void append_dbginfo(FILE *fout)
align16(&id1); align16(&id1);
#endif #endif
writeerror |= !pc_writebin(fout,&id1,sizeof id1); writeerror |= !pc_writebin(fout,&id1,sizeof id1);
writeerror |= !pc_writebin(fout,constptr->name,strlen(constptr->name)+1); writeerror |= !pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
} /* for */ } /* for */
/* automaton table */ /* automaton table */
@ -1313,7 +1313,7 @@ static void append_dbginfo(FILE *fout)
#endif #endif
writeerror |= !pc_writebin(fout,&id1,sizeof id1); writeerror |= !pc_writebin(fout,&id1,sizeof id1);
writeerror |= !pc_writebin(fout,&address,sizeof address); writeerror |= !pc_writebin(fout,&address,sizeof address);
writeerror |= !pc_writebin(fout,constptr->name,strlen(constptr->name)+1); writeerror |= !pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
} /* for */ } /* for */
/* state table */ /* state table */
@ -1328,7 +1328,7 @@ static void append_dbginfo(FILE *fout)
#endif #endif
writeerror |= !pc_writebin(fout,&id1,sizeof id1); writeerror |= !pc_writebin(fout,&id1,sizeof id1);
writeerror |= !pc_writebin(fout,&id2,sizeof id2); writeerror |= !pc_writebin(fout,&id2,sizeof id2);
writeerror |= !pc_writebin(fout,constptr->name,strlen(constptr->name)+1); writeerror |= !pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
} /* for */ } /* for */
delete_dbgstringtable(); delete_dbgstringtable();

View File

@ -203,10 +203,10 @@ SC_FUNC void stgwrite(const char *st)
CHECK_STGBUFFER(stgidx); CHECK_STGBUFFER(stgidx);
stgbuf[stgidx++]='\0'; stgbuf[stgidx++]='\0';
} else { } else {
len=(stgbuf!=NULL) ? strlen(stgbuf) : 0; len=(stgbuf!=NULL) ? (int)strlen(stgbuf) : 0;
CHECK_STGBUFFER(len+strlen(st)+1); CHECK_STGBUFFER(len+(int)strlen(st)+1);
strcat(stgbuf,st); strcat(stgbuf,st);
len=strlen(stgbuf); len=(int)strlen(stgbuf);
if (len>0 && stgbuf[len-1]=='\n') { if (len>0 && stgbuf[len-1]=='\n') {
filewrite(stgbuf); filewrite(stgbuf);
stgbuf[0]='\0'; stgbuf[0]='\0';
@ -246,7 +246,7 @@ SC_FUNC void stgout(int index)
/* there is no sense in re-optimizing if the order of the sub-expressions /* there is no sense in re-optimizing if the order of the sub-expressions
* did not change; so output directly * did not change; so output directly
*/ */
for (idx=0; idx<pipeidx; idx+=strlen(stgpipe+idx)+1) for (idx=0; idx<pipeidx; idx+=(int)strlen(stgpipe+idx)+1)
filewrite(stgpipe+idx); filewrite(stgpipe+idx);
} /* if */ } /* if */
} /* if */ } /* if */
@ -569,7 +569,7 @@ static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+
var=atoi(lptr) - 1; var=atoi(lptr) - 1;
assert(var>=0 && var<MAX_OPT_VARS); assert(var>=0 && var<MAX_OPT_VARS);
assert(symbols[var][0]!='\0'); /* variable should be defined */ assert(symbols[var][0]!='\0'); /* variable should be defined */
*repl_length+=strlen(symbols[var]); *repl_length+=(int)strlen(symbols[var]);
break; break;
case '!': case '!':
*repl_length+=3; /* '\t', '\n' & '\0' */ *repl_length+=3; /* '\t', '\n' & '\0' */

View File

@ -213,14 +213,14 @@ SC_FUNC stringpair *insert_alias(char *name,char *alias)
assert(strlen(name)<=sNAMEMAX); assert(strlen(name)<=sNAMEMAX);
assert(alias!=NULL); assert(alias!=NULL);
assert(strlen(alias)<=sNAMEMAX); assert(strlen(alias)<=sNAMEMAX);
if ((cur=insert_stringpair(&alias_tab,name,alias,strlen(name)))==NULL) if ((cur=insert_stringpair(&alias_tab,name,alias,(int)strlen(name)))==NULL)
error(103); /* insufficient memory (fatal error) */ error(103); /* insufficient memory (fatal error) */
return cur; return cur;
} }
SC_FUNC int lookup_alias(char *target,char *name) SC_FUNC int lookup_alias(char *target,char *name)
{ {
stringpair *cur=find_stringpair(alias_tab.next,name,strlen(name)); stringpair *cur=find_stringpair(alias_tab.next,name,(int)strlen(name));
if (cur!=NULL) { if (cur!=NULL) {
assert(strlen(cur->second)<=sNAMEMAX); assert(strlen(cur->second)<=sNAMEMAX);
strcpy(target,cur->second); strcpy(target,cur->second);

View File

@ -113,7 +113,7 @@ unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size)
unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size) unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size)
{ {
return memfile_read(mf, buffer, size); return (unsigned int)memfile_read(mf, buffer, size);
} }
char *mfgets(MEMFILE *mf,char *string,unsigned int size) char *mfgets(MEMFILE *mf,char *string,unsigned int size)
@ -159,7 +159,7 @@ int mfputs(MEMFILE *mf,const char *string)
assert(mf!=NULL); assert(mf!=NULL);
length=strlen(string); length=(unsigned int)strlen(string);
written=mfwrite(mf,(unsigned char *)string,length); written=mfwrite(mf,(unsigned char *)string,length);
return written==length; return written==length;
} }