Kernel Newbies archive mirror
 help / color / mirror / Atom feed
From: jim.cromie@gmail.com
To: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: howto strip trailing newline from a format string at compile-time ?
Date: Wed, 12 Oct 2022 13:05:07 -0600	[thread overview]
Message-ID: <CAJfuBxzdKepKAYnW2JTWZwOMpGk-fUER0b+m4NFW8aaovOUEgg@mail.gmail.com> (raw)

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@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

                 reply	other threads:[~2022-10-12 19:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAJfuBxzdKepKAYnW2JTWZwOMpGk-fUER0b+m4NFW8aaovOUEgg@mail.gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).