Fix "possible loss of data" warnings in x64 Windows build
This commit is contained in:
parent
e35f9c9a21
commit
e5dc717491
@ -76,7 +76,7 @@ size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize)
|
||||
|
||||
memcpy(buffer, mf->base + mf->offs, maxsize);
|
||||
|
||||
mf->offs += maxsize;
|
||||
mf->offs += (long)maxsize;
|
||||
|
||||
return maxsize;
|
||||
}
|
||||
@ -98,7 +98,7 @@ int memfile_write(memfile_t *mf, const void *buffer, size_t size)
|
||||
mf->size = newsize;
|
||||
}
|
||||
memcpy(mf->base + mf->offs, buffer, size);
|
||||
mf->offs += size;
|
||||
mf->offs += (long)size;
|
||||
|
||||
if (mf->offs > mf->usedoffs)
|
||||
{
|
||||
|
@ -1043,7 +1043,7 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
|
||||
#endif
|
||||
case 'i':
|
||||
strlcpy(str,option_value(ptr),sizeof str); /* set name of include directory */
|
||||
i=strlen(str);
|
||||
i=(int)strlen(str);
|
||||
if (i>0) {
|
||||
if (str[i-1]!=DIRSEP_CHAR) {
|
||||
str[i]=DIRSEP_CHAR;
|
||||
@ -1316,7 +1316,7 @@ static void setconfig(char *root)
|
||||
*(ptr+1)='\0';
|
||||
base=ptr;
|
||||
strcat(path,"include");
|
||||
len=strlen(path);
|
||||
len=(int)strlen(path);
|
||||
path[len]=DIRSEP_CHAR;
|
||||
path[len+1]='\0';
|
||||
/* see if it exists */
|
||||
@ -1329,7 +1329,7 @@ static void setconfig(char *root)
|
||||
if ((ptr=strrchr(path,DIRSEP_CHAR))!=NULL) {
|
||||
*(ptr+1)='\0';
|
||||
strcat(path,"include");
|
||||
len=strlen(path);
|
||||
len=(int)strlen(path);
|
||||
path[len]=DIRSEP_CHAR;
|
||||
path[len+1]='\0';
|
||||
} else {
|
||||
@ -4008,9 +4008,9 @@ static int find_xmltag(char *source,char *xmltag,char *xmlparam,char *xmlvalue,
|
||||
/* both NULL or both non-NULL */
|
||||
assert(xmlvalue!=NULL && xmlparam!=NULL || xmlvalue==NULL && xmlparam==NULL);
|
||||
|
||||
xmltag_len=strlen(xmltag);
|
||||
xmlparam_len= (xmlparam!=NULL) ? strlen(xmlparam) : 0;
|
||||
xmlvalue_len= (xmlvalue!=NULL) ? strlen(xmlvalue) : 0;
|
||||
xmltag_len=(int)strlen(xmltag);
|
||||
xmlparam_len= (xmlparam!=NULL) ? (int)strlen(xmlparam) : 0;
|
||||
xmlvalue_len= (xmlvalue!=NULL) ? (int)strlen(xmlvalue) : 0;
|
||||
ptr=source;
|
||||
/* find an opening '<' */
|
||||
while ((ptr=strchr(ptr,'<'))!=NULL) {
|
||||
@ -5924,10 +5924,10 @@ static void dostate(void)
|
||||
listid=-1;
|
||||
} /* if */
|
||||
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 */
|
||||
for (index=0; (str=get_autolist(index))!=NULL; index++)
|
||||
length+=strlen(str);
|
||||
length+=(int)strlen(str);
|
||||
if ((doc=(char*)malloc(length*sizeof(char)))!=NULL) {
|
||||
do {
|
||||
sprintf(doc,"<transition target=\"%s\"",name);
|
||||
|
@ -377,7 +377,7 @@ static void readline(unsigned char *line)
|
||||
*ptr='\0'; /* erase '\n' (and any trailing whitespace) */
|
||||
} /* if */
|
||||
} /* if */
|
||||
num-=strlen((char*)line);
|
||||
num-=(int)strlen((char*)line);
|
||||
line+=strlen((char*)line);
|
||||
} /* if */
|
||||
fline+=1;
|
||||
@ -1385,7 +1385,7 @@ static int command(void)
|
||||
case tpUNDEF:
|
||||
if (!SKIPPING) {
|
||||
if (lex(&val,&str)==tSYMBOL) {
|
||||
ret=delete_subst(str,strlen(str));
|
||||
ret=delete_subst(str,(int)strlen(str));
|
||||
if (!ret) {
|
||||
/* also undefine normal constants */
|
||||
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';
|
||||
assert(arg>=0 && arg<=9);
|
||||
if (args[arg]!=NULL)
|
||||
len+=strlen((char*)args[arg]);
|
||||
len+=(int)strlen((char*)args[arg]);
|
||||
else
|
||||
len+=2; /* copy '%' plus digit */
|
||||
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)
|
||||
{
|
||||
const unsigned char *ptr=(const unsigned char *)name;
|
||||
int len=strlen(name);
|
||||
int len=(int)strlen(name);
|
||||
if (len==0)
|
||||
return 0L;
|
||||
assert(len<256);
|
||||
|
@ -1310,7 +1310,7 @@ static int hier2(value *lval)
|
||||
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" */
|
||||
val= (sym!=NULL);
|
||||
if (!val && find_subst(st,strlen(st))!=NULL)
|
||||
if (!val && find_subst(st,(int)strlen(st))!=NULL)
|
||||
val=1;
|
||||
clear_value(lval);
|
||||
lval->ident=iCONSTEXPR;
|
||||
|
@ -755,7 +755,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
assert(strlen(sym->name)<=sNAMEMAX);
|
||||
strcpy(alias,sym->name);
|
||||
} /* if */
|
||||
nametablesize+=strlen(alias)+1;
|
||||
nametablesize+=(int)strlen(alias)+1;
|
||||
} /* if */
|
||||
} /* for */
|
||||
assert(numnatives==ntv_funcid);
|
||||
@ -767,7 +767,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
if (constptr->value>0) {
|
||||
assert(strlen(constptr->name)>0);
|
||||
numlibraries++;
|
||||
nametablesize+=strlen(constptr->name)+1;
|
||||
nametablesize+=(int)strlen(constptr->name)+1;
|
||||
} /* if */
|
||||
} /* for */
|
||||
} /* if */
|
||||
@ -778,7 +778,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
if ((constptr->value & PUBLICTAG)!=0) {
|
||||
assert(strlen(constptr->name)>0);
|
||||
numtags++;
|
||||
nametablesize+=strlen(constptr->name)+1;
|
||||
nametablesize+=(int)strlen(constptr->name)+1;
|
||||
} /* if */
|
||||
} /* for */
|
||||
|
||||
@ -841,8 +841,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
pc_resetbin(fout,hdr.publics+count*sizeof(AMX_FUNCSTUBNT));
|
||||
pc_writebin(fout,&func,sizeof func);
|
||||
pc_resetbin(fout,nameofs);
|
||||
pc_writebin(fout,sym->name,strlen(sym->name)+1);
|
||||
nameofs+=strlen(sym->name)+1;
|
||||
pc_writebin(fout,sym->name,(int)strlen(sym->name)+1);
|
||||
nameofs+=(int)strlen(sym->name)+1;
|
||||
count++;
|
||||
} /* if */
|
||||
} /* for */
|
||||
@ -890,8 +890,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
pc_resetbin(fout,hdr.natives+count*sizeof(AMX_FUNCSTUBNT));
|
||||
pc_writebin(fout,&func,sizeof func);
|
||||
pc_resetbin(fout,nameofs);
|
||||
pc_writebin(fout,alias,strlen(alias)+1);
|
||||
nameofs+=strlen(alias)+1;
|
||||
pc_writebin(fout,alias,(int)strlen(alias)+1);
|
||||
nameofs+=(int)strlen(alias)+1;
|
||||
count++;
|
||||
} /* for */
|
||||
free(nativelist);
|
||||
@ -912,8 +912,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
pc_resetbin(fout,hdr.libraries+count*sizeof(AMX_FUNCSTUBNT));
|
||||
pc_writebin(fout,&func,sizeof func);
|
||||
pc_resetbin(fout,nameofs);
|
||||
pc_writebin(fout,constptr->name,strlen(constptr->name)+1);
|
||||
nameofs+=strlen(constptr->name)+1;
|
||||
pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
|
||||
nameofs+=(int)strlen(constptr->name)+1;
|
||||
count++;
|
||||
} /* if */
|
||||
} /* for */
|
||||
@ -934,8 +934,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
pc_resetbin(fout,hdr.pubvars+count*sizeof(AMX_FUNCSTUBNT));
|
||||
pc_writebin(fout,&func,sizeof func);
|
||||
pc_resetbin(fout,nameofs);
|
||||
pc_writebin(fout,sym->name,strlen(sym->name)+1);
|
||||
nameofs+=strlen(sym->name)+1;
|
||||
pc_writebin(fout,sym->name,(int)strlen(sym->name)+1);
|
||||
nameofs+=(int)strlen(sym->name)+1;
|
||||
count++;
|
||||
} /* if */
|
||||
} /* for */
|
||||
@ -954,8 +954,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
pc_resetbin(fout,hdr.tags+count*sizeof(AMX_FUNCSTUBNT));
|
||||
pc_writebin(fout,&func,sizeof func);
|
||||
pc_resetbin(fout,nameofs);
|
||||
pc_writebin(fout,constptr->name,strlen(constptr->name)+1);
|
||||
nameofs+=strlen(constptr->name)+1;
|
||||
pc_writebin(fout,constptr->name,(int)strlen(constptr->name)+1);
|
||||
nameofs+=(int)strlen(constptr->name)+1;
|
||||
count++;
|
||||
} /* if */
|
||||
} /* for */
|
||||
@ -1119,7 +1119,7 @@ static void append_dbginfo(FILE *fout)
|
||||
if (prevstr!=NULL) {
|
||||
assert(prevname!=NULL);
|
||||
dbghdr.files++;
|
||||
dbghdr.size+=sizeof(cell)+strlen(prevname)+1;
|
||||
dbghdr.size+=(int)(sizeof(cell)+strlen(prevname)+1);
|
||||
} /* if */
|
||||
previdx=codeidx;
|
||||
} /* if */
|
||||
@ -1130,7 +1130,7 @@ static void append_dbginfo(FILE *fout)
|
||||
if (prevstr!=NULL) {
|
||||
assert(prevname!=NULL);
|
||||
dbghdr.files++;
|
||||
dbghdr.size+=sizeof(cell)+strlen(prevname)+1;
|
||||
dbghdr.size+=(int)(sizeof(cell)+strlen(prevname)+1);
|
||||
} /* if */
|
||||
|
||||
/* line number table */
|
||||
@ -1151,7 +1151,7 @@ static void append_dbginfo(FILE *fout)
|
||||
dbghdr.symbols++;
|
||||
name=strchr(str+2,':');
|
||||
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)
|
||||
while ((prevstr=strchr(prevstr+1,':'))!=NULL)
|
||||
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) {
|
||||
assert(strlen(constptr->name)>0);
|
||||
dbghdr.tags++;
|
||||
dbghdr.size+=sizeof(AMX_DBG_TAG)+strlen(constptr->name);
|
||||
dbghdr.size+=(int)(sizeof(AMX_DBG_TAG)+strlen(constptr->name));
|
||||
} /* for */
|
||||
|
||||
/* automaton table */
|
||||
for (constptr=sc_automaton_tab.next; constptr!=NULL; constptr=constptr->next) {
|
||||
assert(constptr->index==0 && strlen(constptr->name)==0 || strlen(constptr->name)>0);
|
||||
dbghdr.automatons++;
|
||||
dbghdr.size+=sizeof(AMX_DBG_MACHINE)+strlen(constptr->name);
|
||||
dbghdr.size+=(int)(sizeof(AMX_DBG_MACHINE)+strlen(constptr->name));
|
||||
} /* for */
|
||||
|
||||
/* state table */
|
||||
for (constptr=sc_state_tab.next; constptr!=NULL; constptr=constptr->next) {
|
||||
assert(strlen(constptr->name)>0);
|
||||
dbghdr.states++;
|
||||
dbghdr.size+=sizeof(AMX_DBG_STATE)+strlen(constptr->name);
|
||||
dbghdr.size+=(int)(sizeof(AMX_DBG_STATE)+strlen(constptr->name));
|
||||
} /* for */
|
||||
|
||||
|
||||
@ -1210,7 +1210,7 @@ static void append_dbginfo(FILE *fout)
|
||||
aligncell(&previdx);
|
||||
#endif
|
||||
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 */
|
||||
previdx=codeidx;
|
||||
} /* if */
|
||||
@ -1224,7 +1224,7 @@ static void append_dbginfo(FILE *fout)
|
||||
aligncell(&previdx);
|
||||
#endif
|
||||
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 */
|
||||
|
||||
/* line number table */
|
||||
@ -1280,7 +1280,7 @@ static void append_dbginfo(FILE *fout)
|
||||
align16(&dbgsym.dim);
|
||||
#endif
|
||||
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++) {
|
||||
#if BYTE_ORDER==BIG_ENDIAN
|
||||
align16(&dbgidxtag[dim].tag);
|
||||
@ -1299,7 +1299,7 @@ static void append_dbginfo(FILE *fout)
|
||||
align16(&id1);
|
||||
#endif
|
||||
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 */
|
||||
|
||||
/* automaton table */
|
||||
@ -1313,7 +1313,7 @@ static void append_dbginfo(FILE *fout)
|
||||
#endif
|
||||
writeerror |= !pc_writebin(fout,&id1,sizeof id1);
|
||||
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 */
|
||||
|
||||
/* state table */
|
||||
@ -1328,7 +1328,7 @@ static void append_dbginfo(FILE *fout)
|
||||
#endif
|
||||
writeerror |= !pc_writebin(fout,&id1,sizeof id1);
|
||||
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 */
|
||||
|
||||
delete_dbgstringtable();
|
||||
|
@ -203,10 +203,10 @@ SC_FUNC void stgwrite(const char *st)
|
||||
CHECK_STGBUFFER(stgidx);
|
||||
stgbuf[stgidx++]='\0';
|
||||
} else {
|
||||
len=(stgbuf!=NULL) ? strlen(stgbuf) : 0;
|
||||
CHECK_STGBUFFER(len+strlen(st)+1);
|
||||
len=(stgbuf!=NULL) ? (int)strlen(stgbuf) : 0;
|
||||
CHECK_STGBUFFER(len+(int)strlen(st)+1);
|
||||
strcat(stgbuf,st);
|
||||
len=strlen(stgbuf);
|
||||
len=(int)strlen(stgbuf);
|
||||
if (len>0 && stgbuf[len-1]=='\n') {
|
||||
filewrite(stgbuf);
|
||||
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
|
||||
* 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);
|
||||
} /* if */
|
||||
} /* if */
|
||||
@ -569,7 +569,7 @@ static char *replacesequence(char *pattern,char symbols[MAX_OPT_VARS][MAX_ALIAS+
|
||||
var=atoi(lptr) - 1;
|
||||
assert(var>=0 && var<MAX_OPT_VARS);
|
||||
assert(symbols[var][0]!='\0'); /* variable should be defined */
|
||||
*repl_length+=strlen(symbols[var]);
|
||||
*repl_length+=(int)strlen(symbols[var]);
|
||||
break;
|
||||
case '!':
|
||||
*repl_length+=3; /* '\t', '\n' & '\0' */
|
||||
|
@ -213,14 +213,14 @@ SC_FUNC stringpair *insert_alias(char *name,char *alias)
|
||||
assert(strlen(name)<=sNAMEMAX);
|
||||
assert(alias!=NULL);
|
||||
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) */
|
||||
return cur;
|
||||
}
|
||||
|
||||
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) {
|
||||
assert(strlen(cur->second)<=sNAMEMAX);
|
||||
strcpy(target,cur->second);
|
||||
|
@ -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)
|
||||
{
|
||||
return memfile_read(mf, buffer, size);
|
||||
return (unsigned int)memfile_read(mf, buffer, size);
|
||||
}
|
||||
|
||||
char *mfgets(MEMFILE *mf,char *string,unsigned int size)
|
||||
@ -159,7 +159,7 @@ int mfputs(MEMFILE *mf,const char *string)
|
||||
|
||||
assert(mf!=NULL);
|
||||
|
||||
length=strlen(string);
|
||||
length=(unsigned int)strlen(string);
|
||||
written=mfwrite(mf,(unsigned char *)string,length);
|
||||
return written==length;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user