]> granicus.if.org Git - yasm/commitdiff
Enable more warnings and perform code cleanups to avoid them.
authorPeter Johnson <peter@tortall.net>
Mon, 17 Mar 2003 00:03:02 +0000 (00:03 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 17 Mar 2003 00:03:02 +0000 (00:03 -0000)
When -Werror is used, disable -Wconversion, because flex-generated code causes
warnings when calling fwrite() and fread().

svn path=/trunk/yasm/; revision=873

16 files changed:
configure.ac
libyasm/bytecode.c
libyasm/bytecode.h
libyasm/intnum.c
modules/arch/x86/x86arch.c
modules/arch/x86/x86arch.h
modules/arch/x86/x86bc.c
modules/arch/x86/x86expr.c
modules/arch/x86/x86id.re
modules/objfmts/coff/coff-objfmt.c
modules/parsers/nasm/nasm-token.re
modules/preprocs/nasm/nasm-eval.c
modules/preprocs/nasm/nasm-pp.c
modules/preprocs/nasm/nasmlib.c
modules/preprocs/yapp/yapp-preproc.c
modules/preprocs/yapp/yapp-token.l

index fa37052f6f35e2a41b606953ca07a9a8d85c079a..f9a824d751821e8364b7a9e497914d8086ea58c2 100644 (file)
@@ -162,7 +162,7 @@ if test "$USE_MAINTAINER_MODE" = "yes"; then
 
   # 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
@@ -216,7 +216,7 @@ fi
 # 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
 
index 808677e77111b3b4549ad6c9877657b91aee6a5c..71801ae1b179502e457145b36ab1380564b5b453 100644 (file)
@@ -137,7 +137,7 @@ yasm_ea_get_disp(const yasm_effaddr *ptr)
 }
 
 void
-yasm_ea_set_len(yasm_effaddr *ptr, unsigned char len)
+yasm_ea_set_len(yasm_effaddr *ptr, unsigned int len)
 {
     if (!ptr)
        return;
@@ -146,16 +146,16 @@ yasm_ea_set_len(yasm_effaddr *ptr, unsigned char len)
      * 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@*/
@@ -212,7 +212,7 @@ yasm_bc_new_common(yasm_bytecode_type type, size_t size, unsigned long lindex)
 }
 
 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;
@@ -221,13 +221,13 @@ yasm_bc_new_data(yasm_datavalhead *datahead, unsigned char size,
        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;
@@ -238,7 +238,7 @@ yasm_bc_new_reserve(yasm_expr *numitems, unsigned char itemsize,
     /*@-mustfree@*/
     reserve->numitems = numitems;
     /*@=mustfree@*/
-    reserve->itemsize = itemsize;
+    reserve->itemsize = (unsigned char)itemsize;
 
     return (yasm_bytecode *)reserve;
 }
@@ -340,7 +340,7 @@ yasm_bc_delete(yasm_bytecode *bc)
                    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"));
@@ -414,7 +414,7 @@ yasm_bc_print(FILE *f, int indent_level, const yasm_bytecode *bc)
                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, "");
