embro_cc: Shut up some coverity warning

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.
This commit is contained in:
Jean-Philippe Andre 2016-07-13 13:16:34 +09:00
parent bed1e28d85
commit 3d16cdc67e
2 changed files with 4 additions and 3 deletions

View 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,

View 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