diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-03 15:54:58 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-12-09 16:39:33 +0100 |
commit | e206ae0348021d4d3c2c7c02f41fb5dbcf14cdb2 (patch) | |
tree | 86f192441f27f368ba06a5260187d82ffc9bf0a7 | |
parent | fff61b26c44a6ead0dde04f214f909f3269140b8 (diff) | |
download | sparse-e206ae0348021d4d3c2c7c02f41fb5dbcf14cdb2.tar.gz |
as-name: add and use show_as()
Use a function to display the address spaces.
This will allow to display a real name instead of '<asn:1>'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 6 | ||||
-rw-r--r-- | show-parse.c | 13 | ||||
-rw-r--r-- | symbol.h | 1 | ||||
-rw-r--r-- | tokenize.c | 4 | ||||
-rw-r--r-- | validation/Waddress-space-all-attr.c | 24 | ||||
-rw-r--r-- | validation/Waddress-space-strict.c | 12 | ||||
-rw-r--r-- | validation/address_space.c | 2 | ||||
-rw-r--r-- | validation/ptr-inherit.c | 2 |
8 files changed, 38 insertions, 26 deletions
@@ -3018,13 +3018,13 @@ static struct symbol *evaluate_cast(struct expression *expr) } if (!tas && sas > 0) - warning(expr->pos, "cast removes address space of expression (<asn:%d>)", sas); + warning(expr->pos, "cast removes address space '%s' of expression", show_as(sas)); if (tas > 0 && sas > 0 && tas != sas) - warning(expr->pos, "cast between address spaces (<asn:%d>-><asn:%d>)", sas, tas); + warning(expr->pos, "cast between address spaces (%s -> %s)", show_as(sas), show_as(tas)); if (tas > 0 && !sas && !is_null_pointer_constant(source) && Wcast_to_as) warning(expr->pos, - "cast adds address space to expression (<asn:%d>)", tas); + "cast adds address space '%s' to expression", show_as(tas)); if (!(ttype->ctype.modifiers & MOD_PTRINHERIT) && tclass == TYPE_PTR && !tas && (source->flags & CEF_ICE)) { diff --git a/show-parse.c b/show-parse.c index 6328439c..ae098c28 100644 --- a/show-parse.c +++ b/show-parse.c @@ -182,6 +182,17 @@ void show_symbol_list(struct symbol_list *list, const char *sep) } END_FOR_EACH_PTR(sym); } +const char *show_as(unsigned int as) +{ + static char buffer[4][32]; + static int n; + char *buff; + + buff = buffer[3 & ++n]; + sprintf(buff, "<asn:%u>", as); + return buff; +} + struct type_name { char *start; char *end; @@ -288,7 +299,7 @@ deeper: size_t len; if (as) - prepend(name, "<asn:%d>", as); + prepend(name, "%s ", show_as(as)); s = modifier_string(mod); len = strlen(s); @@ -315,6 +315,7 @@ extern void bind_symbol(struct symbol *, struct ident *, enum namespace); extern struct symbol *examine_symbol_type(struct symbol *); extern struct symbol *examine_pointer_target(struct symbol *); +extern const char *show_as(unsigned int as); extern const char *show_typename(struct symbol *sym); extern const char *builtin_typename(struct symbol *sym); extern const char *builtin_ctypename(struct ctype *ctype); @@ -88,13 +88,13 @@ const char *show_special(int val) const char *show_ident(const struct ident *ident) { - static char buff[2][256]; + static char buff[4][256]; static int n; char *buffer; if (!ident) return "<noident>"; - buffer = buff[2 & ++n]; + buffer = buff[3 & ++n]; sprintf(buffer, "%.*s", ident->len, ident->name); return buffer; } diff --git a/validation/Waddress-space-all-attr.c b/validation/Waddress-space-all-attr.c index 46b70953..5b2d0f92 100644 --- a/validation/Waddress-space-all-attr.c +++ b/validation/Waddress-space-all-attr.c @@ -44,17 +44,17 @@ static void expl(obj_t __kernel *k, obj_t __iomem *o, * check-command: sparse -Wcast-from-as -Wcast-to-as $file * * check-error-start -Waddress-space-all-attr.c:21:10: warning: cast removes address space of expression (<asn:2>) -Waddress-space-all-attr.c:22:10: warning: cast removes address space of expression (<asn:2>) -Waddress-space-all-attr.c:23:10: warning: cast removes address space of expression (<asn:2>) -Waddress-space-all-attr.c:26:10: warning: cast removes address space of expression (<asn:1>) -Waddress-space-all-attr.c:27:10: warning: cast removes address space of expression (<asn:1>) -Waddress-space-all-attr.c:28:10: warning: cast removes address space of expression (<asn:1>) -Waddress-space-all-attr.c:31:10: warning: cast removes address space of expression (<asn:3>) -Waddress-space-all-attr.c:32:10: warning: cast removes address space of expression (<asn:3>) -Waddress-space-all-attr.c:33:10: warning: cast removes address space of expression (<asn:3>) -Waddress-space-all-attr.c:36:10: warning: cast removes address space of expression (<asn:4>) -Waddress-space-all-attr.c:37:10: warning: cast removes address space of expression (<asn:4>) -Waddress-space-all-attr.c:38:10: warning: cast removes address space of expression (<asn:4>) +Waddress-space-all-attr.c:21:10: warning: cast removes address space '<asn:2>' of expression +Waddress-space-all-attr.c:22:10: warning: cast removes address space '<asn:2>' of expression +Waddress-space-all-attr.c:23:10: warning: cast removes address space '<asn:2>' of expression +Waddress-space-all-attr.c:26:10: warning: cast removes address space '<asn:1>' of expression +Waddress-space-all-attr.c:27:10: warning: cast removes address space '<asn:1>' of expression +Waddress-space-all-attr.c:28:10: warning: cast removes address space '<asn:1>' of expression +Waddress-space-all-attr.c:31:10: warning: cast removes address space '<asn:3>' of expression +Waddress-space-all-attr.c:32:10: warning: cast removes address space '<asn:3>' of expression +Waddress-space-all-attr.c:33:10: warning: cast removes address space '<asn:3>' of expression +Waddress-space-all-attr.c:36:10: warning: cast removes address space '<asn:4>' of expression +Waddress-space-all-attr.c:37:10: warning: cast removes address space '<asn:4>' of expression +Waddress-space-all-attr.c:38:10: warning: cast removes address space '<asn:4>' of expression * check-error-end */ diff --git a/validation/Waddress-space-strict.c b/validation/Waddress-space-strict.c index 807965f6..7987eb1d 100644 --- a/validation/Waddress-space-strict.c +++ b/validation/Waddress-space-strict.c @@ -27,11 +27,11 @@ static void expl(ulong u, void *v, obj_t *o, obj_t __user *p) * check-command: sparse -Wcast-from-as -Wcast-to-as $file * * check-error-start -Waddress-space-strict.c:9:10: warning: cast adds address space to expression (<asn:1>) -Waddress-space-strict.c:12:10: warning: cast adds address space to expression (<asn:1>) -Waddress-space-strict.c:17:10: warning: cast adds address space to expression (<asn:1>) -Waddress-space-strict.c:19:10: warning: cast removes address space of expression (<asn:1>) -Waddress-space-strict.c:20:10: warning: cast removes address space of expression (<asn:1>) -Waddress-space-strict.c:21:10: warning: cast removes address space of expression (<asn:1>) +Waddress-space-strict.c:9:10: warning: cast adds address space '<asn:1>' to expression +Waddress-space-strict.c:12:10: warning: cast adds address space '<asn:1>' to expression +Waddress-space-strict.c:17:10: warning: cast adds address space '<asn:1>' to expression +Waddress-space-strict.c:19:10: warning: cast removes address space '<asn:1>' of expression +Waddress-space-strict.c:20:10: warning: cast removes address space '<asn:1>' of expression +Waddress-space-strict.c:21:10: warning: cast removes address space '<asn:1>' of expression * check-error-end */ diff --git a/validation/address_space.c b/validation/address_space.c index c55b78df..a0c8bf5d 100644 --- a/validation/address_space.c +++ b/validation/address_space.c @@ -12,6 +12,6 @@ static int sys_do_stuff(void __user *user_addr) * check-error-start address_space.c:7:28: warning: incorrect type in argument 1 (different address spaces) address_space.c:7:28: expected void *addr -address_space.c:7:28: got void <asn:1>*user_addr +address_space.c:7:28: got void <asn:1> *user_addr * check-error-end */ diff --git a/validation/ptr-inherit.c b/validation/ptr-inherit.c index 58524a71..87330567 100644 --- a/validation/ptr-inherit.c +++ b/validation/ptr-inherit.c @@ -75,6 +75,6 @@ ptr-inherit.c:30:19: expected int *p ptr-inherit.c:30:19: got restricted int *<noident> ptr-inherit.c:36:19: warning: incorrect type in initializer (different address spaces) ptr-inherit.c:36:19: expected int *p -ptr-inherit.c:36:19: got int <asn:1>*<noident> +ptr-inherit.c:36:19: got int <asn:1> *<noident> * check-error-end */ |