From 3d16cdc67e66642e12279edeb5c90438e9dc7f21 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 13 Jul 2016 13:16:34 +0900 Subject: [PATCH] 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. --- src/bin/embryo/embryo_cc_amx.h | 1 + src/bin/embryo/embryo_cc_sc1.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/embryo/embryo_cc_amx.h b/src/bin/embryo/embryo_cc_amx.h index 0118e2d2af..5a00e525f8 100644 --- a/src/bin/embryo/embryo_cc_amx.h +++ b/src/bin/embryo/embryo_cc_amx.h @@ -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, diff --git a/src/bin/embryo/embryo_cc_sc1.c b/src/bin/embryo/embryo_cc_sc1.c index b53693495e..2ca1aaf559 100644 --- a/src/bin/embryo/embryo_cc_sc1.c +++ b/src/bin/embryo/embryo_cc_sc1.c @@ -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