[Spice-devel] [PATCH spice-streaming-agent 7/9] Make the try-catch block in main() a catch-all

Lukáš Hrázký lhrazky at redhat.com
Thu Jun 14 10:09:22 UTC 2018


On Thu, 2018-06-14 at 05:29 -0400, Frediano Ziglio wrote:
> > 
> > Extends the try-catch block to encompass all the business code in
> > main(), making it a catch-all for all errors.
> > 
> > Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
> 
> Idea is good, the patch does not compile.

Ah, right... I've done more patches at once and didn't check each one.

(do you really try to compile the patches one by one? :))

> > ---
> >  src/spice-streaming-agent.cpp | 46 +++++++++++++++++------------------
> >  1 file changed, 23 insertions(+), 23 deletions(-)
> > 
> > diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> > index 2bdfc32..fe26f70 100644
> > --- a/src/spice-streaming-agent.cpp
> > +++ b/src/spice-streaming-agent.cpp
> > @@ -474,36 +474,36 @@ int main(int argc, char* argv[])
> >          }
> >      }
> >  
> > -    // register built-in plugins
> > -    MjpegPlugin::Register(&agent);
> > +    try {
> > +        // register built-in plugins
> > +        MjpegPlugin::Register(&agent);
> >  
> > -    agent.LoadPlugins(pluginsdir);
> > +        agent.LoadPlugins(pluginsdir);
> >  
> > -    register_interrupts();
> > +        register_interrupts();
> >  
> > -    FrameLog frame_log(log_filename, log_binary, log_frames);
> > +        FrameLog frame_log(log_filename, log_binary, log_frames);
> >  
> > -    for (const std::string& arg: old_args) {
> > -        frame_log.log_stat("Args: %s", arg.c_str());
> > -    }
> > -    old_args.clear();
> > +        for (const std::string& arg: old_args) {
> > +            frame_log.log_stat("Args: %s", arg.c_str());
> > +        }
> > +        old_args.clear();
> >  
> > -    Display *display = XOpenDisplay(NULL);
> > -    if (display == NULL) {
> > -        syslog(LOG_ERR, "failed to open display\n");
> > -        return EXIT_FAILURE;
> > -    }
> > -    int event_base, error_base;
> > -    if (!XFixesQueryExtension(display, &event_base, &error_base)) {
> > -        syslog(LOG_ERR, "XFixesQueryExtension failed\n");
> > -        return EXIT_FAILURE;
> > -    }
> > -    Window rootwindow = DefaultRootWindow(display);
> > -    XFixesSelectCursorInput(display, rootwindow,
> > XFixesDisplayCursorNotifyMask);
> > +        Display *display = XOpenDisplay(NULL);
> > +        if (display == NULL) {
> > +            syslog(LOG_ERR, "failed to open display\n");
> > +            return EXIT_FAILURE;
> > +        }
> > +        int event_base, error_base;
> > +        if (!XFixesQueryExtension(display, &event_base, &error_base)) {
> > +            syslog(LOG_ERR, "XFixesQueryExtension failed\n");
> > +            return EXIT_FAILURE;
> > +        }
> > +        Window rootwindow = DefaultRootWindow(display);
> > +        XFixesSelectCursorInput(display, rootwindow,
> > XFixesDisplayCursorNotifyMask);
> >  
> > -    int ret = EXIT_SUCCESS;
> > +        int ret = EXIT_SUCCESS;
> >  
> > -    try {
> >          StreamPort stream_port(stream_port_name);
> >  
> >          std::thread cursor_th(cursor_changes, &stream_port, display,
> >          event_base);
> 
> Frediano


More information about the Spice-devel mailing list