[PATCH v1 01/11] tests: print quotation marks in print_quoted_memory

Dmitry V. Levin ldv at altlinux.org
Thu Jul 6 11:19:10 UTC 2017


On Thu, Jul 06, 2017 at 09:57:27AM +0800, JingPiao Chen wrote:
> * tests/print_quoted_string.c (print_quoted_memory): Add
> quotation marks printer.
> * tests/getcwd.c (main): Remove quotation marks printer.
> * tests/keyctl.c (print_quoted_string_limit): Likewise.
> * tests/netlink_protocol.c (send_query): Likewise.
> * tests/uname.c (main): Likewise.
> * tests/xattr.c (main): Likewise.
[...]
> diff --git a/tests/print_quoted_string.c b/tests/print_quoted_string.c
> index 732fe3d..6fc0d16 100644
> --- a/tests/print_quoted_string.c
> +++ b/tests/print_quoted_string.c
> @@ -21,6 +21,7 @@ print_quoted_memory(const char *instr, const size_t len)
>  	const unsigned char *str = (const unsigned char *) instr;
>  	size_t i;
>  
> +	printf("\"");
>  	for (i = 0; i < len; ++i) {
>  		const int c = str[i];
>  		switch (c) {
> @@ -72,4 +73,5 @@ print_quoted_memory(const char *instr, const size_t len)
>  		}
>  	}
>  
> +	printf("\"");
>  }
[...]
> diff --git a/tests/xattr.c b/tests/xattr.c
> index 03b4270..fea9e92 100644
> --- a/tests/xattr.c
> +++ b/tests/xattr.c
> @@ -112,9 +112,7 @@ main(void)
>  	else {
>  		const int ellipsis = rc > DEFAULT_STRLEN;
>  
> -		putchar('"');
>  		print_quoted_memory(big, ellipsis ? DEFAULT_STRLEN : rc);
> -		putchar('"');
>  		if (ellipsis)
>  			fputs("...", stdout);
>  	}

I'm slightly in favour of putchar('"') over printf("\"") nowadays.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170706/38f8b8ed/attachment.bin>


More information about the Strace-devel mailing list