[PATCH] acpi: brightness: check get_setting return

Keng-Yu Lin kengyu at canonical.com
Mon May 20 07:41:49 UTC 2013


On Tue, May 7, 2013 at 5:31 PM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997319: Unchecked return value (CHECKED_RETURN)
>
> We should really check the get_setting() return to see if it failed
> rather than blindly assuming it worked OK.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/acpi/brightness/brightness.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpi/brightness/brightness.c b/src/acpi/brightness/brightness.c
> index f523cbf..b4b588e 100644
> --- a/src/acpi/brightness/brightness.c
> +++ b/src/acpi/brightness/brightness.c
> @@ -158,7 +158,11 @@ static int brightness_test2(fwts_framework *fw)
>
>                                         for (i=0;i<=max_brightness;i++) {
>                                                 set_setting(entry->d_name, "brightness", i);
> -                                               get_setting(entry->d_name, "actual_brightness", &actual_brightness);
> +                                               if (get_setting(entry->d_name, "actual_brightness", &actual_brightness) != FWTS_OK) {
> +                                                       fwts_log_info(fw, "Cannot get brightness setting %d for backlight %s.", i, entry->d_name);
> +                                                       failed++;
> +                                                       continue;
> +                                               }
>                                                 if (actual_brightness != i)  {
>                                                         fwts_log_info(fw, "Actual brightness %d does not match the brightnesss level %d just set for backlight %s.", actual_brightness, i, entry->d_name);
>                                                         failed++;
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu at canonical.com>>



More information about the fwts-devel mailing list