From 532fc79db26140b2b8af464f0e3a361bee1c4005 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 29 Oct 2012 14:52:51 +0300 Subject: [PATCH] sval: add sval_type_min() This matches sval_type_max() which we already have. Signed-off-by: Dan Carpenter --- smatch.h | 1 + smatch_type.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/smatch.h b/smatch.h index 35d6074e..ddea44d0 100644 --- a/smatch.h +++ b/smatch.h @@ -271,6 +271,7 @@ int returns_pointer(struct symbol *base_type); long long type_max(struct symbol *base_type); sval_t sval_type_max(struct symbol *base_type); long long type_min(struct symbol *base_type); +sval_t sval_type_min(struct symbol *base_type); int nr_bits(struct expression *expr); int is_static(struct expression *expr); const char *global_static(); diff --git a/smatch_type.c b/smatch_type.c index 3d884ab7..2e5cadca 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -268,6 +268,24 @@ long long type_min(struct symbol *base_type) return -(ret + 1); } +sval_t sval_type_min(struct symbol *base_type) +{ + sval_t ret; + + if (!base_type || !base_type->bit_size) + base_type = &llong_ctype; + ret.type = base_type; + + if (type_unsigned(base_type)) { + ret.value = 0; + return ret; + } + + ret.value = (~0ULL) << (base_type->bit_size - 1); + + return ret; +} + int nr_bits(struct expression *expr) { struct symbol *type; -- 2.11.4.GIT