From 0879b5fefc747e458f1529b99895ef2a47428393 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 4 Feb 2021 15:46:27 -0500 Subject: [PATCH] condition: buffer usage: validation does not check for ratio and bytes threshold MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Buffer usage condition do not support having both ratio and bytes threshold set. Using `!usage->threshold_ratio.set && !usage->threshold_bytes.set` does not error out for `threshold_ratio.set == 1` and `usage->threshold_bytes.set == 1` 0 0 : 1 0 1 : 0 1 0 : 0 1 1 : 0 We want to check for a xnor (`usage->threshold_ratio.set == usage->threshold_bytes.set`) 0 0 : 1 0 1 : 0 1 0 : 0 1 1 : 1 We could also do 2 error check one for not set and one validating that both are not set. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I5bfcf43bcaf9687ddf9fdebe5ace4f15bda28261 --- src/common/conditions/buffer-usage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/conditions/buffer-usage.c b/src/common/conditions/buffer-usage.c index cc9e9cde8..a97f6d59f 100644 --- a/src/common/conditions/buffer-usage.c +++ b/src/common/conditions/buffer-usage.c @@ -62,8 +62,8 @@ bool lttng_condition_buffer_usage_validate( ERR("Invalid buffer condition: a target channel name must be set."); goto end; } - if (!usage->threshold_ratio.set && !usage->threshold_bytes.set) { - ERR("Invalid buffer condition: a threshold must be set."); + if (usage->threshold_ratio.set == usage->threshold_bytes.set) { + ERR("Invalid buffer condition: a threshold must be set or both type cannot be used simultaneously."); goto end; } if (!usage->domain.set) { -- 2.34.1