[Spice-devel] spice-xpi

Marc-André Lureau mlureau at redhat.com
Tue Mar 20 04:36:13 PDT 2012



----- Original Message -----
> On 03/15/2012 02:48 PM, Marc-André Lureau wrote:
> > why not use only __FUNCTION__?
> >
> 
> Because, it does not format the string to meet this pattern for
> classes:
> "class::method". What I get is only the method name, which is not
> enough
> in this case.

Apparently, there are more elegant ways of doing this:
http://stackoverflow.com/questions/1666802/class-macro-in-c
 
> >>> -        execl("/usr/libexec/spice-xpi-client",
> >>> "/usr/libexec/spice-xpi-client", NULL);
> >>> -        g_message("failed to run spice-xpi-client, running
> >>> spicec instead");
> >>> +        char *spice_xpi_client_args[] = {
> >>> +            const_cast<char*>("/usr/libexec/spice-xpi-client"),
> >>> +            NULL
> >>> +        };
> >>> +        std::stringstream ss;
> >>> +        int cnt = sizeof(spice_xpi_client_args) /
> >>> sizeof(spice_xpi_client_args[0]);
> >>> +        for (int i = 0; i < cnt; ++i)
> >>> +            ss << spice_xpi_client_args[i] << " ";
> >>> +        LOG_MESSAGE("Launching " << ss.str());
> >>> +        execv(spice_xpi_client_args[0], spice_xpi_client_args);
> >>> +        LOG_MESSAGE("failed to run spice-xpi-client, running
> >>> spicec instead");
> > 
> > This change is quite intrusive and ugly imho, especially because
> > you
> > do it at least twice (here, +more for usb elsewhere).
> >
> 
> It depends. I wanted to easily dump the parameters, which are passed
> to
> the process - I wanted to avoid copying the same thing twice.
> > Can't you define a exec helper instead, using a ostream operator<<
> > for
> > logging argv would be a plus, for instance.
> > 

I don't see how having a helper function would necessary mean to copy things. Anyway, copying or serializing etc, you already do some, and it's not going to kill us.

> >>  /* attribute string Title; */
> >>  char *nsPluginInstance::GetTitle() const
> >>  {
> >> +    std::string title(m_title);
> >> +    size_t found = -2;
> >> +    while ((found = title.find("%", found + 2)) !=
> >> std::string::npos)
> >> +        title.replace(found, 1, "%%");
> >> +    LOG_DEBUG(title);
> >>      return stringCopy(m_title);
> >>  }
> > 
> > Hmm, I think I understand why you did this, because we use C
> > printf-like g_log functions in the end, but we can't add use
> > LOG_DEBUG("%s", title) sadly.
> >
> 
> Yes, exactly!

Then we can fix it, like I proposed:
 
> > Maybe the g_log functions should be called like g_debug("%s", msg)
> > instead, since they are not doing the formating anyway?


More information about the Spice-devel mailing list