]> git.proxmox.com Git - mirror_qemu.git/blobdiff - ui/curses.c
curses: fix wchar_t printf warning
[mirror_qemu.git] / ui / curses.c
index 3a7e8649f3decaa39257fefdd817b5129b456328..fb63945188b2affe70ed23c76231456af07afd36 100644 (file)
@@ -75,9 +75,9 @@ static void curses_update(DisplayChangeListener *dcl,
             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] = (cchar_t) {
+                    .chars[0] = ch,
+                };
             }
             curses_line[x].attr |= at;
         }
@@ -453,8 +453,8 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
     swch = sizeof(wch);
 
     if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
-        fprintf(stderr, "Could not convert 0x%02x from WCHAR_T to UCS-2: %s\n",
-                        wch, strerror(errno));
+        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n",
+                (unsigned long)wch, strerror(errno));
         return 0xFFFD;
     }
 
@@ -519,6 +519,7 @@ static void font_setup(void)
 
     wchar_to_ucs_conv = iconv_open("UCS-2", "WCHAR_T");
     if (wchar_to_ucs_conv == (iconv_t) -1) {
+        iconv_close(ucs_to_wchar_conv);
         fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
                         strerror(errno));
         exit(1);
@@ -526,6 +527,8 @@ static void font_setup(void)
 
     font_conv = iconv_open("WCHAR_T", font_charset);
     if (font_conv == (iconv_t) -1) {
+        iconv_close(ucs_to_wchar_conv);
+        iconv_close(wchar_to_ucs_conv);
         fprintf(stderr, "Could not convert font glyphs from %s: '%s'\n",
                         font_charset, strerror(errno));
         exit(1);
@@ -646,6 +649,9 @@ static void font_setup(void)
             }
         }
     }
+    iconv_close(ucs_to_wchar_conv);
+    iconv_close(wchar_to_ucs_conv);
+    iconv_close(font_conv);
 }
 
 static void curses_setup(void)