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

Re: [virt-tools-list] [PATCH 1/2] install script: generates the output in a file



On Mon, Aug 13, 2012 at 10:31:29PM -0300, Fabiano Fidêncio wrote:
> >> @@ -665,7 +752,7 @@ gchar *osinfo_install_script_generate(OsinfoInstallScript *script,
> >>      GMainLoop *loop = g_main_loop_new(g_main_context_get_thread_default(),
> >>                                        TRUE);
> >>      struct OsinfoInstallScriptGenerateSync data = {
> >> -        loop, NULL, NULL
> >> +        loop, NULL, NULL, NULL
> >
> > If all you need to do is to pass the main loop, you should pass that
> > as the data pointer and no need to have a separate struct.
> 
> Sorry, I didn't understand your point. I was following the Daniel's code.
> What do you said is to merge this fields in the OsinfoInstallScriptGenerateData?

I don't have the whole function body handy, but if you have a single
pointer (loop) to pass to a callback as user_data, you can directly pass
'loop' as user_data instead of allocating a struct where the only thing you
use will be a single pointer. Really depends what the rest of the code
does...

> 
> >
> >>      };
> >>
> >>      osinfo_install_script_generate_async(script,
> >> @@ -686,6 +773,121 @@ gchar *osinfo_install_script_generate(OsinfoInstallScript *script,
> >>      return data.output;
> >>  }
> >>
> >> +static void osinfo_install_script_generate_output_write_file(GObject *src,
> >> +                                                             GAsyncResult *res,
> >> +                                                             gpointer user_data)
> >> +{
> >> +    struct OsinfoInstallScriptGenerateOutputData *data = user_data;
> >> +
> >> +    if (data->stream == NULL)
> >> +        data->stream = g_file_replace_finish(G_FILE (src), res, &data->error);
> >> +    else
> >> +        data->output_pos += g_output_stream_write_finish(G_OUTPUT_STREAM(data->stream),
> >> +                                                                         res,
> >> +                                                                         &data->error);
> >
> > arguments preferably need to be aligned with the first.
> 
> As teuf pointed, GMail sucks.

I wasn't clear in my answer, but my comment about the args being aligned as
expected was only applying to the next 2 blocks (the only ones I kept in my
email). This block is misaligned, the alignement shouldn't be done on the '('
of G_OUTPUT_STREAM( but on the one from g_output_stream_write_finish(.

Christophe

Attachment: pgpK2Z0GS19sN.pgp
Description: PGP signature


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