Re: [PATCH 10/14] Make CCD::load_api throw exception by its own

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



s/by its own/on its own/

On Thu, Sep 01, 2016 at 01:00:52PM +0100, Frediano Ziglio wrote:
> Avoid to use two way to handle errors.

"two different ways"

Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  vdagent/display_configuration.cpp | 19 +++++++------------
>  vdagent/display_configuration.h   |  2 +-
>  2 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
> index 5aed7be..86c4ea5 100644
> --- a/vdagent/display_configuration.cpp
> +++ b/vdagent/display_configuration.cpp
> @@ -692,12 +692,8 @@ CCD::CCD()
>      ,_primary_detached(false)
>      ,_path_state(PATH_UPDATED)
>  {
> -    if (load_api()) {
> -        get_config_buffers();
> -    }
> -    else {
> -        throw std::exception();
> -    }
> +    load_api();
> +    get_config_buffers();
>  }
>  
>  CCD::~CCD()
> @@ -802,14 +798,13 @@ void CCD::debug_print_config(const char* prefix)
>      }
>  }
>  
> -bool CCD::load_api()
> +void CCD::load_api()
>  {
>      HMODULE hModule = GetModuleHandle(L"user32.dll");
> -    if(!hModule) {
> -        return false;
> +    if (!hModule) {
> +        throw std::exception();
>      }
>  
> -    bool bFound_all(false);
>      do {
>          if (!(_pfnGetDeviceInfo = (PDISPLAYCONFIG_GETDEVICEINFO)
>              GetProcAddress(hModule, "DisplayConfigGetDeviceInfo"))) {
> @@ -830,11 +825,11 @@ bool CCD::load_api()
>              GetProcAddress(hModule, "SetDisplayConfig"))) {
>              break;
>          }
> -        bFound_all = true;
> +        return;
>      }
>      while(0);
>  
> -    return bFound_all;
> +    throw std::exception();
>  }
>  
>  bool CCD::get_config_buffers()
> diff --git a/vdagent/display_configuration.h b/vdagent/display_configuration.h
> index 7abf526..ef4f989 100644
> --- a/vdagent/display_configuration.h
> +++ b/vdagent/display_configuration.h
> @@ -67,7 +67,7 @@ public:
>      void debug_print_config(const char* prefix = NULL);
>  
>  private:
> -    bool load_api();
> +    void load_api();
>      bool get_config_buffers();
>      void free_config_buffers();
>      bool is_device_path(LPCTSTR device_name, DISPLAYCONFIG_PATH_INFO* path);
> -- 
> 2.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]