diff options
author | Jiri Slaby <jslaby@suse.cz> | 2020-06-15 09:48:54 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-06-24 17:08:33 +0200 |
commit | f1bcbe141381a9f715f90d61003d6b47fe084d04 (patch) | |
tree | 78dcc4807ff25b822c6b4316cd18f82fa4fe76db /drivers/tty/vt | |
parent | vt: simplify vc_attr handling in vc_con_write_normal (diff) | |
download | linux-f1bcbe141381a9f715f90d61003d6b47fe084d04.tar.xz linux-f1bcbe141381a9f715f90d61003d6b47fe084d04.zip |
vt: make tc write more obvious in vc_con_write_normal
Nested ternary operators spread over 4 lines are really evil for
reading. Turn the outer one to proper 'if'. Now, we see, there is a
common path, so the code can be simplified. This way, the code is
understandable now.
Checked using symbolic execution (klee), that the old and new behaviors
are the same.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200615074910.19267-22-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r-- | drivers/tty/vt/vt.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 72ae8ede1ac9..4686f8b9251d 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2787,11 +2787,14 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c, if (vc->vc_decim) insert_char(vc, 1); vc_uniscr_putc(vc, next_c); - scr_writew(himask ? - ((vc_attr << 8) & ~himask) + - ((tc & 0x100) ? himask : 0) + (tc & 0xff) : - (vc_attr << 8) + tc, - (u16 *)vc->vc_pos); + + if (himask) + tc = ((tc & 0x100) ? himask : 0) | + (tc & 0xff); + tc |= (vc_attr << 8) & ~himask; + + scr_writew(tc, (u16 *)vc->vc_pos); + if (con_should_update(vc) && draw->x < 0) { draw->x = vc->state.x; draw->from = vc->vc_pos; |