Commit 519e1d69 authored by Paul Eggert's avatar Paul Eggert
Browse files

* ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'.

parent 847044ea
2011-05-23 Paul Eggert <eggert@cs.ucla.edu> 2011-05-23 Paul Eggert <eggert@cs.ucla.edu>
* ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'.
ccl: add integer overflow checks ccl: add integer overflow checks
* ccl.c (CCL_CODE_MAX, GET_CCL_RANGE, GET_CCL_CODE, GET_CCL_INT): * ccl.c (CCL_CODE_MAX, GET_CCL_RANGE, GET_CCL_CODE, GET_CCL_INT):
(IN_INT_RANGE): New macros. (IN_INT_RANGE): New macros.
......
...@@ -946,7 +946,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ...@@ -946,7 +946,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */ case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
i = reg[RRR]; i = reg[RRR];
j = field1 >> 3; j = field1 >> 3;
if ((unsigned int) i < j) if (0 <= i && i < j)
GET_CCL_INT (reg[rrr], ccl_prog, ic + i); GET_CCL_INT (reg[rrr], ccl_prog, ic + i);
ic += j; ic += j;
break; break;
...@@ -997,7 +997,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ...@@ -997,7 +997,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
i = reg[rrr]; i = reg[rrr];
GET_CCL_INT (j, ccl_prog, ic); GET_CCL_INT (j, ccl_prog, ic);
if ((unsigned int) i < j) if (0 <= i && i < j)
{ {
GET_CCL_INT (i, ccl_prog, ic + 1 + i); GET_CCL_INT (i, ccl_prog, ic + 1 + i);
CCL_WRITE_CHAR (i); CCL_WRITE_CHAR (i);
...@@ -1019,7 +1019,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ...@@ -1019,7 +1019,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
{ {
int incr; int incr;
GET_CCL_INT (incr, ccl_prog, GET_CCL_INT (incr, ccl_prog,
ic + ((unsigned int) reg[rrr] < field1 ic + (0 <= reg[rrr] && reg[rrr] < field1
? reg[rrr] ? reg[rrr]
: field1)); : field1));
ic += incr; ic += incr;
...@@ -1114,7 +1114,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size ...@@ -1114,7 +1114,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
i = reg[rrr]; i = reg[rrr];
if ((unsigned int) i < field1) if (0 <= i && i < field1)
{ {
GET_CCL_INT (j, ccl_prog, ic + i); GET_CCL_INT (j, ccl_prog, ic + i);
CCL_WRITE_CHAR (j); CCL_WRITE_CHAR (j);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment