linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Pitre <nicolas.pitre@linaro.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dave Mielke <Dave@mielke.cc>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] vt: coherence validation code for the unicode screen buffer
Date: Mon, 18 Jun 2018 21:50:08 -0400 (EDT)	[thread overview]
Message-ID: <nycvar.YSQ.7.76.1806182110450.16670@knanqh.ubzr> (raw)
In-Reply-To: <CAHp75VfG_4zw+NPuHTUyH-gzdktiCKVcnWcwo0D_fAgfPbdk+A@mail.gmail.com>

On Tue, 19 Jun 2018, Andy Shevchenko wrote:

> On Sun, Jun 17, 2018 at 10:07 PM, Nicolas Pitre
> <nicolas.pitre@linaro.org> wrote:
> > Make sure the unicode screen buffer matches the video screen content.
> > This is provided for debugging convenience and disabled by default.
> 
> > +#define VC_UNI_SCREEN_DEBUG 0
> 
> > +       if (!VC_UNI_SCREEN_DEBUG || !uniscr)
> > +               return;
> 
> Hmm... Interesting. I would rather go with
> #ifdef ..._DEBUG
> ...
> #else
> return;
> #endif
> 
> It will relax requirement on how to define _DEBUG. I don't recall I
> see something like you proposing in the kernel for the same purpose.

Some random examples:

include/crypto/scatterwalk.h:106;
                if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE && !PageSlab(page))

include/math-emu/single.h:68:
    if (!FP_INHIBIT_RESULTS)

This form also allows for the compiler to parse and validate the code 
whether or not the feature is enabled, while still optimizing it away in 
the end if not enabled.

> > +
> > +       WARN_CONSOLE_UNLOCKED();
> > +
> > +       /*
> > +        * Make sure our unicode screen translates into the same glyphs
> > +        * as the actual screen. This is brutal indeed.
> > +        */
> > +       p = (unsigned short *)vc->vc_origin;
> > +       mask = vc->vc_hi_font_mask | 0xff;
> > +       for (y = 0; y < vc->vc_rows; y++) {
> > +               char32_t *line = uniscr->lines[y];
> > +               for (x = 0; x < vc->vc_cols; x++) {
> > +                       u16 glyph = scr_readw(p++) & mask;
> > +                       char32_t uc = line[x];
> > +                       int tc = conv_uni_to_pc(vc, uc);
> > +                       if (tc == -4)
> > +                               tc = conv_uni_to_pc(vc, 0xfffd);
> > +                       if (tc == -4)
> > +                               tc = conv_uni_to_pc(vc, '?');
> > +                       if (tc != glyph)
> 
> > +                               pr_notice("%s: mismatch at %d,%d: "
> > +                                         "glyph=%#x tc=%#x\n", __func__,
> > +                                         x, y, glyph, tc);
> 
> Don't split format string in printk(). checkpatch will not warn on longer lines.

I didn't do it like that for checkpatch but to keep the code readable.
I don't particularly care either ways though.


Nicolas

  reply	other threads:[~2018-06-19  1:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-17 19:07 [PATCH v2 0/4] have the vt console preserve unicode characters Nicolas Pitre
2018-06-17 19:07 ` [PATCH v2 1/4] vt: preserve unicode values corresponding to screen characters Nicolas Pitre
2018-06-17 22:59   ` valdis.kletnieks
2018-06-17 23:17     ` Nicolas Pitre
2018-06-17 23:23       ` valdis.kletnieks
2018-06-17 19:07 ` [PATCH v2 2/4] vt: introduce unicode mode for /dev/vcs Nicolas Pitre
2018-06-17 19:07 ` [PATCH v2 3/4] vt: unicode fallback for scrollback Nicolas Pitre
2018-06-17 19:07 ` [PATCH v2 4/4] vt: coherence validation code for the unicode screen buffer Nicolas Pitre
2018-06-18 22:01   ` Andy Shevchenko
2018-06-19  1:50     ` Nicolas Pitre [this message]
2018-06-19  4:52       ` Joe Perches
2018-06-19 12:14         ` Nicolas Pitre
2018-06-19 13:09 ` [PATCH v2 0/4] have the vt console preserve unicode characters Adam Borowski
2018-06-19 13:52   ` Dave Mielke
2018-06-19 15:14     ` Adam Borowski
2018-06-19 15:30       ` Dave Mielke
2018-06-19 15:34   ` Nicolas Pitre
2018-06-21  1:43     ` Adam Borowski
2018-06-21  2:21       ` Dave Mielke
2018-06-21  3:03         ` Nicolas Pitre
2018-06-22  1:54         ` Adam Borowski
2018-06-22  6:41           ` Samuel Thibault
2018-06-22 15:59           ` Alan Cox
2018-06-22 16:28             ` Nicolas Pitre
2018-06-22 17:51               ` Alan Cox
2018-06-21  2:59       ` Nicolas Pitre
2018-06-25  0:33         ` Adam Borowski

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=nycvar.YSQ.7.76.1806182110450.16670@knanqh.ubzr \
    --to=nicolas.pitre@linaro.org \
    --cc=Dave@mielke.cc \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel.thibault@ens-lyon.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 NNTP newsgroup(s).