commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 35/75: fix compiler warnings in hurd/console-client


From: Samuel Thibault
Subject: [hurd] 35/75: fix compiler warnings in hurd/console-client
Date: Thu, 14 Jan 2016 01:04:08 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch dde
in repository hurd.

commit cc3e97aa0141410eb8b05cab34aecf65f44a164c
Author: Flavio Cruz <address@hidden>
Date:   Tue Dec 29 17:35:00 2015 +0100

    fix compiler warnings in hurd/console-client
    
    console-client: Fix several compiler warnings.
    
    * console-client/bdf.c: Use size_t instead of int.
    * console-client/driver.c: Remove unused variable errstring.
    * console-client/pc-kbd.c: Cast sc to scancode_x1 before comparing with enum
    values.
    * console-client/vga-dynacolor.h: Use an explicit if in reference counting.
    * console-client/vga-dynafont.c: Use usigned char for bitmaps.
    * console-client/vga-support.c: Use unsigned char instead of char.
    * console-client/vga-support.h: Likewise.
    * console-client/vga.c: Use conchar_attr_equal instead of casting 
structures to
    integers.
    * hurd/console.h: Add conchar_attr_equal to compare conchar_attr_t 
structures.
---
 console-client/bdf.c           |  4 ++--
 console-client/driver.c        |  2 +-
 console-client/pc-kbd.c        | 21 +++++++++++----------
 console-client/vga-dynacolor.h | 10 ++++++++--
 console-client/vga-dynafont.c  |  8 ++++----
 console-client/vga-support.c   |  8 +++++---
 console-client/vga-support.h   |  4 ++--
 console-client/vga.c           |  2 +-
 hurd/console.h                 |  7 +++++++
 9 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/console-client/bdf.c b/console-client/bdf.c
index 467c139..b61ef35 100644
--- a/console-client/bdf.c
+++ b/console-client/bdf.c
@@ -128,7 +128,7 @@ parse_hexbyte (char *line, unsigned char *byte)
    COMMENT lines, and removes whitespace at the beginning and end of a
    line.  */
 static int
