Browse Source

Code cleanup after runing splint on src/main.c file

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Slava Zanko 13 years ago
parent
commit
a1e34b8dfa
10 changed files with 49 additions and 43 deletions
  1. 2 2
      lib/charsets.h
  2. 1 0
      lib/fs.h
  3. 1 0
      lib/global.c
  4. 5 0
      lib/global.h
  5. 3 7
      lib/tty/key.c
  6. 1 2
      lib/tty/key.h
  7. 18 14
      src/cons.handler.c
  8. 3 3
      src/consaver/cons.saver.h
  9. 13 13
      src/execute.c
  10. 2 2
      src/filemanager/cmd.c

+ 2 - 2
lib/charsets.h

@@ -93,7 +93,7 @@ convert_to_display_c (int c)
 {
     if (c < 0 || c >= 256)
         return c;
-    return conv_displ[c];
+    return (int) conv_displ[c];
 }
 
 static inline int
@@ -101,7 +101,7 @@ convert_from_input_c (int c)
 {
     if (c < 0 || c >= 256)
         return c;
-    return conv_input[c];
+    return (int) conv_input[c];
 }
 
 #endif /* HAVE_CHARSET */

+ 1 - 0
lib/fs.h

@@ -88,6 +88,7 @@ static inline void
 compute_namelen (struct dirent *dent __attribute__ ((unused)))
 {
 #ifdef DIRENT_LENGTH_COMPUTED
+    (void) dent;
     return;
 #else
     dent->d_namlen = strlen (dent);

+ 1 - 0
lib/global.c

@@ -104,6 +104,7 @@ mc_global_t mc_global = {
         .disable_colors = FALSE,
         .ugly_line_drawing = FALSE,
         .old_mouse = FALSE,
+        .alternate_plus_minus = FALSE,
     },
 
     .vfs =

+ 5 - 0
lib/global.h

@@ -258,6 +258,11 @@ typedef struct
 
         /* Tries to use old highlight mouse tracking */
         gboolean old_mouse;
+
+        /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
+           and M-- and keypad + / - */
+        gboolean alternate_plus_minus;
+
     } tty;
 
     struct

+ 3 - 7
lib/tty/key.c

@@ -75,10 +75,6 @@
 
 /*** global variables ****************************************************************************/
 
-/* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
-   and M-- and keypad + / - */
-int alternate_plus_minus = 0;
-
 int mou_auto_repeat = 100;
 int double_click_speed = 250;
 int old_esc_mode = 0;
@@ -1058,7 +1054,7 @@ correct_key_code (int code)
         mod &= ~KEY_M_SHIFT;
     }
 
