howto strip trailing newline from a format string at compile-time ?

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

 



hi all

So Im (always) hacking on dynamic-debug..

Ive added a 'T' flag, which causes dyndbg to send its message
to /sys/kernel/tracing/trace instead of syslog (p does that).

trouble is, pr_debug() calls almost always have a trailing newline,
and ftrace adds its own, so the tracefile has empty lines after each
pr_debug's message.


I would like to fix this in the format-string, with a macro,
and add the newline explicitly, when given originally, for the 'p'/syslog case.
While still needing an add-newline? decision,
it avoids scanning format or sprint-d bufs for the trailing newline.


ie
#define strip_trailing_newline(str) .....
#define has_trailing_newline(str) ...

theyd get used in:
#define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \
...
.format = strip_trailing_newline(fmt), \
.add_nl = has_trailing_newline(fmt), \

that new .add_nl bit-field might be difficult - the other flags in _ddebug
are not individual bit-fields, but I think this would have to be separate
to be initializable in the macro.  maybe no big deal.

and how to fix the 'fmt expanded 2x' problem ?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux