qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value
@ 2020-07-02 16:09 Filip Bozuta
  2020-07-02 16:49 ` no-reply
  2020-07-17 13:02 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Filip Bozuta @ 2020-07-02 16:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Laurent Vivier, Filip Bozuta

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("]");
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value
  2020-07-02 16:09 [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value Filip Bozuta
@ 2020-07-02 16:49 ` no-reply
  2020-07-17 13:02 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2020-07-02 16:49 UTC (permalink / raw)
  To: Filip.Bozuta; +Cc: riku.voipio, qemu-devel, Filip.Bozuta, laurent

Patchew URL: https://patchew.org/QEMU/20200702160915.9517-1-Filip.Bozuta@syrmia.com/



Hi,

This series failed build test on FreeBSD host. Please find the details below.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
if qemu-system-x86_64 --help >/dev/null 2>&1; then
  QEMU=qemu-system-x86_64
elif /usr/libexec/qemu-kvm --help >/dev/null 2>&1; then
  QEMU=/usr/libexec/qemu-kvm
else
  exit 1
fi
make vm-build-freebsd J=21 QEMU=$QEMU
exit 0
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200702160915.9517-1-Filip.Bozuta@syrmia.com/testing.FreeBSD/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value
  2020-07-02 16:09 [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value Filip Bozuta
  2020-07-02 16:49 ` no-reply
@ 2020-07-17 13:02 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2020-07-17 13:02 UTC (permalink / raw)
  To: Filip Bozuta, qemu-devel; +Cc: Riku Voipio

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-17 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 16:09 [PATCH v2] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value Filip Bozuta
2020-07-02 16:49 ` no-reply
2020-07-17 13:02 ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).