From b022d128f6cfa980759b71c96ac47b89daa89112 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Sun, 21 Nov 2021 12:20:10 -0800 Subject: [PATCH 1/2] provider: Fix a complier warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC provider/libply_la-special.lo provider/special.c: In function ‘register_special_probes’: provider/special.c:67:34: warning: ‘base_addr’ may be used uninitialized in this function [-Wmaybe-uninitialized] 67 | end_offset = (unsigned long)end - base_addr; | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ --- src/libply/provider/special.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libply/provider/special.c b/src/libply/provider/special.c index d6e4711..b90284f 100644 --- a/src/libply/provider/special.c +++ b/src/libply/provider/special.c @@ -26,7 +26,7 @@ int register_special_probes(special_probe_t begin, special_probe_t end) { FILE *fp; char buf[PATH_MAX]; - unsigned long base_addr; + unsigned long base_addr = 0; if (begin == NULL && end == NULL) return 0; From 88357ae049c22b6197080cd4b83a745913060dc9 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Sun, 21 Nov 2021 12:43:49 -0800 Subject: [PATCH 2/2] bultin-in: Show proper error message for maps Sometimes I mistakenly type '$' instead of '@' for maps. But the error message was not clear and just showed an assertion failure. Check the type of the node when it assignes to a map like below: # ply 'kr:vfs_read { $r["bytes"] = quantize(retval); }' :1:14-25: error: expect map type, but get $r ERR:-22 --- src/libply/built-in/memory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libply/built-in/memory.c b/src/libply/built-in/memory.c index 9b7b9aa..0b173b1 100644 --- a/src/libply/built-in/memory.c +++ b/src/libply/built-in/memory.c @@ -629,6 +629,12 @@ static int map_type_infer(const struct func *func, struct node *n) return 0; if (map->sym->type) { + if (map->sym->type->ttype != T_MAP) { + _ne(n, "can't lookup a key in %N (type '%T'), " + "which is not a map.\n", map, map->sym->type); + return -EINVAL; + } + if (!n->sym->type) /* given `m[key]` where m's type is known, * infer that the expression's type is equal