[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not prin
From: |
Laurent Vivier |
Subject: |
Re: [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value |
Date: |
Fri, 17 Jul 2020 15:02:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
Le 02/07/2020 à 18:09, Filip Bozuta a écrit :
> Function "print_fdset()" in "strace.c" is used to print the file descriptor
> values in "print__newselect()" which prints arguments of syscall _newselect().
> Until changes from this patch, this function was printing "," even after the
> last value of the fd_set argument. This was changed in this patch by removing
> this unnecessary "," after the last fd value and thus improving the estetics
> of
> the _newselect() "-strace" print.
>
> Implementation notes:
>
> The printing fix was made possible by using an existing function
> "get_comma()"
> which returns a "," or an empty string "" based on its argument (0 for ","
> and
> other for "").
>
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/strace.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 6044c66954..23ca5d88c8 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -541,6 +541,7 @@ static void
> print_fdset(int n, abi_ulong target_fds_addr)
> {
> int i;
> + int first = 1;
>
> qemu_log("[");
> if( target_fds_addr ) {
> @@ -555,9 +556,12 @@ print_fdset(int n, abi_ulong target_fds_addr)
> return;
>
> for (i=n; i>=0; i--) {
> - if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i &
> (TARGET_ABI_BITS - 1))) & 1)
> - qemu_log("%d,", i);
> + if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
> + (i & (TARGET_ABI_BITS - 1))) & 1) {
> + qemu_log("%s%d", get_comma(first), i);
> + first = 0;
> }
> + }
> unlock_user(target_fds, target_fds_addr, 0);
> }
> qemu_log("]");
>
I missed this patch for my last PR. I don't think it is critical enough
to be in an RC. Applied to linux-user-for-5.2 branch.
Thanks,
Laurent