summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-10-01 23:24:37 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-30 14:05:03 +0100
commit4ce42ee56d9207ef831f76104fa248fa0fddb326 (patch)
treefcc68584573fbc0b8ffd6d32131db741caec8317
parent600bc3b599fe3488e31a044f45939f9b52d7f7d3 (diff)
downloadsparse-4ce42ee56d9207ef831f76104fa248fa0fddb326.tar.gz
bitfield: don't warn twice on invalid width
At parsing time, bitfields with invalid width have their size set to -1 but at examination time this size is interpreted as an unsigned value, causing a second warning. Fix this by avoiding to cast the size to an unsigned variable. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--symbol.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/symbol.c b/symbol.c
index fb14b624..6c1fb2a5 100644
--- a/symbol.c
+++ b/symbol.c
@@ -254,12 +254,11 @@ static struct symbol * examine_array_type(struct symbol *sym)
static struct symbol *examine_bitfield_type(struct symbol *sym)
{
struct symbol *base_type = examine_base_type(sym);
- unsigned long bit_size, alignment, modifiers;
+ unsigned long alignment, modifiers;
if (!base_type)
return sym;
- bit_size = base_type->bit_size;
- if (sym->bit_size > bit_size)
+ if (sym->bit_size > base_type->bit_size)
warning(sym->pos, "impossible field-width, %d, for this type", sym->bit_size);
alignment = base_type->ctype.alignment;