-    if (!alternate_plus_minus)
+    if (!mc_global.tty.alternate_plus_minus)
         switch (c)
         {
         case KEY_KP_ADD:
@@ -2102,7 +2098,7 @@ learn_key (void)
 void
 numeric_keypad_mode (void)
 {
-    if (mc_global.tty.console_flag || mc_global.tty.xterm_flag)
+    if (mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)
     {
         fputs (ESC_STR ">", stdout);
         fflush (stdout);
@@ -2114,7 +2110,7 @@ numeric_keypad_mode (void)
 void
 application_keypad_mode (void)
 {
-    if (mc_global.tty.console_flag || mc_global.tty.xterm_flag)
+    if (mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag)
     {
         fputs (ESC_STR "=", stdout);
         fflush (stdout);

+ 1 - 2
lib/tty/key.h

@@ -53,7 +53,6 @@ extern const key_code_name_t key_name_conv_tab[];
 
 extern int old_esc_mode_timeout;
 
-extern int alternate_plus_minus;
 extern int double_click_speed;
 extern int old_esc_mode;
 extern int use_8th_bit_as_meta;
@@ -104,7 +103,7 @@ void application_keypad_mode (void);
 static inline gboolean
 is_abort_char (int c)
 {
-    return ((c == ESC_CHAR) || (c == KEY_F (10)));
+    return ((c == (int) ESC_CHAR) || (c == (int) KEY_F (10)));
 }
 
 #endif /* MC_KEY_H */

+ 18 - 14
src/cons.handler.c

@@ -88,7 +88,7 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
     ssize_t ret;
 
     /* Is tty console? */
-    if (!mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag == '\0')
         return;
     /* Paranoid: Is the cons.saver still running? */
     if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
@@ -128,7 +128,7 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
 /* --------------------------------------------------------------------------------------------- */
 
 static void
-handle_console_linux (unsigned char action)
+handle_console_linux (console_action_t action)
 {
     char *tty_name;
     char *mc_conssaver;
@@ -166,7 +166,7 @@ handle_console_linux (unsigned char action)
             status = close (pipefd2[1]);
             /* Was the child successful? */
             status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
-            if (!mc_global.tty.console_flag)
+            if (mc_global.tty.console_flag == '\0')
             {
                 pid_t ret;
                 status = close (pipefd1[1]);
@@ -216,7 +216,7 @@ handle_console_linux (unsigned char action)
     case CONSOLE_SAVE:
     case CONSOLE_RESTORE:
         /* Is tty console? */
-        if (!mc_global.tty.console_flag)
+        if (mc_global.tty.console_flag == '\0')
             return;
         /* Paranoid: Is the cons.saver still running? */
         if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
@@ -232,7 +232,7 @@ handle_console_linux (unsigned char action)
             /* Wait the console handler to do its job */
             status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
         }
-        if (action == CONSOLE_DONE || !mc_global.tty.console_flag)
+        if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0')
         {
             /* We are done -> Let's clean up */
             pid_t ret;
@@ -242,6 +242,8 @@ handle_console_linux (unsigned char action)
             mc_global.tty.console_flag = '\0';
         }
         break;
+    default:
+        break;
     }
 }
 
@@ -256,7 +258,7 @@ handle_console_linux (unsigned char action)
 static void
 console_init (void)
 {
-    if (mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag != '\0')
         return;
 
     screen_info.size = sizeof (screen_info);
@@ -297,7 +299,7 @@ console_restore (void)
 {
     int i, last;
 
-    if (!mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag == '\0')
         return;
 
     cursor_to (0, 0);
@@ -321,7 +323,7 @@ console_restore (void)
 static void
 console_shutdown (void)
 {
-    if (!mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag == '\0')
         return;
 
     g_free (screen_shot.buf);
@@ -338,7 +340,7 @@ console_save (void)
     scrmap_t map;
     scrmap_t revmap;
 
-    if (!mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag == '\0')
         return;
 
     /* screen_info.size is already set in console_init() */
@@ -376,8 +378,8 @@ console_save (void)
     for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
     {
         screen_shot.buf[i] =
-            (screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.
-            scrmap[screen_shot.buf[i] & 0xff];
+            (screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.scrmap[screen_shot.
+                                                                          buf[i] & 0xff];
     }
 }
 
@@ -389,7 +391,7 @@ show_console_contents_freebsd (int starty, unsigned char begin_line, unsigned ch
     int col, line;
     char c;
 
-    if (!mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag == '\0')
         return;
 
     for (line = begin_line; line <= end_line; line++)
@@ -406,7 +408,7 @@ show_console_contents_freebsd (int starty, unsigned char begin_line, unsigned ch
 /* --------------------------------------------------------------------------------------------- */
 
 static void
-handle_console_freebsd (unsigned char action)
+handle_console_freebsd (console_action_t action)
 {
     switch (action)
     {
@@ -425,6 +427,8 @@ handle_console_freebsd (unsigned char action)
     case CONSOLE_RESTORE:
         console_restore ();
         break;
+    default:
+        break;
     }
 }
 #endif /* __FreeBSD__ */
@@ -455,7 +459,7 @@ show_console_contents (int starty, unsigned char begin_line, unsigned char end_l
 /* --------------------------------------------------------------------------------------------- */
 
 void
-handle_console (unsigned char action)
+handle_console (console_action_t action)
 {
     (void) action;
 

+ 3 - 3
src/consaver/cons.saver.h

@@ -16,14 +16,14 @@
 
 /*** enums ***************************************************************************************/
 
-enum
+typedef enum
 {
     CONSOLE_INIT = '1',
     CONSOLE_DONE,
     CONSOLE_SAVE,
     CONSOLE_RESTORE,
     CONSOLE_CONTENTS
-};
+} console_action_t;
 
 /*** structures declarations (and typedefs of structures)*****************************************/
 
@@ -39,7 +39,7 @@ extern int cons_saver_pid;
 #ifndef LINUX_CONS_SAVER_C
 /* Used only in mc, not in cons.saver */
 void show_console_contents (int starty, unsigned char begin_line, unsigned char end_line);
-void handle_console (unsigned char action);
+void handle_console (console_action_t action);
 #endif /* !LINUX_CONS_SAVER_C */
 
 /*** inline functions ****************************************************************************/

+ 13 - 13
src/execute.c

@@ -68,7 +68,7 @@ edition_post_exec (void)
     tty_raw_mode ();
     channels_up ();
     enable_mouse ();
-    if (alternate_plus_minus)
+    if (mc_global.tty.alternate_plus_minus)
         application_keypad_mode ();
 }
 
@@ -81,7 +81,7 @@ edition_pre_exec (void)
         clr_scr ();
     else
     {
-        if (!(mc_global.tty.console_flag || mc_global.tty.xterm_flag))
+        if (!(mc_global.tty.console_flag != '\0' || mc_global.tty.xterm_flag))
             printf ("\n\n");
     }
 
@@ -135,7 +135,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
     if (mc_global.mc_run_mode == MC_RUN_FULL)
         save_cwds_stat ();
     pre_exec ();
-    if (mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag != '\0')
         handle_console (CONSOLE_RESTORE);
 
     if (!mc_global.tty.use_subshell && command && !(flags & EXECUTE_INTERNAL))
@@ -159,7 +159,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
     {
         if ((pause_after_run == pause_always
              || (pause_after_run == pause_on_dumb_terminals && !mc_global.tty.xterm_flag
-                 && !mc_global.tty.console_flag)) && quit == 0
+                 && mc_global.tty.console_flag == '\0')) && quit == 0
 #ifdef HAVE_SUBSHELL_SUPPORT
             && subshell_state != RUNNING_COMMAND
 #endif /* HAVE_SUBSHELL_SUPPORT */
@@ -172,7 +172,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
             printf ("\r\n");
             fflush (stdout);
         }
-        if (mc_global.tty.console_flag)
+        if (mc_global.tty.console_flag != '\0')
         {
             if (output_lines && mc_global.keybar_visible)
             {
@@ -182,7 +182,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
         }
     }
 
-    if (mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag != '\0')
         handle_console (CONSOLE_SAVE);
     edition_post_exec ();
 
@@ -215,7 +215,7 @@ do_suspend_cmd (void)
 {
     pre_exec ();
 
-    if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
+    if (mc_global.tty.console_flag != '\0' && !mc_global.tty.use_subshell)
         handle_console (CONSOLE_RESTORE);
 
 #ifdef SIGTSTP
@@ -234,7 +234,7 @@ do_suspend_cmd (void)
     }
 #endif /* SIGTSTP */
 
-    if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
+    if (mc_global.tty.console_flag != '\0' && !mc_global.tty.use_subshell)
         handle_console (CONSOLE_SAVE);
 
     edition_post_exec ();
@@ -312,7 +312,7 @@ toggle_panels (void)
     disable_mouse ();
     if (clear_before_exec)
         clr_scr ();
-    if (alternate_plus_minus)
+    if (mc_global.tty.alternate_plus_minus)
         numeric_keypad_mode ();
 #ifndef HAVE_SLANG
     /* With slang we don't want any of this, since there
@@ -325,7 +325,7 @@ toggle_panels (void)
     tty_reset_screen ();
     do_exit_ca_mode ();
     tty_raw_mode ();
-    if (mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag != '\0')
         handle_console (CONSOLE_RESTORE);
 
 #ifdef HAVE_SUBSHELL_SUPPORT
@@ -348,7 +348,7 @@ toggle_panels (void)
             get_key_code (0);
     }
 
-    if (mc_global.tty.console_flag)
+    if (mc_global.tty.console_flag != '\0')
         handle_console (CONSOLE_SAVE);
 
     do_enter_ca_mode ();
@@ -374,7 +374,7 @@ toggle_panels (void)
 
     enable_mouse ();
     channels_up ();
-    if (alternate_plus_minus)
+    if (mc_global.tty.alternate_plus_minus)
         application_keypad_mode ();
 
 #ifdef HAVE_SUBSHELL_SUPPORT
@@ -383,7 +383,7 @@ toggle_panels (void)
         load_prompt (0, NULL);
         if (new_dir)
             do_possible_cd (new_dir);
-        if (mc_global.tty.console_flag && output_lines)
+        if (mc_global.tty.console_flag != '\0' && output_lines)
             show_console_contents (output_start_y,
                                    LINES - mc_global.keybar_visible - output_lines -
                                    1, LINES - mc_global.keybar_visible - 1);

+ 2 - 2
src/filemanager/cmd.c

@@ -1268,8 +1268,8 @@ view_other_cmd (void)
 {
     static int message_flag = TRUE;
 
-    if (!mc_global.tty.xterm_flag && !mc_global.tty.console_flag && !mc_global.tty.use_subshell
-        && !output_starts_shell)
+    if (!mc_global.tty.xterm_flag && mc_global.tty.console_flag == '\0'
+        && !mc_global.tty.use_subshell && !output_starts_shell)
     {
         if (message_flag)
             message (D_ERROR, MSG_ERROR,

Some files were not shown because too many files changed in this diff