[igt-dev] [PATCH i-g-t] runner: Chomp away trailing spaces from cmdline
Petri Latvala
petri.latvala at intel.com
Tue Sep 24 09:39:48 UTC 2019
On Tue, Sep 24, 2019 at 10:19:43AM +0100, Chris Wilson wrote:
> A minor refinement to remove the trailing spaces after converting the
> NUL-terminators to spaces.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Petri Latvala <petri.latvala at intel.com>
Reviewed-by: Petri Latvala <petri.latvala at intel.com>
I suppose it's impossible that cmdline is entirely spaces...
> ---
> runner/executor.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/runner/executor.c b/runner/executor.c
> index 3e0121421..130ba38d2 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -630,6 +630,10 @@ static const char *get_cmdline(pid_t pid, char *buf, ssize_t len)
> if (buf[i] == '\0')
> buf[i] = ' ';
>
> + /* chomp away the trailing spaces */
> + while (buf[len - 1] == ' ')
> + --len;
> +
> buf[len] = '\0'; /* but make sure that we return a valid string! */
> return buf;
> }
> --
> 2.23.0
>
More information about the igt-dev
mailing list