# Enable more warnings
if test "$GCC" = "yes"; then
- MORE_CFLAGS="$MORE_CFLAGS -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings"
+ MORE_CFLAGS="$MORE_CFLAGS -Waggregate-return -Wbad-function-cast -Wcast-align -Wcast-qual -Wconversion -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wsign-compare -Wstrict-prototypes -Wtraditional -Wwrite-strings"
fi
# Require Perl
# Turn warnings into errors
if test "$warnerror" = "yes"; then
if test "$GCC" = "yes"; then
- MORE_CFLAGS="$MORE_CFLAGS -Werror"
+ MORE_CFLAGS="$MORE_CFLAGS -Wno-conversion -Werror"
fi
fi
}
void
-yasm_ea_set_len(yasm_effaddr *ptr, unsigned char len)
+yasm_ea_set_len(yasm_effaddr *ptr, unsigned int len)
{
if (!ptr)
return;
* an explicit override, where we expect the user knows what they're doing.
*/
- ptr->len = len;
+ ptr->len = (unsigned char)len;
}
void
-yasm_ea_set_nosplit(yasm_effaddr *ptr, unsigned char nosplit)
+yasm_ea_set_nosplit(yasm_effaddr *ptr, unsigned int nosplit)
{
if (!ptr)
return;
- ptr->nosplit = nosplit;
+ ptr->nosplit = (unsigned char)nosplit;
}
/*@-nullstate@*/
}
yasm_bytecode *
-yasm_bc_new_data(yasm_datavalhead *datahead, unsigned char size,
+yasm_bc_new_data(yasm_datavalhead *datahead, unsigned int size,
unsigned long lindex)
{
bytecode_data *data;
yasm_bc_new_common(YASM_BC__DATA, sizeof(bytecode_data), lindex);
data->datahead = *datahead;
- data->size = size;
+ data->size = (unsigned char)size;
return (yasm_bytecode *)data;
}
yasm_bytecode *
-yasm_bc_new_reserve(yasm_expr *numitems, unsigned char itemsize,
+yasm_bc_new_reserve(yasm_expr *numitems, unsigned int itemsize,
unsigned long lindex)
{
bytecode_reserve *reserve;
/*@-mustfree@*/
reserve->numitems = numitems;
/*@=mustfree@*/
- reserve->itemsize = itemsize;
+ reserve->itemsize = (unsigned char)itemsize;
return (yasm_bytecode *)reserve;
}
N_("objfmt can't handle its own objfmt data bytecode"));
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
cur_arch->bc.bc_delete(bc);
else
yasm_internal_error(N_("Unknown bytecode type"));
fprintf(f, "%*sUNKNOWN\n", indent_level, "");
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
cur_arch->bc.bc_print(f, indent_level, bc);
else
fprintf(f, "%*s_Unknown_\n", indent_level, "");
yasm_internal_error(N_("resolving objfmt data bytecode?"));
/*break;*/
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
retval = cur_arch->bc.bc_resolve(bc, save, sect,
calc_bc_dist);
else
break;
case DV_EXPR:
if (output_expr(&dv->data.expn, bufp, bc_data->size,
- *bufp-bufp_orig, sect, bc, 0, d))
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0,
+ d))
return 1;
break;
case DV_STRING:
N_("Have objfmt data bytecode but no way to output it"));
break;
default:
- if (bc->type < cur_arch->bc.type_max)
+ if ((unsigned int)bc->type < (unsigned int)cur_arch->bc.type_max)
error = cur_arch->bc.bc_tobytes(bc, &destbuf, sect, d,
output_expr);
else
/*@only@*/ yasm_immval *yasm_imm_new_expr(/*@keep@*/ yasm_expr *e);
/*@observer@*/ const yasm_expr *yasm_ea_get_disp(const yasm_effaddr *ea);
-void yasm_ea_set_len(yasm_effaddr *ea, unsigned char len);
-void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned char nosplit);
+void yasm_ea_set_len(yasm_effaddr *ea, unsigned int len);
+void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned int nosplit);
void yasm_ea_delete(/*@only@*/ yasm_effaddr *ea);
void yasm_ea_print(FILE *f, int indent_level, const yasm_effaddr *ea);
size_t datasize,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_data(yasm_datavalhead *datahead,
- unsigned char size,
+ unsigned int size,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_reserve(/*@only@*/ yasm_expr *numitems,
- unsigned char itemsize,
+ unsigned int itemsize,
unsigned long lindex);
/*@only@*/ yasm_bytecode *yasm_bc_new_incbin
(/*@only@*/ char *filename, /*@only@*/ /*@null@*/ yasm_expr *start,
int retval;
BitVector_Negate(abs_bv, intn->val.bv);
- retval = Set_Max(abs_bv) < size*8;
+ retval = Set_Max(abs_bv) < (long)(size*8);
BitVector_Destroy(abs_bv);
return retval;
} else
- return (Set_Max(intn->val.bv) < size*8);
+ return (Set_Max(intn->val.bv) < (long)(size*8));
}
} else {
switch (intn->type) {
if (size >= 10)
return 1;
else
- return (Set_Max(intn->val.bv) < size*8);
+ return (Set_Max(intn->val.bv) < (long)(size*8));
}
}
return 0;
unsigned int
yasm_x86__get_reg_size(unsigned long reg)
{
- switch ((x86_expritem_reg_size)(reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(reg & ~0xFUL)) {
case X86_REG8:
case X86_REG8X:
return 1;
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};
- switch ((x86_expritem_reg_size)(reg&~0xF)) {
+ switch ((x86_expritem_reg_size)(reg & ~0xFUL)) {
case X86_REG8:
fprintf(f, "%s", name8[reg&0xF]);
break;
{
switch((x86_parse_insn_prefix)data[0]) {
case X86_LOCKREP:
- yasm_x86__bc_insn_set_lockrep_prefix(bc, (unsigned char)data[1],
+ yasm_x86__bc_insn_set_lockrep_prefix(bc, data[1] & 0xff,
lindex);
break;
case X86_ADDRSIZE:
- yasm_x86__bc_insn_addrsize_override(bc, (unsigned char)data[1]);
+ yasm_x86__bc_insn_addrsize_override(bc, data[1]);
break;
case X86_OPERSIZE:
- yasm_x86__bc_insn_opersize_override(bc, (unsigned char)data[1]);
+ yasm_x86__bc_insn_opersize_override(bc, data[1]);
break;
}
}
* in 64-bit mode or if it wasn't needed to express reg.
*/
int yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned char bits,
+ unsigned long reg, unsigned int bits,
x86_rex_bit_pos rexbit);
void yasm_x86__ea_set_segment(/*@null@*/ yasm_effaddr *ea,
- unsigned char segment, unsigned long lindex);
+ unsigned int segment, unsigned long lindex);
void yasm_x86__ea_set_disponly(yasm_effaddr *ea);
yasm_effaddr *yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex,
- unsigned char bits);
+ unsigned int bits);
yasm_effaddr *yasm_x86__ea_new_imm(/*@keep@*/ yasm_expr *imm,
- unsigned char im_len);
+ unsigned int im_len);
yasm_effaddr *yasm_x86__ea_new_expr(/*@keep@*/ yasm_expr *e);
/*@observer@*/ /*@null@*/ yasm_effaddr *yasm_x86__bc_insn_get_ea
(/*@null@*/ yasm_bytecode *bc);
void yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc,
- unsigned char opersize);
+ unsigned int opersize);
void yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc,
- unsigned char addrsize);
+ unsigned int addrsize);
void yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc,
- unsigned char prefix,
+ unsigned int prefix,
unsigned long lindex);
/* Structure with *all* inputs passed to x86_bytecode_new_insn().
yasm_output_expr_func output_expr);
int yasm_x86__expr_checkea
- (yasm_expr **ep, unsigned char *addrsize, unsigned char bits,
- unsigned char nosplit, unsigned char *displen, unsigned char *modrm,
+ (yasm_expr **ep, unsigned char *addrsize, unsigned int bits,
+ unsigned int nosplit, unsigned char *displen, unsigned char *modrm,
unsigned char *v_modrm, unsigned char *n_modrm, unsigned char *sib,
unsigned char *v_sib, unsigned char *n_sib, unsigned char *rex,
yasm_calc_bc_dist_func calc_bc_dist);
int
yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned char bits,
+ unsigned long reg, unsigned int bits,
x86_rex_bit_pos rexbit)
{
*low3 = (unsigned char)(reg&7);
if (bits == 64) {
- x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xF);
+ x86_expritem_reg_size size = (x86_expritem_reg_size)(reg & ~0xFUL);
if (size == X86_REG8X || (reg & 0xF) >= 8) {
if (*rex == 0xff)
/*@=compmempass =mustfree@*/
void
-yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned char segment,
+yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned int segment,
unsigned long lindex)
{
x86_effaddr *x86_ea = (x86_effaddr *)ea;
yasm__warning(YASM_WARN_GENERAL, lindex,
N_("multiple segment overrides, using leftmost"));
- x86_ea->segment = segment;
+ x86_ea->segment = (unsigned char)segment;
}
void
}
yasm_effaddr *
-yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned char bits)
+yasm_x86__ea_new_reg(unsigned long reg, unsigned char *rex, unsigned int bits)
{
x86_effaddr *x86_ea;
unsigned char rm;
/*@-compmempass@*/
yasm_effaddr *
-yasm_x86__ea_new_imm(yasm_expr *imm, unsigned char im_len)
+yasm_x86__ea_new_imm(yasm_expr *imm, unsigned int im_len)
{
x86_effaddr *x86_ea;
x86_ea = yasm_xmalloc(sizeof(x86_effaddr));
x86_ea->ea.disp = imm;
- x86_ea->ea.len = im_len;
+ x86_ea->ea.len = (unsigned char)im_len;
x86_ea->ea.nosplit = 0;
x86_ea->segment = 0;
x86_ea->modrm = 0;
}
void
-yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
+yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned int opersize)
{
x86_insn *insn;
x86_jmprel *jmprel;
switch ((x86_bytecode_type)bc->type) {
case X86_BC_INSN:
insn = (x86_insn *)bc;
- insn->opersize = opersize;
+ insn->opersize = (unsigned char)opersize;
break;
case X86_BC_JMPREL:
jmprel = (x86_jmprel *)bc;
- jmprel->opersize = opersize;
+ jmprel->opersize = (unsigned char)opersize;
break;
default:
yasm_internal_error(
}
void
-yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
+yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned int addrsize)
{
x86_insn *insn;
x86_jmprel *jmprel;
switch ((x86_bytecode_type)bc->type) {
case X86_BC_INSN:
insn = (x86_insn *)bc;
- insn->addrsize = addrsize;
+ insn->addrsize = (unsigned char)addrsize;
break;
case X86_BC_JMPREL:
jmprel = (x86_jmprel *)bc;
- jmprel->addrsize = addrsize;
+ jmprel->addrsize = (unsigned char)addrsize;
break;
default:
yasm_internal_error(
}
void
-yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned char prefix,
+yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned int prefix,
unsigned long lindex)
{
x86_insn *insn;
yasm__warning(YASM_WARN_GENERAL, lindex,
N_("multiple LOCK or REP prefixes, using leftmost"));
- *lockrep_pre = prefix;
+ *lockrep_pre = (unsigned char)prefix;
}
void
yasm_internal_error(N_("checkea failed"));
if (ea->disp) {
- if (output_expr(&ea->disp, bufp, ea->len, *bufp-bufp_orig,
- sect, bc, 0, d))
+ if (output_expr(&ea->disp, bufp, ea->len,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0,
+ d))
return 1;
} else {
/* 0 displacement, but we didn't know it before, so we have to
/* Immediate (if required) */
if (imm && imm->val) {
/* TODO: check imm->len vs. sized len from expr? */
- if (output_expr(&imm->val, bufp, imm->len, *bufp-bufp_orig, sect, bc,
- 0, d))
+ if (output_expr(&imm->val, bufp, imm->len,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 0, d))
return 1;
}
YASM_WRITE_8(*bufp, jmprel->shortop.opcode[i]);
/* Relative displacement */
- if (output_expr(&jmprel->target, bufp, 1, *bufp-bufp_orig, sect,
- bc, 1, d))
+ if (output_expr(&jmprel->target, bufp, 1,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 1, d))
return 1;
break;
case JR_NEAR_FORCED:
/* Relative displacement */
if (output_expr(&jmprel->target, bufp,
- (opersize == 32) ? 4UL : 2UL, *bufp-bufp_orig,
- sect, bc, 1, d))
+ (opersize == 32) ? 4UL : 2UL,
+ (unsigned long)(*bufp-bufp_orig), sect, bc, 1, d))
return 1;
break;
default:
N_("tried to do PC-relative offset from invalid sized value"));
val = yasm_intnum_get_uint(intn);
val -= bc->len;
- switch (valsize) {
+ switch ((unsigned int)valsize) {
case 1:
YASM_WRITE_8(*bufp, val);
break;
{
x86_checkea_reg3264_data *data = d;
- switch ((x86_expritem_reg_size)(ei->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) {
case X86_REG32:
if (data->addrsize != 32)
return 0;
reg16[7] = &data->di;
/* don't allow 32-bit registers */
- if ((ei->data.reg & ~0xF) != X86_REG16)
+ if ((ei->data.reg & ~0xFUL) != X86_REG16)
return 0;
/* & 7 for sanity check */
unsigned char *addrsize = (unsigned char *)d;
if (ei->type == YASM_EXPR_REG) {
- switch ((x86_expritem_reg_size)(ei->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(ei->data.reg & ~0xFUL)) {
case X86_REG16:
*addrsize = 16;
break;
int
yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
- unsigned char bits, unsigned char nosplit,
+ unsigned int bits, unsigned int nosplit,
unsigned char *displen, unsigned char *modrm,
unsigned char *v_modrm, unsigned char *n_modrm,
unsigned char *sib, unsigned char *v_sib,
* of register basereg is, as x86_set_rex_from_reg doesn't pay
* much attention.
*/
- if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
+ if (yasm_x86__set_rex_from_reg(rex, &low3,
+ (unsigned int)(X86_REG64 | basereg),
bits, X86_REX_B)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
if (basereg == REG3264_NONE)
*sib |= 5;
else {
- if (yasm_x86__set_rex_from_reg(rex, &low3, X86_REG64 | basereg,
- bits, X86_REX_B)) {
+ if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
+ (X86_REG64 | basereg), bits,
+ X86_REX_B)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
return 0;
*sib |= 040;
/* Any scale field is valid, just leave at 0. */
else {
- if (yasm_x86__set_rex_from_reg(rex, &low3,
- X86_REG64 | indexreg, bits,
+ if (yasm_x86__set_rex_from_reg(rex, &low3, (unsigned int)
+ (X86_REG64 | indexreg), bits,
X86_REX_X)) {
yasm__error(e->line,
N_("invalid combination of operands and effective address"));
0, lindex)), lindex);
/* See if the user explicitly specified short/near. */
- switch (jrinfo->operands[0] & OPTM_MASK) {
+ switch ((int)(jrinfo->operands[0] & OPTM_MASK)) {
case OPTM_Short:
d.op_sel = JR_SHORT_FORCED;
break;
if (info->opersize != d.opersize)
continue;
- switch (info->operands[0] & OPTM_MASK) {
+ switch ((int)(info->operands[0] & OPTM_MASK)) {
case OPTM_Short:
d.short_op_len = info->opcode_len;
d.short_op[0] = info->opcode[0];
for(i = 0, op = yasm_ops_first(operands); op && i<info->num_operands &&
!mismatch; op = yasm_ops_next(op), i++) {
/* Check operand type */
- switch (info->operands[i] & OPT_MASK) {
+ switch ((int)(info->operands[i] & OPT_MASK)) {
case OPT_Imm:
if (op->type != YASM_INSN__OPERAND_IMM)
mismatch = 1;
if (op->type != YASM_INSN__OPERAND_REG)
mismatch = 1;
else {
- switch ((x86_expritem_reg_size)(op->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) {
case X86_REG8:
case X86_REG8X:
case X86_REG16:
if (op->type != YASM_INSN__OPERAND_REG)
mismatch = 1;
else {
- switch ((x86_expritem_reg_size)(op->data.reg & ~0xF)) {
+ switch ((x86_expritem_reg_size)(op->data.reg&~0xFUL)) {
case X86_MMXREG:
case X86_XMMREG:
break;
break;
case OPT_CRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_CRREG)
+ (op->data.reg & ~0xFUL) != X86_CRREG)
mismatch = 1;
break;
case OPT_DRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_DRREG)
+ (op->data.reg & ~0xFUL) != X86_DRREG)
mismatch = 1;
break;
case OPT_TRReg:
if (op->type != YASM_INSN__OPERAND_REG ||
- (op->data.reg & ~0xF) != X86_TRREG)
+ (op->data.reg & ~0xFUL) != X86_TRREG)
mismatch = 1;
break;
case OPT_ST0:
break;
/* Check target modifier */
- switch (info->operands[i] & OPTM_MASK) {
+ switch ((int)(info->operands[i] & OPTM_MASK)) {
case OPTM_None:
if (op->targetmod != 0)
mismatch = 1;
}
/* Extended error/warning handling */
- switch (info->modifiers & MOD_Ext_MASK) {
+ switch ((int)(info->modifiers & MOD_Ext_MASK)) {
case MOD_ExtNone:
/* No extended modifier, so just continue */
break;
case MOD_ExtErr:
- switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
+ switch ((int)((info->modifiers & MOD_ExtIndex_MASK)
+ >> MOD_ExtIndex_SHIFT)) {
case 0:
yasm__error(lindex, N_("mismatch in operand sizes"));
break;
}
return NULL; /* It was an error */
case MOD_ExtWarn:
- switch ((info->modifiers & MOD_ExtIndex_MASK)>>MOD_ExtIndex_SHIFT) {
+ switch ((int)((info->modifiers & MOD_ExtIndex_MASK)
+ >> MOD_ExtIndex_SHIFT)) {
default:
yasm_internal_error(N_("unrecognized x86 ext mod index"));
}
}
if (info->modifiers & MOD_Imm8) {
d.imm = yasm_expr_new_ident(yasm_expr_int(
- yasm_intnum_new_int(mod_data & 0xFF)), lindex);
+ yasm_intnum_new_uint(mod_data & 0xFF)), lindex);
d.im_len = 1;
/*mod_data >>= 8;*/
}
if (operands) {
for(i = 0, op = yasm_ops_first(operands); op && i<info->num_operands;
op = yasm_ops_next(op), i++) {
- switch (info->operands[i] & OPA_MASK) {
+ switch ((int)(info->operands[i] & OPA_MASK)) {
case OPA_None:
/* Throw away the operand contents */
switch (op->type) {
yasm_internal_error(N_("unknown operand action"));
}
- switch (info->operands[i] & OPAP_MASK) {
+ switch ((int)(info->operands[i] & OPAP_MASK)) {
case OPAP_None:
break;
case OPAP_ShiftOp:
F C H S { RET_INSN(twobyte, 0xD9E0, CPU_FPU); }
F A B S { RET_INSN(twobyte, 0xD9E1, CPU_FPU); }
F N I N I T { RET_INSN(twobyte, 0xDBE3, CPU_FPU); }
- F I N I T { RET_INSN(threebyte, 0x98DBE3, CPU_FPU); }
+ F I N I T { RET_INSN(threebyte, 0x98DBE3UL, CPU_FPU); }
F L D C W { RET_INSN(fldnstcw, 0x05, CPU_FPU); }
F N S T C W { RET_INSN(fldnstcw, 0x07, CPU_FPU); }
F S T C W { RET_INSN(fstcw, 0, CPU_FPU); }
F N S T S W { RET_INSN(fnstsw, 0, CPU_FPU); }
F S T S W { RET_INSN(fstsw, 0, CPU_FPU); }
F N C L E X { RET_INSN(twobyte, 0xDBE2, CPU_FPU); }
- F C L E X { RET_INSN(threebyte, 0x98DBE2, CPU_FPU); }
+ F C L E X { RET_INSN(threebyte, 0x98DBE2UL, CPU_FPU); }
F N S T E N V { RET_INSN(onebytemem, 0x06D9, CPU_FPU); }
F S T E N V { RET_INSN(twobytemem, 0x069BD9, CPU_FPU); }
F L D E N V { RET_INSN(onebytemem, 0x04D9, CPU_FPU); }
info.buf = yasm_xmalloc(REGULAR_OUTBUF_SIZE);
/* Allocate space for headers by seeking forward */
- if (fseek(f, 20+40*(coff_objfmt_parse_scnum-1), SEEK_SET) < 0) {
+ if (fseek(f, (long)(20+40*(coff_objfmt_parse_scnum-1)), SEEK_SET) < 0) {
yasm__error(0, N_("could not seek on output file"));
return;
}
s.tok = cursor; \
}
-#define TOKLEN (cursor-s.tok)
+#define TOKLEN (size_t)(cursor-s.tok)
typedef struct Scanner {
YYCTYPE *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
if(!s.eof){
size_t cnt = s.tok - s.bot;
if(cnt){
- memcpy(s.bot, s.tok, s.lim - s.tok);
+ memcpy(s.bot, s.tok, (size_t)(s.lim - s.tok));
s.tok = s.bot;
s.ptr -= cnt;
cursor -= cnt;
if (!s.bot)
first = 1;
if((s.top - s.lim) < BSIZE){
- char *buf = yasm_xmalloc((s.lim - s.bot) + BSIZE);
- memcpy(buf, s.tok, s.lim - s.tok);
+ char *buf = yasm_xmalloc((size_t)(s.lim - s.bot) + BSIZE);
+ memcpy(buf, s.tok, (size_t)(s.lim - s.tok));
s.tok = buf;
s.ptr = &buf[s.ptr - s.bot];
cursor = &buf[cursor - s.bot];
e = scalarvect (nasm_reloc_value(e) << nasm_reloc_value(f));
break;
case TOKEN_SHR:
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) >>
- nasm_reloc_value(f));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) >>
+ nasm_reloc_value(f)));
break;
}
}
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
e = unknown_expr();
else
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) /
- ((unsigned long)nasm_reloc_value(f)));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) /
+ ((unsigned long)nasm_reloc_value(f))));
break;
case '%':
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
e = unknown_expr();
else
- e = scalarvect (((unsigned long)nasm_reloc_value(e)) %
- ((unsigned long)nasm_reloc_value(f)));
+ e = scalarvect ((long)(((unsigned long)nasm_reloc_value(e)) %
+ ((unsigned long)nasm_reloc_value(f))));
break;
case TOKEN_SDIV:
if (nasm_is_just_unknown(e) || nasm_is_just_unknown(f))
static char *
check_tasm_directive(char *line)
{
- int i, j, k, m, len;
+ int i, j, k, m;
+ size_t len;
char *p = line, *oldline, oldchar;
/* Skip whitespace */
static char *
prepreproc(char *line)
{
- int lineno, fnlen;
+ int lineno;
+ size_t fnlen;
char *fname, *oldline;
if (line[0] == '#' && line[1] == ' ')
fname++;
fnlen = strcspn(fname, "\"");
line = nasm_malloc(20 + fnlen);
- sprintf(line, "%%line %d %.*s", lineno, fnlen, fname);
+ sprintf(line, "%%line %d %.*s", lineno, (int)fnlen, fname);
nasm_free(oldline);
}
if (tasm_compatible_mode)
hash(char *s)
{
unsigned int h = 0;
- int i = 0;
+ unsigned int i = 0;
/*
* Powers of three, mod 31.
*/
{
long offset = p - buffer;
bufsize += BUF_DELTA;
- buffer = nasm_realloc(buffer, bufsize);
+ buffer = nasm_realloc(buffer, (size_t)bufsize);
p = buffer + offset; /* prevent stale-pointer problems */
}
}
{
if (txtlen == 0)
txtlen = strlen(text);
- t->text = nasm_malloc(1 + txtlen);
- strncpy(t->text, text, txtlen);
+ t->text = nasm_malloc(1 + (size_t)txtlen);
+ strncpy(t->text, text, (size_t)txtlen);
t->text[txtlen] = '\0';
}
return t;
len += strlen(t->text);
}
}
- p = line = nasm_malloc(len + 1);
+ p = line = nasm_malloc((size_t)len + 1);
for (t = tlist; t; t = t->next)
{
if (t->type == TOK_WHITESPACE)
macro_start = nasm_malloc(sizeof(*macro_start));
macro_start->next = NULL;
- make_tok_num(macro_start, strlen(t->text) - 2);
+ make_tok_num(macro_start, (int)strlen(t->text) - 2);
macro_start->mac = NULL;
/*
macro_start->next = NULL;
macro_start->text = nasm_strdup("'''");
if (evalresult->value > 0
- && evalresult->value < strlen(t->text) - 1)
+ && evalresult->value < (int)strlen(t->text) - 1)
{
macro_start->text[1] = t->text[evalresult->value];
}
void nasm_quote(char **str)
{
- int ln=strlen(*str);
+ size_t ln=strlen(*str);
char q=(*str)[0];
char *p;
if (ln>1 && (*str)[ln-1]==q && (q=='"' || q=='\''))
}
}
-void
+static void
replay_saved_tokens(char *ident,
struct source_head *from_head,
struct source_head *to_head,
yapp_preproc_input(char *buf, size_t max_size)
{
static YAPP_State state = YAPP_STATE_INITIAL;
- int n = 0;
+ size_t n = 0;
int token;
int need_line_directive = 0;
- while (saved_length < max_size && state != YAPP_STATE_EOF)
+ while ((size_t)saved_length < max_size && state != YAPP_STATE_EOF)
{
token = yapp_preproc_lex();
/* string/character constant values */
["'] {
- int inch, count;
+ int inch;
+ size_t count;
char endch = yytext[0];
strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);