gamemode-context: Avoid GameModeClient *cl being NULL

There's no need in defining it at the top of the function. During
rebase, I had one `if` accessing `cl->executable` too early but we were
only storing the path in `executable` at that point.

This change avoids accessing `cl` while it might be NULL.

Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
Kai Krakow 2019-10-14 23:20:45 +02:00 committed by Alex Smith
parent 0668e3b4da
commit 24f054659c

View File

@ -403,7 +403,6 @@ int game_mode_context_register(GameModeContext *self, pid_t client, pid_t reques
errno = 0;
/* Construct a new client if we can */
GameModeClient *cl = NULL;
char *executable = NULL;
int err = -1;
@ -465,7 +464,7 @@ int game_mode_context_register(GameModeContext *self, pid_t client, pid_t reques
}
/* From now on we depend on the client, initialize it */
cl = game_mode_client_new(client, executable, requester);
GameModeClient *cl = game_mode_client_new(client, executable, requester);
if (!cl)
goto error_cleanup;
free(executable); /* we're now done with memory */
@ -497,7 +496,6 @@ error_cleanup:
if (errno != 0)
LOG_ERROR("Failed to register client [%d]: %s\n", client, strerror(errno));
free(executable);
game_mode_client_unref(cl);
return err;
}