Re: [PATCH spice-streaming-agent v2 6/9] Clean up the global try-catch block

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

 



> 
> Unify the error handling to use exceptions, narrowing down the exit
> spots for success/error to one each.
> 
> Signed-off-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx>
> ---
>  src/spice-streaming-agent.cpp | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index cc256bb..ea4d4fd 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -474,8 +474,6 @@ int main(int argc, char* argv[])
>          }
>      }
>  
> -    int ret = EXIT_SUCCESS;
> -
>      try {
>          // register built-in plugins
>          MjpegPlugin::Register(&agent);
> @@ -493,13 +491,12 @@ int main(int argc, char* argv[])
>  
>          Display *display = XOpenDisplay(NULL);
>          if (display == NULL) {
> -            syslog(LOG_ERR, "failed to open display\n");
> -            return EXIT_FAILURE;
> +            throw Error("Failed to open X display");
>          }
> +
>          int event_base, error_base;
>          if (!XFixesQueryExtension(display, &event_base, &error_base)) {
> -            syslog(LOG_ERR, "XFixesQueryExtension failed\n");
> -            return EXIT_FAILURE;
> +            throw Error("XFixesQueryExtension failed");
>          }
>          Window rootwindow = DefaultRootWindow(display);
>          XFixesSelectCursorInput(display, rootwindow,
>          XFixesDisplayCursorNotifyMask);
> @@ -513,8 +510,8 @@ int main(int argc, char* argv[])
>      }
>      catch (std::exception &err) {
>          syslog(LOG_ERR, "%s\n", err.what());
> -        ret = EXIT_FAILURE;
> +        return EXIT_FAILURE;
>      }
>  
> -    return ret;
> +    return EXIT_SUCCESS;
>  }

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

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




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