-next_line (char **line, int *size, FILE *file, int *count)
+next_line (char **line, size_t *size, FILE *file, int *count)
 {
   int len;
 
@@ -184,7 +184,7 @@ bdf_read (FILE *filep, bdf_font_t *font, int *linecount)
 {
   bdf_error_t err = 0;
   char *line = 0;
-  int line_size = 0;
+  size_t line_size = 0;
   int len;
   int done = 0;
   bdf_font_t bdf;
diff --git a/console-client/driver.c b/console-client/driver.c
index 6407824..7a55bbe 100644
--- a/console-client/driver.c
+++ b/console-client/driver.c
@@ -130,7 +130,7 @@ error_t driver_add (const char *const name, const char 
*const driver,
       shobj = dlopen (filename, RTLD_LAZY);
       if (!shobj)
        {
-         const char *errstring = dlerror (); /* Must always call or it leaks! 
*/
+         (void) dlerror (); /* Must always call or it leaks! */
          if (errno != ENOENT)
            {
              free (filename);
diff --git a/console-client/pc-kbd.c b/console-client/pc-kbd.c
index 21c0987..6f2d827 100644
--- a/console-client/pc-kbd.c
+++ b/console-client/pc-kbd.c
@@ -1100,10 +1100,11 @@ input_loop (void *unused)
        }
       else if (state.extended == 1)
        {
+         const enum scancode_x1 scx1 = (enum scancode_x1) sc;
          state.extended = 0;
-         if (sc == SC_X1_RIGHT_CTRL)
+         if (scx1 == SC_X1_RIGHT_CTRL)
            state.right_ctrl = down;
-         else if (sc == SC_X1_RIGHT_ALT)
+         else if (scx1 == SC_X1_RIGHT_ALT)
            {
              state.right_alt = down;
              
@@ -1139,23 +1140,23 @@ input_loop (void *unused)
                    }
                }
            }
-         else if (state.right_alt && down && sc == SC_X1_PAD_SLASH) /* XXX */
+         else if (state.right_alt && down && scx1 == SC_X1_PAD_SLASH) /* XXX */
            state.direct = (state.direct << 4) | 0xb;
-         else if (state.right_alt && down && sc == SC_X1_PAD_ENTER) /* XXX */
+         else if (state.right_alt && down && scx1 == SC_X1_PAD_ENTER) /* XXX */
            state.direct = (state.direct << 4) | 0xf;
-         else if (state.left_alt && down && sc == SC_X1_RIGHT) /* XXX */
+         else if (state.left_alt && down && scx1 == SC_X1_RIGHT) /* XXX */
            console_switch (0, 1);
-         else if (state.left_alt && down && sc == SC_X1_LEFT) /* XXX */
+         else if (state.left_alt && down && scx1 == SC_X1_LEFT) /* XXX */
            console_switch (0, -1);
-         else if (state.left_alt && down && sc == SC_X1_UP) /* XXX */
+         else if (state.left_alt && down && scx1 == SC_X1_UP) /* XXX */
            console_scrollback (CONS_SCROLL_DELTA_LINES, 1);
-         else if (state.left_alt && down && sc == SC_X1_DOWN) /* XXX */
+         else if (state.left_alt && down && scx1 == SC_X1_DOWN) /* XXX */
            console_scrollback (CONS_SCROLL_DELTA_LINES, -1);
          else if ((state.right_shift || state.left_shift)
-                  && down && sc == SC_X1_PGUP) /* XXX */
+                  && down && scx1 == SC_X1_PGUP) /* XXX */
            console_scrollback (CONS_SCROLL_DELTA_SCREENS, 0.5);
          else if ((state.right_shift || state.left_shift)
-                  && down && sc == SC_X1_PGDN) /* XXX */
+                  && down && scx1 == SC_X1_PGDN) /* XXX */
            console_scrollback (CONS_SCROLL_DELTA_SCREENS, -0.5);
          else if (down && sc < sizeof (sc_x1_to_kc)/sizeof (sc_x1_to_kc[0]))
            {
diff --git a/console-client/vga-dynacolor.h b/console-client/vga-dynacolor.h
index 304bcc1..0526e0d 100644
--- a/console-client/vga-dynacolor.h
+++ b/console-client/vga-dynacolor.h
@@ -77,11 +77,17 @@ signed char dynacolor_allocate (dynacolor_t *dc, unsigned 
char col);
 
 /* Add a reference to palette entry P in the dynamic font DC.  */
 #define dynacolor_add_ref(dc,p)                                                
\
-  ((dc).ref[0] >= 0 && (dc).ref[p]++)
+  do {                                                                  \
+      if ((dc).ref[0] >= 0)                                             \
+        (dc).ref[p]++;                                                  \
+  } while (0)
 
 /* Deallocate a reference for palette entry P in the dynamic font DC.  */
 #define dynacolor_release(dc,p)                                                
\
-  ((dc).ref[0] >= 0 && (dc).ref[p]--)
+  do {                                                                  \
+      if ((dc).ref[0] >= 0)                                             \
+        (dc).ref[p]--;                                                  \
+  } while (0)
 
 /* This is a convenience function that looks up a replacement color
    pair if the original colors are not available.  The function always
diff --git a/console-client/vga-dynafont.c b/console-client/vga-dynafont.c
index 573d63b..2cee47e 100644
--- a/console-client/vga-dynafont.c
+++ b/console-client/vga-dynafont.c
@@ -46,7 +46,7 @@ static dynafont_t active_dynafont;
 /* One glyph in a VGA font is 8 pixels wide and 32 pixels high.  Only
    the first N lines are visible, and N depends on the VGA register
    settings.  */
-typedef char vga_font_glyph[VGA_FONT_HEIGHT];
+typedef unsigned char vga_font_glyph[VGA_FONT_HEIGHT];
 
 
 /* For each glyph in the VGA font, one instance of this structure is
@@ -329,7 +329,7 @@ create_system_font (void)
       else
        {
          int i;
-         char glyph_bitmap[32];
+         unsigned char glyph_bitmap[32];
          
          for (i = 0; i < 16; i++)
            {
@@ -591,7 +591,7 @@ dynafont_new (bdf_font_t font, bdf_font_t font_italic, 
bdf_font_t font_bold,
     else
       {
        int i;
-       char *gl = df->vga_font[FONT_INDEX_UNKNOWN];
+       unsigned char *gl = df->vga_font[FONT_INDEX_UNKNOWN];
        /* XXX Take font height into account.  */
        gl[0] = 0x7E;   /*  ******  */
        gl[1] = 0xC3;   /* **    ** */
@@ -988,7 +988,7 @@ dynafont_activate (dynafont_t df)
 {
   int height = (df->font->bbox.height > 32) ? 32 : df->font->bbox.height;
 
-  vga_write_font_buffer (0, 0, (char *) df->vga_font,
+  vga_write_font_buffer (0, 0, (unsigned char *) df->vga_font,
                         df->size * VGA_FONT_HEIGHT);
   vga_select_font_buffer (0, (df->size == 512) ? 1 : 0);
 
diff --git a/console-client/vga-support.c b/console-client/vga-support.c
index e8497f8..3a2d758 100644
--- a/console-client/vga-support.c
+++ b/console-client/vga-support.c
@@ -216,7 +216,7 @@ vga_fini (void)
    DATALEN bytes from DATA (if WRITE is not 0).  */
 static void
 vga_read_write_font_buffer (int write, int buffer, int index,
-                           char *data, size_t datalen)
+                           unsigned char *data, size_t datalen)
 {
   char saved_seq_map;
   char saved_seq_mode;
@@ -271,7 +271,8 @@ vga_read_write_font_buffer (int write, int buffer, int 
index,
 /* Write DATALEN bytes from DATA to the font buffer BUFFER, starting
    from glyph INDEX.  */
 void
-vga_write_font_buffer (int buffer, int index, char *data, size_t datalen)
+vga_write_font_buffer (int buffer, int index, unsigned char *data,
+                       size_t datalen)
 {
   vga_read_write_font_buffer (1, buffer, index, data, datalen);
 }
@@ -279,7 +280,8 @@ vga_write_font_buffer (int buffer, int index, char *data, 
size_t datalen)
 /* Read DATALEN bytes into DATA from the font buffer BUFFER, starting
    from glyph INDEX.  */
 void
-vga_read_font_buffer (int buffer, int index, char *data, size_t datalen)
+vga_read_font_buffer (int buffer, int index, unsigned char *data,
+                      size_t datalen)
 {
   vga_read_write_font_buffer (0, buffer, index, data, datalen);
 }
diff --git a/console-client/vga-support.h b/console-client/vga-support.h
index 38c6248..17c0b5f 100644
--- a/console-client/vga-support.h
+++ b/console-client/vga-support.h
@@ -44,12 +44,12 @@ void vga_fini (void);
 /* Write DATALEN bytes from DATA to the font buffer BUFFER, starting
    from glyph index.  */
 void vga_write_font_buffer (int buffer, int index,
-                           char *data, size_t datalen);
+                           unsigned char *data, size_t datalen);
 
 /* Read DATALEN bytes into DATA from the font buffer BUFFER, starting
    from glyph INDEX.  */
 void vga_read_font_buffer (int buffer, int index,
-                          char *data, size_t datalen);
+                          unsigned char *data, size_t datalen);
 
 /* Set FONT_BUFFER_SUPP to FONT_BUFFER if the font is small.  */
 void vga_select_font_buffer (int font_buffer, int font_buffer_supp);
diff --git a/console-client/vga.c b/console-client/vga.c
index cf6c8c3..2d74aae 100644
--- a/console-client/vga.c
+++ b/console-client/vga.c
@@ -713,7 +713,7 @@ vga_display_write (void *handle, conchar_t *str, size_t 
length,
        return 0;
 
       if (!disp->cur_conchar_attr_init
-         || *(uint32_t *) &disp->cur_conchar_attr != *(uint32_t *) &str->attr)
+         || !conchar_attr_equal (&disp->cur_conchar_attr, &str->attr))
        {
          if (!disp->cur_conchar_attr_init)
            disp->cur_conchar_attr_init = 1;
diff --git a/hurd/console.h b/hurd/console.h
index 05177eb..f037493 100644
--- a/hurd/console.h
+++ b/hurd/console.h
@@ -20,6 +20,7 @@
 #define _HURD_CONSOLE_H
 
 #include <stdint.h>
+#include <string.h>
 #include <wchar.h>
 
 typedef enum
@@ -51,6 +52,12 @@ typedef struct
   uint32_t bold : 1;
 } conchar_attr_t; 
 
+static inline int
+conchar_attr_equal (conchar_attr_t *c1, conchar_attr_t *c2)
+{
+  return !memcmp (c1, c2, sizeof (conchar_attr_t));
+}
+
 /* We support double-width characters by using an extra bit to identify the
    continuation in the character matrix.  The constants below document our
    usage of wchar_t.  */

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

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