@@ -637,7 +637,7 @@ yasm_bc_resolve(yasm_bytecode *bc, int save, const yasm_section *sect,
            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
@@ -691,7 +691,8 @@ bc_tobytes_data(bytecode_data *bc_data, unsigned char **bufp,
                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:
@@ -834,7 +835,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize,
                    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
index 276633d576561201a9b05f9acc953e02d28efc36..30570221c7c6ac685ae4451f5b62aa38f75dfc54 100644 (file)
@@ -57,8 +57,8 @@ void yasm_bc_initialize(yasm_arch *a);
 /*@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);
 
@@ -68,10 +68,10 @@ void yasm_bc_set_multiple(yasm_bytecode *bc, /*@keep@*/ yasm_expr *e);
                                             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,
index 26312a48f33ddf171493f5ff50257e137e56f277..81b46d59c8fa76ffdc40837d7f4b1c26654f461a 100644 (file)
@@ -602,12 +602,12 @@ yasm_intnum_check_size(const yasm_intnum *intn, size_t size, int is_signed)
                    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) {
@@ -627,7 +627,7 @@ yasm_intnum_check_size(const yasm_intnum *intn, size_t size, int is_signed)
                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;
index 5441b279923dcb8cf08810dbba966b34cd5b5e46..4b44906f6f1d4fbdf21b45cf227cf21d93cd141d 100644 (file)
@@ -70,7 +70,7 @@ yasm_x86__directive(const char *name, yasm_valparamhead *valparams,
 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;
@@ -115,7 +115,7 @@ yasm_x86__reg_print(FILE *f, unsigned long reg)
        "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;
@@ -167,14 +167,14 @@ yasm_x86__handle_prefix(yasm_bytecode *bc, const unsigned long data[4],
 {
     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;
     }
 }
index 26cf2fb7e6470fc4e7485f0b5e82c8e43a962696..ec974693aa3ba5854eb7a4c274889cd749a82159 100644 (file)
@@ -85,27 +85,27 @@ typedef enum {
  * 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().
@@ -158,8 +158,8 @@ int yasm_x86__bc_tobytes(yasm_bytecode *bc, unsigned char **bufp,
                         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);
index fd4cf461213b90df203561ddaf3fd67799d104f4..d7cb4cbf2ad9c2dd3994bdb96343741f207457d2 100644 (file)
@@ -116,13 +116,13 @@ typedef struct x86_jmprel {
 
 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)
@@ -220,7 +220,7 @@ yasm_x86__bc_new_jmprel(x86_new_jmprel_data *d)
 /*@=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;
@@ -232,7 +232,7 @@ yasm_x86__ea_set_segment(yasm_effaddr *ea, unsigned char segment,
        yasm__warning(YASM_WARN_GENERAL, lindex,
                      N_("multiple segment overrides, using leftmost"));
 
-    x86_ea->segment = segment;
+    x86_ea->segment = (unsigned char)segment;
 }
 
 void
@@ -247,7 +247,7 @@ yasm_x86__ea_set_disponly(yasm_effaddr *ea)
 }
 
 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;
@@ -297,14 +297,14 @@ yasm_x86__ea_new_expr(yasm_expr *e)
 
 /*@-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;
@@ -331,7 +331,7 @@ yasm_x86__bc_insn_get_ea(yasm_bytecode *bc)
 }
 
 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;
@@ -342,11 +342,11 @@ yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
     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(
@@ -355,7 +355,7 @@ yasm_x86__bc_insn_opersize_override(yasm_bytecode *bc, unsigned char opersize)
 }
 
 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;
@@ -366,11 +366,11 @@ yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
     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(
@@ -379,7 +379,7 @@ yasm_x86__bc_insn_addrsize_override(yasm_bytecode *bc, unsigned char addrsize)
 }
 
 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;
@@ -407,7 +407,7 @@ yasm_x86__bc_insn_set_lockrep_prefix(yasm_bytecode *bc, unsigned char prefix,
        yasm__warning(YASM_WARN_GENERAL, lindex,
                      N_("multiple LOCK or REP prefixes, using leftmost"));
 
-    *lockrep_pre = prefix;
+    *lockrep_pre = (unsigned char)prefix;
 }
 
 void
@@ -898,8 +898,9 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
                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
@@ -914,8 +915,8 @@ x86_bc_tobytes_insn(x86_insn *insn, unsigned char **bufp,
     /* 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;
     }
 
@@ -957,8 +958,8 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
                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:
@@ -975,8 +976,8 @@ x86_bc_tobytes_jmprel(x86_jmprel *jmprel, unsigned char **bufp,
 
            /* 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:
@@ -1015,7 +1016,7 @@ yasm_x86__intnum_tobytes(const yasm_intnum *intn, unsigned char **bufp,
                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;
index 972ff9536f468172900725fd0be5261c208ab4fd..e218fd2264f78226531ae6a87c455367b677efaa 100644 (file)
@@ -47,7 +47,7 @@ x86_expr_checkea_get_reg3264(yasm_expr__item *ei, int *regnum,
 {
     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;
@@ -97,7 +97,7 @@ x86_expr_checkea_get_reg16(yasm_expr__item *ei, int *regnum, void *d)
     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 */
@@ -491,7 +491,7 @@ x86_expr_checkea_getregsize_callback(yasm_expr__item *ei, void *d)
     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;
@@ -512,7 +512,7 @@ x86_expr_checkea_getregsize_callback(yasm_expr__item *ei, void *d)
 
 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,
@@ -740,7 +740,8 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
             * 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"));
@@ -769,8 +770,9 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
            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;
@@ -783,8 +785,8 @@ yasm_x86__expr_checkea(yasm_expr **ep, unsigned char *addrsize,
                *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"));
index 37d55564dbac6d53ab6e8a9b895980e31b82ba58..8b5619e3c1b5cae71be904adfb095d894ceee724 100644 (file)
@@ -1532,7 +1532,7 @@ x86_new_jmprel(const unsigned long data[4], int num_operands,
                                               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;
@@ -1585,7 +1585,7 @@ x86_new_jmprel(const unsigned long data[4], int num_operands,
        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];
@@ -1655,7 +1655,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
        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;
@@ -1668,7 +1668,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
                    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:
@@ -1694,7 +1694,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
                    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;
@@ -1710,17 +1710,17 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
                    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:
@@ -1837,7 +1837,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
                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;
@@ -1876,12 +1876,13 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
     }
 
     /* 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;
@@ -1893,7 +1894,8 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
            }
            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"));
            }
@@ -1950,7 +1952,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
     }
     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;*/
     }
@@ -1959,7 +1961,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
     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) {
@@ -2070,7 +2072,7 @@ yasm_x86__new_insn(const unsigned long data[4], int num_operands,
                    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:
@@ -3159,14 +3161,14 @@ yasm_x86__check_identifier(unsigned long data[4], const char *id,
        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); }
index cc26ca43313ab54cc323978c21ccae1fbcb369f5..d6da34060d21b725cf47af9641de523ffe8e1a0a 100644 (file)
@@ -508,7 +508,7 @@ coff_objfmt_output(FILE *f, yasm_sectionhead *sections)
     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;
     }
index 854ecc06adca3f33c0da9e940cca148dbf02e943..af1b45e5495a4063fc4ee551ae59095bd0f17036 100644 (file)
@@ -51,7 +51,7 @@ RCSID("$IdPath$");
        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;
@@ -70,7 +70,7 @@ fill(YYCTYPE *cursor)
     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;
@@ -80,8 +80,8 @@ fill(YYCTYPE *cursor)
        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];
index 1991a4d19028ce3bbe5a9b43d763c556f8ba75c6..942f4c8bb96255735a86a181466a1a72e25e9939 100644 (file)
@@ -511,8 +511,8 @@ static nasm_expr *expr3(int critical)
            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;
        }
     }
@@ -589,15 +589,15 @@ static nasm_expr *expr5(int critical)
            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))
index 9d8c30eb39bd32b54fa393c703a5dbcfd5f3a4e7..012531d52e9193cbc309a96109d9a0961b23dd5b 100644 (file)
@@ -445,7 +445,8 @@ static Token *delete_Token(Token * t);
 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 */
@@ -513,7 +514,8 @@ check_tasm_directive(char *line)
 static char *
 prepreproc(char *line)
 {
-    int lineno, fnlen;
+    int lineno;
+    size_t fnlen;
     char *fname, *oldline;
 
     if (line[0] == '#' && line[1] == ' ')
@@ -526,7 +528,7 @@ prepreproc(char *line)
            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)
@@ -544,7 +546,7 @@ static int
 hash(char *s)
 {
     unsigned int h = 0;
-    int i = 0;
+    unsigned int i = 0;
     /*
      * Powers of three, mod 31.
      */
@@ -722,7 +724,7 @@ read_line(void)
        {
            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 */
        }
     }
@@ -988,8 +990,8 @@ new_Token(Token * next, int type, const char *text, int txtlen)
     {
        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;
@@ -1056,7 +1058,7 @@ detoken(Token * tlist, int expand_locals)
            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)
@@ -2812,7 +2814,7 @@ do_directive(Token * tline)
 
            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;
 
            /*
@@ -2912,7 +2914,7 @@ do_directive(Token * tline)
            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];
            }
index 6b025dfd4bd11deb709deaa034b00183c2e5f567..d74d053f4c8d71ed666b80f41a3b1abbb30ec952 100644 (file)
@@ -344,7 +344,7 @@ int nasm_src_get(long *xline, char **xname)
 
 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=='\''))
index 593437295d9044693faa3ba4f53e4f63b2927cdb..68e154e428b0f388390b3a4fb993d2a1d0efd539 100644 (file)
@@ -418,7 +418,7 @@ append_token(int token, struct source_head *to_head, source **to_tail)
     }
 }
 
-void
+static void
 replay_saved_tokens(char *ident,
                    struct source_head *from_head,
                    struct source_head *to_head,
@@ -748,11 +748,11 @@ static size_t
 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();
 
index 8423430ec33a61339f8dbab9119795e4114f6650..7889ea3f73ebc0422c26e9471f214174f9de248a 100644 (file)
@@ -122,7 +122,8 @@ DIR  %[ \t]*
 
     /* string/character constant values */
 ["']   {
-    int inch, count;
+    int inch;
+    size_t count;
     char endch = yytext[0];
 
     strbuf = yasm_xmalloc(STRBUF_ALLOC_SIZE);