From: VMware, Inc <> Date: Tue, 26 Apr 2011 21:15:06 +0000 (-0700) Subject: Call g_clear_error(&err) after g_locale_from_utf8() fails. X-Git-Tag: 2011.04.25-402641~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f10ce3b509c8b86ca917a9c3128207dabc84b77e;p=thirdparty%2Fopen-vm-tools.git Call g_clear_error(&err) after g_locale_from_utf8() fails. After catching an error from g_locale_from_utf8() the error structure is not freed. This results in a warning from GLib when we later call g_spawn_async() with the same (now populated) error parameter. While we're in here copy the debug message from the Windows version of PowerOpsScriptCallback() so that the exit code of the power script is logged. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/services/plugins/powerOps/powerOps.c b/open-vm-tools/services/plugins/powerOps/powerOps.c index 735a3ac0e..15d73dbe3 100644 --- a/open-vm-tools/services/plugins/powerOps/powerOps.c +++ b/open-vm-tools/services/plugins/powerOps/powerOps.c @@ -307,7 +307,7 @@ PowerOpsRunScript(PowerOpState *state, * Callback for when the script process finishes on POSIX systems. * * @param[in] pid Child pid. - * @param[in] status Exit status of script. + * @param[in] exitcode Exit status of script. * @param[in] _state Plugin state. * * @return FALSE. @@ -315,14 +315,16 @@ PowerOpsRunScript(PowerOpState *state, static gboolean PowerOpsScriptCallback(GPid pid, - gint status, + gint exitcode, gpointer _state) { PowerOpState *state = _state; + gboolean success = exitcode == 0; ASSERT(state->pid != INVALID_PID); - PowerOpsStateChangeDone(_state, status == 0); + g_debug("Script exit code: %d, success = %d\n", exitcode, success); + PowerOpsStateChangeDone(_state, success); g_spawn_close_pid(state->pid); state->pid = INVALID_PID; return FALSE; @@ -352,6 +354,7 @@ PowerOpsRunScript(PowerOpState *state, argv[0] = g_locale_from_utf8(script, -1, NULL, NULL, &err); if (err != NULL) { g_debug("Conversion error: %s\n", err->message); + g_clear_error(&err); /* * If we could not convert to current locate let's hope that * what we have is a useable script name and use it directly.