From: mpi Date: Thu, 9 Sep 2021 07:17:31 +0000 (+0000) Subject: Do not treat empty map has invalid. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2e354f386ceff812617a290388cc0ed5907ea3a4;p=openbsd Do not treat empty map has invalid. --- diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index b65fb58a9ba..cd63d6581a3 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.51 2021/09/09 07:03:10 mpi Exp $ */ +/* $OpenBSD: btrace.c,v 1.52 2021/09/09 07:17:31 mpi Exp $ */ /* * Copyright (c) 2019 - 2021 Martin Pieuchot @@ -749,13 +749,13 @@ stmt_clear(struct bt_stmt *bs) assert(bs->bs_var == NULL); assert(ba->ba_type == B_AT_VAR); - if (bv->bv_type != B_VT_MAP && bv->bv_type != B_VT_HIST) - errx(1, "invalid variable type for clear(%s)", ba_name(ba)); - map = (struct map *)bv->bv_value; if (map == NULL) return; + if (bv->bv_type != B_VT_MAP && bv->bv_type != B_VT_HIST) + errx(1, "invalid variable type for clear(%s)", ba_name(ba)); + map_clear(map); bv->bv_value = NULL; @@ -956,13 +956,13 @@ stmt_zero(struct bt_stmt *bs) assert(bs->bs_var == NULL); assert(ba->ba_type == B_AT_VAR); - if (bv->bv_type != B_VT_MAP && bv->bv_type != B_VT_HIST) - errx(1, "invalid variable type for zero(%s)", ba_name(ba)); - map = (struct map *)bv->bv_value; if (map == NULL) return; + if (bv->bv_type != B_VT_MAP && bv->bv_type != B_VT_HIST) + errx(1, "invalid variable type for zero(%s)", ba_name(ba)); + map_zero(map); debug("map=%p '%s' zero\n", map, bv_name(bv));