Re: [PATCH 1/2 v4] scsi: add __print_hex() to ftrace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> +const char *
>> +ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
>> +{
>> +	int i;
>> +	const char *ret = p->buffer + p->len;
>> +
>> +	for (i = 0; i < buf_len; i++)
>> +		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
>> +
>> +	trace_seq_putc(p, 0);
> 
> I would not put the putc(p, 0) into a helper function. This terminates
> the buffer, and strings added to the trace_seq will go after the '\0'.
> 

This is exactly what ftrace_print_flags_seq() and ftrace_print_symbols_seq()
do, and exactly what we want.

An example:

TP_printk("%s,%s", __print_flags(...), __print_flags(...));

We need 2 seperated strings, while trace_seq_terminate() will make it
a single string.

> What we need is this in trace_seq.h:
> 
> static inline trace_seq_terminate(struct trace_seq *s)
> {
> 	if (!s->full)
> 		s->buffer[s->len] = 0;
> }
> 
> This will add a '0' to the buffer after the last string, but will not
> increment length while doing it. Thus, new data added to the buffer
> would still be appended correctly.
> 
> -- Steve
> 
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL(ftrace_print_hex_seq);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux