linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v3] tools/lib/traceevent, perf tools: Handle %pU format correctly
Date: Mon, 21 Oct 2019 22:30:37 +0800	[thread overview]
Message-ID: <6bc13ae1-9f26-afaa-ddfa-f1dd1cdcf6df@gmx.com> (raw)
In-Reply-To: <20191021102408.3bb4aa8b@gandalf.local.home>


[-- Attachment #1.1: Type: text/plain, Size: 2556 bytes --]



On 2019/10/21 下午10:24, Steven Rostedt wrote:
> On Mon, 21 Oct 2019 22:03:21 +0800
> Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
> 
>> On 2019/10/21 下午9:56, Steven Rostedt wrote:
>>> On Mon, 21 Oct 2019 17:47:30 +0800
>>> Qu Wenruo <wqu@suse.com> wrote:
>>>   
>>>> +static void print_uuid_arg(struct trace_seq *s, void *data, int size,
>>>> +			   struct tep_event *event, struct tep_print_arg *arg)
>>>> +{
>>>> +	unsigned char *buf;
>>>> +	int i;
>>>> +
>>>> +	if (arg->type != TEP_PRINT_FIELD) {
>>>> +		trace_seq_printf(s, "ARG TYPE NOT FIELID but %d", arg->type);
>>>> +		return;
>>>> +	}
>>>> +
>>>> +	if (!arg->field.field) {
>>>> +		arg->field.field = tep_find_any_field(event, arg->field.name);
>>>> +		if (!arg->field.field) {
>>>> +			do_warning("%s: field %s not found",
>>>> +				   __func__, arg->field.name);
>>>> +			return;
>>>> +		}
>>>> +	}
>>>> +	if (arg->field.field->size < 16) {
>>>> +		trace_seq_printf(s, "INVALID UUID: size have %u expect 16",
>>>> +				arg->field.field->size);
>>>> +		return;
>>>> +	}
>>>> +	buf = data + arg->field.field->offset;
>>>> +
>>>> +	for (i = 0; i < 8; i++) {
>>>> +		trace_seq_printf(s, "%02x", buf[2 * i]);
>>>> +		trace_seq_printf(s, "%02x", buf[2 * i + 1]);
>>>> +		if (1 <= i && i <= 4)  
>>>
>>> I'm fine with this patch except for one nit. The above is hard to read
>>> (in my opinion), and I absolutely hate the "constant" compare to
>>> "variable" notation. Please change the above to:
>>>
>>> 		if (i >= 1 && i <= 4)  
>>
>> Isn't this ( 1 <= i && i <= 4 ) easier to find out the lower and upper
>> boundary? only two numbers, both at the end of the expression.
> 
> I don't read it like that.
> 
>>
>> I feel that ( i >= 1 && i <= 4 ) easier to write, but takes me extra
>> half second to read, thus I changed to the current one.
> 
> How do you read it in English?

How about mathematics interval?

i in [1, 4].

It looks way easier and simpler no matter what language you speak.

Thanks,
Qu
> 
>   "If one is less than or equal to i and i is less than or equal to
>   four."
> 
> Or
> 
>   "If i is greater than or equal to one and i is less than or equal to
>    four."
> 
> ?
> 
> I read it the second way, and I believe most English speakers read it
> that way too.
> 
> It took me a minute or two to understand the original method, because
> my mind likes to take a variable and keep it on the same side of the
> comparison, and the variable should always be first.
> 
> -- Steve
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-10-21 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21  9:47 [PATCH v3] tools/lib/traceevent, perf tools: Handle %pU format correctly Qu Wenruo
2019-10-21 13:56 ` Steven Rostedt
2019-10-21 14:03   ` Qu Wenruo
2019-10-21 14:24     ` Steven Rostedt
2019-10-21 14:30       ` Qu Wenruo [this message]
2019-10-21 15:34         ` Steven Rostedt
2019-10-29 14:39 ` [tools/lib/traceevent, perf tools] b28d7df1d3: stderr.In_file_included_from_event-parse.c kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6bc13ae1-9f26-afaa-ddfa-f1dd1cdcf6df@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).