Revert and adjust the changes in ometric_set_state() from last commit.
authorclaudio <claudio@openbsd.org>
Mon, 5 Dec 2022 11:50:11 +0000 (11:50 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 5 Dec 2022 11:50:11 +0000 (11:50 +0000)
Calling ometric_set_int_with_labels() for a state metric fails because
there is a check in ometric_set_int comparing the type.
Use olabels_add_extras() and ometric_set_int_value() instead.

usr.sbin/bgpctl/ometric.c

index 37abc64..296c080 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ometric.c,v 1.4 2022/12/01 09:14:40 claudio Exp $ */
+/*     $OpenBSD: ometric.c,v 1.5 2022/12/05 11:50:11 claudio Exp $ */
 
 /*
  * Copyright (c) 2022 Claudio Jeker <claudio@openbsd.org>
@@ -390,6 +390,7 @@ ometric_set_info(struct ometric *om, const char **keys, const char **values,
 void
 ometric_set_state(struct ometric *om, const char *state, struct olabels *ol)
 {
+       struct olabels *extra;
        size_t i;
        int val;
 
@@ -402,8 +403,10 @@ ometric_set_state(struct ometric *om, const char *state, struct olabels *ol)
                else
                        val = 0;
 
-               ometric_set_int_with_labels(om, val, OKV(om->name),
-                   OKV(om->stateset[i]), ol);
+               extra = olabels_add_extras(ol, OKV(om->name),
+                   OKV(om->stateset[i]));
+               ometric_set_int_value(om, val, extra);
+               olabels_free(extra);
        }
 }