romcc: Fix off-by-one
Arrays are indexed 0..(number_of_element-1). Change-Id: I2157e74340568636d588113d1d2d8cae50082da2 Found-by: Coverity Scan Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/4089 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins)
This commit is contained in:
		@@ -898,7 +898,7 @@ static const char *tops(int index)
 | 
			
		||||
	if (index < 0) {
 | 
			
		||||
		return unknown;
 | 
			
		||||
	}
 | 
			
		||||
	if (index > OP_MAX) {
 | 
			
		||||
	if (index >= OP_MAX) {
 | 
			
		||||
		return unknown;
 | 
			
		||||
	}
 | 
			
		||||
	return table_ops[index].name;
 | 
			
		||||
@@ -10398,7 +10398,7 @@ static void simplify(struct compile_state *state, struct triple *ins)
 | 
			
		||||
	do {
 | 
			
		||||
		op = ins->op;
 | 
			
		||||
		do_simplify = 0;
 | 
			
		||||
		if ((op < 0) || (op > sizeof(table_simplify)/sizeof(table_simplify[0]))) {
 | 
			
		||||
		if ((op < 0) || (op >= sizeof(table_simplify)/sizeof(table_simplify[0]))) {
 | 
			
		||||
			do_simplify = 0;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user