embro_cc: Shut up some coverity warning
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 13 Jul 2016 04:16:34 +0000 (13:16 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 13 Jul 2016 04:19:01 +0000 (13:19 +0900)
CID 1039677 1039678 1039679

The expression's value does not depend on the operands; often,
this represents an inadvertent logic error.

In doarg: An operation with non-constant operands that
computes a result with constant value (CWE-569)

cell is defined as an int, not a long, so it can't be > INT_MAX.

src/bin/embryo/embryo_cc_amx.h
src/bin/embryo/embryo_cc_sc1.c

index 0118e2d..5a00e52 100644 (file)
@@ -47,6 +47,7 @@
    typedef unsigned int    ucell;
    typedef int     cell;
 #endif
+#define CELL_MAX INT_MAX        /* assume cell is always int */
 
    struct tagAMX;
    typedef             cell(*AMX_NATIVE) (struct tagAMX * amx,
index b536934..2ca1aaf 100644 (file)
@@ -1071,7 +1071,7 @@ declglb(char *firstname, int firsttag, int fpublic, int fstatic,
                error(52);      /* only last dimension may be variable length */
             size = needsub(&idxtag[numdim]);   /* get size; size==0 for
                                                 * "var[]" */
-#if INT_MAX < LONG_MAX
+#if INT_MAX < CELL_MAX
             if (size > INT_MAX)
                error(105);     /* overflow, exceeding capacity */
 #endif
@@ -1212,7 +1212,7 @@ declloc(int fstatic)
             if (numdim > 0 && dim[numdim - 1] == 0)
                error(52);      /* only last dimension may be variable length */
             size = needsub(&idxtag[numdim]);   /* get size; size==0 for "var[]" */
-#if INT_MAX < LONG_MAX
+#if INT_MAX < CELL_MAX
             if (size > INT_MAX)
                error(105);     /* overflow, exceeding capacity */
 #endif
@@ -2668,7 +2668,7 @@ doarg(char *name, int ident, int offset, int tags[], int numtags,
              */
             size = needsub(&idxtag[arg->numdim]);      /* may be zero here,
                                                         *it is a pointer anyway */
-#if INT_MAX < LONG_MAX
+#if INT_MAX < CELL_MAX
             if (size > INT_MAX)
                error(105);     /* overflow, exceeding capacity */
 #endif