2020-06-18 01:49:15

by Alain Michaud

[permalink] [raw]
Subject: [BlueZ PATCH] main: fixing logical error when loading controller params

Fixing logical error when loading configuration parameters from the
config file. Without this patch, the maximum allowable value is always
used.

---

src/main.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index e51f614b3..75ea27f40 100644
--- a/src/main.c
+++ b/src/main.c
@@ -421,12 +421,13 @@ static void parse_controller_config(GKeyFile *config)
int val = g_key_file_get_integer(config, "Controller",
params[i].val_name, &err);
if (err) {
+ warn("%s", err->message);
g_clear_error(&err);
} else {
- DBG("%s=%d", params[i].val_name, val);
+ info("%s=%d", params[i].val_name, val);

- val = MIN(val, params[i].min);
- val = MAX(val, params[i].max);
+ val = MAX(val, params[i].min);
+ val = MIN(val, params[i].max);
*params[i].val = val;
++main_opts.default_params.num_entries;
}
--
2.27.0.111.gc72c7da667-goog


2020-06-18 04:44:50

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [BlueZ PATCH] main: fixing logical error when loading controller params

Hi Alain,

On Wed, Jun 17, 2020 at 6:51 PM Alain Michaud <[email protected]> wrote:
>
> Fixing logical error when loading configuration parameters from the
> config file. Without this patch, the maximum allowable value is always
> used.
>
> ---
>
> src/main.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/main.c b/src/main.c
> index e51f614b3..75ea27f40 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -421,12 +421,13 @@ static void parse_controller_config(GKeyFile *config)
> int val = g_key_file_get_integer(config, "Controller",
> params[i].val_name, &err);
> if (err) {
> + warn("%s", err->message);
> g_clear_error(&err);
> } else {
> - DBG("%s=%d", params[i].val_name, val);
> + info("%s=%d", params[i].val_name, val);
>
> - val = MIN(val, params[i].min);
> - val = MAX(val, params[i].max);
> + val = MAX(val, params[i].min);
> + val = MIN(val, params[i].max);
> *params[i].val = val;
> ++main_opts.default_params.num_entries;
> }
> --
> 2.27.0.111.gc72c7da667-goog

Applied, thanks.

--
Luiz Augusto von Dentz