Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Remove __assign_str_len()

Now that __assign_str() gets the length from the __string() (and
__string_len()) macros, there's no reason to have a separate
__assign_str_len() macro as __assign_str() can get the length of the
string needed.

Also remove __assign_rel_str() although it had no users anyway.

Link: https://lore.kernel.org/linux-trace-kernel/20240223152206.0b650659@gandalf.local.home

Cc: Jeff Layton <jlayton@kernel.org>
Acked-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+20 -25
+4 -4
fs/nfsd/trace.h
··· 104 104 TP_fast_assign( 105 105 __entry->xid = be32_to_cpu(rqst->rq_xid); 106 106 __entry->opcnt = opcnt; 107 - __assign_str_len(tag, tag, taglen); 107 + __assign_str(tag, tag); 108 108 ), 109 109 TP_printk("xid=0x%08x opcnt=%u tag=%s", 110 110 __entry->xid, __entry->opcnt, __get_str(tag) ··· 485 485 TP_fast_assign( 486 486 __entry->fh_hash = fhp ? knfsd_fh_hash(&fhp->fh_handle) : 0; 487 487 __entry->ino = ino; 488 - __assign_str_len(name, name, namlen) 488 + __assign_str(name, name); 489 489 ), 490 490 TP_printk("fh_hash=0x%08x ino=%llu name=%s", 491 491 __entry->fh_hash, __entry->ino, __get_str(name) ··· 906 906 __entry->flavor = clp->cl_cred.cr_flavor; 907 907 memcpy(__entry->verifier, (void *)&clp->cl_verifier, 908 908 NFS4_VERIFIER_SIZE); 909 - __assign_str_len(name, clp->cl_name.data, clp->cl_name.len); 909 + __assign_str(name, clp->cl_name.data); 910 910 ), 911 911 TP_printk("addr=%pISpc name='%s' verifier=0x%s flavor=%s client=%08x:%08x", 912 912 __entry->addr, __get_str(name), ··· 1976 1976 TP_fast_assign( 1977 1977 __entry->netns_ino = net->ns.inum; 1978 1978 __entry->time = time; 1979 - __assign_str_len(name, name, namelen); 1979 + __assign_str(name, name); 1980 1980 ), 1981 1981 TP_printk("file=%s time=%d\n", 1982 1982 __get_str(name), __entry->time
+11 -17
include/trace/stages/stage6_event_callback.h
··· 32 32 33 33 #undef __assign_str 34 34 #define __assign_str(dst, src) \ 35 - memcpy(__get_str(dst), __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, \ 36 - __get_dynamic_array_len(dst)) 37 - 38 - #undef __assign_str_len 39 - #define __assign_str_len(dst, src, len) \ 40 35 do { \ 41 - memcpy(__get_str(dst), \ 42 - __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, len); \ 43 - __get_str(dst)[len] = '\0'; \ 44 - } while(0) 36 + char *__str__ = __get_str(dst); \ 37 + int __len__ = __get_dynamic_array_len(dst) - 1; \ 38 + memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ 39 + EVENT_NULL_STR, __len__); \ 40 + __str__[__len__] = '\0'; \ 41 + } while (0) 45 42 46 43 #undef __assign_vstr 47 44 #define __assign_vstr(dst, fmt, va) \ ··· 91 94 92 95 #undef __assign_rel_str 93 96 #define __assign_rel_str(dst, src) \ 94 - memcpy(__get_rel_str(dst), __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, \ 95 - __get_rel_dynamic_array_len(dst)) 96 - 97 - #undef __assign_rel_str_len 98 - #define __assign_rel_str_len(dst, src, len) \ 99 97 do { \ 100 - memcpy(__get_rel_str(dst), \ 101 - __data_offsets.dst##_ptr_ ? : EVENT_NULL_STR, len); \ 102 - __get_rel_str(dst)[len] = '\0'; \ 98 + char *__str__ = __get_rel_str(dst); \ 99 + int __len__ = __get_rel_dynamic_array_len(dst) - 1; \ 100 + memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ 101 + EVENT_NULL_STR, __len__); \ 102 + __str__[__len__] = '\0'; \ 103 103 } while (0) 104 104 105 105 #undef __rel_bitmask
+5 -4
samples/trace_events/trace-events-sample.h
··· 163 163 * __string(). 164 164 * 165 165 * __string_len: This is a helper to a __dynamic_array, but it understands 166 - * that the array has characters in it, and with the combined 167 - * use of __assign_str_len(), it will allocate 'len' + 1 bytes 166 + * that the array has characters in it, it will allocate 'len' + 1 bytes 168 167 * in the ring buffer and add a '\0' to the string. This is 169 168 * useful if the string being saved has no terminating '\0' byte. 170 169 * It requires that the length of the string is known as it acts ··· 173 174 * 174 175 * __string_len(foo, bar, len) 175 176 * 176 - * To assign this string, use the helper macro __assign_str_len(). 177 + * To assign this string, use the helper macro __assign_str(). 178 + * The length is saved via the __string_len() and is retrieved in 179 + * __assign_str(). 177 180 * 178 - * __assign_str_len(foo, bar, len); 181 + * __assign_str(foo, bar); 179 182 * 180 183 * Then len + 1 is allocated to the ring buffer, and a nul terminating 181 184 * byte is added. This is similar to: