diff mbox series

[BlueZ] main: fixing logical error when loading controller params

Message ID 20200618014812.234606-1-alainm@chromium.org (mailing list archive)
State Accepted
Headers show
Series [BlueZ] main: fixing logical error when loading controller params | expand

Commit Message

Alain Michaud June 18, 2020, 1:48 a.m. UTC
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(-)

Comments

Luiz Augusto von Dentz June 18, 2020, 4:38 a.m. UTC | #1
Hi Alain,

On Wed, Jun 17, 2020 at 6:51 PM Alain Michaud <alainm@chromium.org> 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.
diff mbox series

Patch

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;
 		}