From ec9fb90b2b978f2bb6eb44714fb43dc45ef2b81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Nov 2020 19:50:51 +0200 Subject: [PATCH] Mark g_subprocess_get_std{in,out,err}_pipe() return value as nullable Previously it was considered a programming error to call these on subprocesses created without the correct flags, but for bindings this distinction is difficult to handle automatically. Returning NULL instead does not cause any inconsistent behaviour and simplifies the API. --- gio/gsubprocess.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c index 8cc935423..4bf1f6b88 100644 --- a/gio/gsubprocess.c +++ b/gio/gsubprocess.c @@ -773,10 +773,10 @@ g_subprocess_get_identifier (GSubprocess *subprocess) * Gets the #GOutputStream that you can write to in order to give data * to the stdin of @subprocess. * - * The process must have been created with - * %G_SUBPROCESS_FLAGS_STDIN_PIPE. + * The process must have been created with %G_SUBPROCESS_FLAGS_STDIN_PIPE and + * not %G_SUBPROCESS_FLAGS_STDIN_INHERIT, otherwise %NULL will be returned. * - * Returns: (transfer none): the stdout pipe + * Returns: (nullable) (transfer none): the stdout pipe * * Since: 2.40 **/ @@ -784,7 +784,6 @@ GOutputStream * g_subprocess_get_stdin_pipe (GSubprocess *subprocess) { g_return_val_if_fail (G_IS_SUBPROCESS (subprocess), NULL); - g_return_val_if_fail (subprocess->stdin_pipe, NULL); return subprocess->stdin_pipe; } @@ -796,10 +795,10 @@ g_subprocess_get_stdin_pipe (GSubprocess *subprocess) * Gets the #GInputStream from which to read the stdout output of * @subprocess. * - * The process must have been created with - * %G_SUBPROCESS_FLAGS_STDOUT_PIPE. + * The process must have been created with %G_SUBPROCESS_FLAGS_STDOUT_PIPE, + * otherwise %NULL will be returned. * - * Returns: (transfer none): the stdout pipe + * Returns: (nullable) (transfer none): the stdout pipe * * Since: 2.40 **/ @@ -807,7 +806,6 @@ GInputStream * g_subprocess_get_stdout_pipe (GSubprocess *subprocess) { g_return_val_if_fail (G_IS_SUBPROCESS (subprocess), NULL); - g_return_val_if_fail (subprocess->stdout_pipe, NULL); return subprocess->stdout_pipe; } @@ -819,10 +817,10 @@ g_subprocess_get_stdout_pipe (GSubprocess *subprocess) * Gets the #GInputStream from which to read the stderr output of * @subprocess. * - * The process must have been created with - * %G_SUBPROCESS_FLAGS_STDERR_PIPE. + * The process must have been created with %G_SUBPROCESS_FLAGS_STDERR_PIPE, + * otherwise %NULL will be returned. * - * Returns: (transfer none): the stderr pipe + * Returns: (nullable) (transfer none): the stderr pipe * * Since: 2.40 **/ @@ -830,7 +828,6 @@ GInputStream * g_subprocess_get_stderr_pipe (GSubprocess *subprocess) { g_return_val_if_fail (G_IS_SUBPROCESS (subprocess), NULL); - g_return_val_if_fail (subprocess->stderr_pipe, NULL); return subprocess->stderr_pipe; }