[PATCH 3/3] fix sign extension in casting enums

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

 



From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

The function cast_value() needs the exact type of the old expression
but when called via cast_enum_list() this type is incorrect because:
- the same struct is used for the new and the old expression
- the type of the new expression is adjusted before cast_value()
  is called.

Fix this by adjusting the type of the new expression only after
cast_value() has been called.

Fixes: 604a148a73af ("enum: fix cast_enum_list()")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 parse.c                       | 2 +-
 validation/enum-sign-extend.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/parse.c b/parse.c
index 005eb1608..b01c876e7 100644
--- a/parse.c
+++ b/parse.c
@@ -897,8 +897,8 @@ static void cast_enum_list(struct symbol_list *list, struct symbol *base_type)
 			expr->ctype = &int_ctype;
 			continue;
 		}
-		expr->ctype = base_type;
 		cast_value(expr, base_type, expr, ctype);
+		expr->ctype = base_type;
 	} END_FOR_EACH_PTR(sym);
 }
 
diff --git a/validation/enum-sign-extend.c b/validation/enum-sign-extend.c
index 7f17debac..d1aee9419 100644
--- a/validation/enum-sign-extend.c
+++ b/validation/enum-sign-extend.c
@@ -8,5 +8,4 @@ _Static_assert(b == -1L,              "value");
 
 /*
  * check-name: enum-sign-extend
- * check-known-to-fail
  */
-- 
2.23.0




[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