[PATCH] parse: Fix sign extension in casting enums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem is the sign isn't extended properly when this casts an int
to a long.  The expr->ctype has to be the original int ctype for the
cast_value() call so that the "value = get_longlong(old);" expansion
works correctly.

Fixes: 604a148a73af ("enum: fix cast_enum_list()")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 parse.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/parse.c b/parse.c
index 7954343..5ced2f4 100644
--- a/parse.c
+++ b/parse.c
@@ -890,10 +890,12 @@ static void cast_enum_list(struct symbol_list *list, struct symbol *base_type)
 			expr->ctype = &int_ctype;
 			continue;
 		}
-		expr->ctype = base_type;
-		if (ctype->bit_size == base_type->bit_size)
+		if (ctype->bit_size == base_type->bit_size) {
+			expr->ctype = base_type;
 			continue;
+		}
 		cast_value(expr, base_type, expr, ctype);
+		expr->ctype = base_type;
 	} END_FOR_EACH_PTR(sym);
 }
 
-- 
2.20.1




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux