From: Alberto Garcia Date: Thu, 18 Feb 2016 10:26:58 +0000 (+0200) Subject: throttle: Set always an average value when setting a maximum value X-Git-Tag: TizenStudio_2.0_p2.4~27^2~6^2~8^2~172^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f9b6d57ae3cd8a5f82e06f79d22e7a591116b5b;p=sdk%2Femulator%2Fqemu.git throttle: Set always an average value when setting a maximum value When testing the ranges of valid values, set_cfg_value() creates sometimes invalid throttling configurations by setting bucket.max while leaving bucket.avg uninitialized. While this doesn't break the current tests, it will as soon as we unify all functions that check the validity of the throttling configuration. This patch ensures that the value of bucket.avg is valid when setting bucket.max. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 0e7c7e0..3e208a8 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -222,6 +222,8 @@ static void set_cfg_value(bool is_max, int index, int value) { if (is_max) { cfg.buckets[index].max = value; + /* If max is set, avg should never be 0 */ + cfg.buckets[index].avg = MAX(cfg.buckets[index].avg, 1); } else { cfg.buckets[index].avg = value; }