From 6ecab1fd02b8919f279004a58467aec1fa23c228 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 9 Sep 2021 12:09:12 +0000 Subject: Relax the check for accessing variable before setting them. First we can't assume rules are written in the order they will be executed. Secondly filters might need to check variables before they had a chance to be populated by the right event. --- usr.sbin/btrace/bt_parse.y | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y index 196edc4e28a..faf2b05f119 100644 --- a/usr.sbin/btrace/bt_parse.y +++ b/usr.sbin/btrace/bt_parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parse.y,v 1.42 2021/09/09 09:53:11 mpi Exp $ */ +/* $OpenBSD: bt_parse.y,v 1.43 2021/09/09 12:09:11 mpi Exp $ */ /* * Copyright (c) 2019-2021 Martin Pieuchot @@ -535,13 +535,7 @@ bg_get(const char *vname) struct bt_arg * bg_find(const char *vname) { - struct bt_var *bv; - - bv = bg_lookup(vname); - if (bv == NULL) - yyerror("variable '%s' accessed before being set", vname); - - return ba_new(bv, B_AT_VAR); + return ba_new(bg_get(vname), B_AT_VAR); } /* Create a 'store' statement to assign a value to a global variable. */ @@ -617,14 +611,9 @@ bm_insert(const char *mname, struct bt_arg *mkey, struct bt_arg *mval) struct bt_arg * bm_find(const char *vname, struct bt_arg *mkey) { - struct bt_var *bv; struct bt_arg *ba; - bv = bg_lookup(vname); - if (bv == NULL) - yyerror("variable '%s' accessed before being set", vname); - - ba = ba_new(bv, B_AT_MAP); + ba = ba_new(bg_get(vname), B_AT_MAP); ba->ba_key = mkey; return ba; } -- cgit v1.2.3