qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 2/2] curses: add option to specify VGA font encod


From: Peter Maydell
Subject: Re: [Qemu-devel] [PULL 2/2] curses: add option to specify VGA font encoding
Date: Thu, 14 Mar 2019 17:00:33 +0000

On Wed, 13 Mar 2019 at 07:38, Gerd Hoffmann <address@hidden> wrote:
>
> From: Samuel Thibault <address@hidden>
>
> This uses iconv to convert glyphs from the specified VGA font encoding to
> unicode, and makes use of cchar_t instead of chtype when using ncursesw,
> which allows to store all wide char as well as the WACS values. The default
> charset is made CP437 since that is the charset of the hardware default VGA
> font. This also makes the curses backend set the LC_CTYPE locale to "" to
> allow curses to emit wide characters.

>  static void curses_update(DisplayChangeListener *dcl,
>                            int x, int y, int w, int h)
>  {
>      console_ch_t *line;
> -    chtype curses_line[width];
> +    cchar_t curses_line[width];
>
>      line = screen + y * width;
>      for (h += y; y < h; y ++, line += width) {
>          for (x = 0; x < width; x++) {
>              chtype ch = line[x] & 0xff;
>              chtype at = line[x] & ~0xff;
> -            if (vga_to_curses[ch]) {
> -                ch = vga_to_curses[ch];
> +            if (vga_to_curses[ch].chars[0]) {
> +                curses_line[x] = vga_to_curses[ch];
> +            } else {
> +                curses_line[x].chars[0] = ch;
> +                curses_line[x].chars[1] = 0;
> +                curses_line[x].attr = 0;
>              }
> -            curses_line[x] = ch | at;
> +            curses_line[x].attr |= at;
>          }
> -        mvwaddchnstr(screenpad, y, 0, curses_line, width);
> +        mvwadd_wchnstr(screenpad, y, 0, curses_line, width);

Hi -- Coverity complains about this (CID 1399711), because
'cchar_t' is a struct type and in the code path
where 'vga_to_curses[ch].chars[0]' is zero we don't
initialize the whole struct. (In the header definitions
Coverity is using there is also a 'ext_color' field.)
I think we could fix this by changing

> +                curses_line[x].chars[0] = ch;
> +                curses_line[x].chars[1] = 0;
> +                curses_line[x].attr = 0;

to
   curses_line[x] = {};
   curses_line[x].chars[0] = ch;

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]