[BUILD] Fix build warnings
authorAlexey Gladkov <legion@altlinux.org>
Tue, 3 Mar 2009 16:14:07 +0000 (19:14 +0300)
committerAlexey Gladkov <legion@altlinux.org>
Wed, 4 Mar 2009 16:00:46 +0000 (19:00 +0300)
Fix strict gcc warnings that come from using:

-Wall -Wextra -Wmissing-noreturn -Wdisabled-optimization -Wcast-align
-Wshadow -Wmissing-format-attribute -Wmissing-prototypes -Wstrict-prototypes
-Wmissing-declarations

Signed-off-by: Alexey Gladkov <legion@altlinux.org>
41 files changed:
src/Makefile.am
src/analyze.c
src/analyze.l
src/dumpkeys.c
src/fgconsole.c
src/findfile.h
src/getfd.h
src/getkeycodes.c
src/getunimap.c
src/kbd.h [new file with mode: 0644]
src/kbd_mode.c
src/kbdrate.c
src/kdfontop.h
src/kdmapop.h
src/ksyms.c
src/ksyms.h
src/loadkeys.c
src/loadkeys.y
src/loadunimap.c
src/mapscrn.c
src/modifiers.h
src/openvt.c
src/openvt.h
src/outpsfheader.c
src/paths.h
src/psffontop.c
src/psffontop.h
src/resizecons.c
src/screendump.c
src/setfont.c
src/setkeycodes.c
src/setleds.c
src/setmetamode.c
src/showconsolefont.c
src/showkey.c
src/spawn_console.c
src/spawn_login.c
src/utf8.h
src/version.h
src/xmalloc.c
src/xmalloc.h

index 006452f..9d2d074 100644 (file)
@@ -1,4 +1,11 @@
-AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" -DLOCALEDIR=\"$(localedir)\"
+WERROR = -Werror
+
+WARNINGS = -Wall -Wextra -Wmissing-noreturn -Wdisabled-optimization \
+       -Wcast-align -Wshadow -Wmissing-format-attribute -Wmissing-prototypes \
+       -Wstrict-prototypes -Wmissing-declarations $(WERROR)
+
+AM_CPPFLAGS = -DDATADIR=\"$(datadir)\" -DLOCALEDIR=\"$(localedir)\" $(WARNINGS) \
+       -funit-at-a-time
 
 OLDPROGS = mapscrn loadunimap
 PROGS = \
@@ -28,7 +35,7 @@ EXTRA_DIST = \
        README.cad README.init README.openvt \
        cad
 
-ALL_S   = modifiers.h nls.h paths.h version.h
+ALL_S   = modifiers.h nls.h paths.h version.h kbd.h
 FIND_S  = findfile.c findfile.h
 GETFD_S = getfd.c getfd.h
 KDMA_S  = kdmapop.c kdmapop.h
index 8d8c057..18474e7 100644 (file)
@@ -9,7 +9,7 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -31,7 +31,7 @@
 
 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
 
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
 
 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  * if you want the limit (max/min) macros for int types. 
@@ -54,7 +54,6 @@ typedef int flex_int32_t;
 typedef unsigned char flex_uint8_t; 
 typedef unsigned short int flex_uint16_t;
 typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
 
 /* Limits of integral types. */
 #ifndef INT8_MIN
@@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t;
 #define UINT32_MAX             (4294967295U)
 #endif
 
+#endif /* ! C99 */
+
 #endif /* ! FLEXINT_H */
 
 #ifdef __cplusplus
@@ -94,11 +95,12 @@ typedef unsigned int flex_uint32_t;
 
 #else  /* ! __cplusplus */
 
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
 
 #define YY_USE_CONST
 
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
 #endif /* ! __cplusplus */
 
 #ifdef YY_USE_CONST
@@ -140,7 +142,15 @@ typedef unsigned int flex_uint32_t;
 
 /* Size of default input buffer. */
 #ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
 #define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
 #endif
 
 /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -178,14 +188,9 @@ extern FILE *yyin, *yyout;
 
 #define unput(c) yyunput( c, (yytext_ptr)  )
 
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
 #ifndef YY_TYPEDEF_YY_SIZE_T
 #define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
 #endif
 
 #ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -352,7 +357,11 @@ extern char *yytext;
 static yy_state_type yy_get_previous_state (void );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
 static int yy_get_next_buffer (void );
+#ifdef __GNUC__
+static void yy_fatal_error (yyconst char msg[]  ) __attribute__((noreturn));
+#else
 static void yy_fatal_error (yyconst char msg[]  );
+#endif
 
 /* Done after the current pattern has been matched and before the
  * corresponding action - sets up yytext.
@@ -792,7 +801,9 @@ int yy_flex_debug = 0;
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
 #line 1 "analyze.l"
-#line 2 "analyze.l"
+#line 4 "analyze.l"
+#define YY_NO_INPUT 1
+
 #include <stdlib.h>
 #include <linux/kd.h>
 #include "ksyms.h"
@@ -815,7 +826,7 @@ extern void open_include(char *s);
 
 
 
-#line 819 "analyze.c"
+#line 830 "analyze.c"
 
 #define INITIAL 0
 #define RVALUE 1
@@ -836,6 +847,35 @@ extern void open_include(char *s);
 
 static int yy_init_globals (void );
 
+/* Accessor methods to globals.
+   These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag  );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined  );
+
+FILE *yyget_in (void );
+
+void yyset_in  (FILE * in_str  );
+
+FILE *yyget_out (void );
+
+void yyset_out  (FILE * out_str  );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number  );
+
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
  */
@@ -848,8 +888,6 @@ extern int yywrap (void );
 #endif
 #endif
 
-    static void yyunput (int c,char *buf_ptr  );
-    
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char *,yyconst char *,int );
 #endif
@@ -870,7 +908,12 @@ static int input (void );
 
 /* Amount of stuff to slurp up with each read. */
 #ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
 #define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
 #endif
 
 /* Copy whatever the last rule matched to the standard output. */
@@ -878,7 +921,7 @@ static int input (void );
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -968,10 +1011,10 @@ extern int yylex (void);
 YY_DECL
 {
        register yy_state_type yy_current_state;
-       register char *yy_cp, *yy_bp;
+       register char *yy_cp = NULL, *yy_bp = NULL;
        register int yy_act;
     
-#line 60 "analyze.l"
+#line 64 "analyze.l"
 
 
 /* To protect from wrong code in the higher level parser (loadkeys.y), 
@@ -986,7 +1029,7 @@ YY_DECL
  * yylval to YYLVAL_UNDEF. Then it might be overwritten by specific rules. */
   yylval = YYLVAL_UNDEF;
 
-#line 990 "analyze.c"
+#line 1033 "analyze.c"
 
        if ( !(yy_init) )
                {
@@ -1071,12 +1114,12 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 74 "analyze.l"
+#line 78 "analyze.l"
 {BEGIN(INCLSTR);}
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 75 "analyze.l"
+#line 79 "analyze.l"
 { int l; char *s;
                         l = strlen(yytext);
                         s = xmalloc(l);
@@ -1089,7 +1132,7 @@ YY_RULE_SETUP
 case 3:
 /* rule 3 can match eol */
 YY_RULE_SETUP
-#line 83 "analyze.l"
+#line 87 "analyze.l"
 {
                          yyerror("expected filename between quotes");
                          BEGIN(0); }
@@ -1097,18 +1140,18 @@ YY_RULE_SETUP
 case 4:
 /* rule 4 can match eol */
 YY_RULE_SETUP
-#line 86 "analyze.l"
+#line 90 "analyze.l"
 {line_nr++;}
        YY_BREAK
 case 5:
 /* rule 5 can match eol */
 YY_RULE_SETUP
-#line 87 "analyze.l"
+#line 91 "analyze.l"
 {line_nr++;BEGIN(0);return(EOL);}
        YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 88 "analyze.l"
+#line 92 "analyze.l"
 ; /* do nothing */
        YY_BREAK
 case 7:
@@ -1117,219 +1160,219 @@ case 7:
 (yy_c_buf_p) = yy_cp -= 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 89 "analyze.l"
+#line 93 "analyze.l"
 ; /* do nothing */
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 90 "analyze.l"
+#line 94 "analyze.l"
 {BEGIN(RVALUE);rvalct=0;return(EQUALS);}
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 91 "analyze.l"
+#line 95 "analyze.l"
 {return(DASH);}
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 92 "analyze.l"
+#line 96 "analyze.l"
 {return(COMMA);}
        YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 93 "analyze.l"
+#line 97 "analyze.l"
 {return(PLUS);}
        YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 94 "analyze.l"
+#line 98 "analyze.l"
 {yylval=strtol(yytext+1,NULL,16);if(yylval>=0xf000)lkfatal1("unicode keysym out of range: %s",yytext);return(UNUMBER);}
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 95 "analyze.l"
+#line 99 "analyze.l"
 {yylval=strtol(yytext,NULL,0);return(NUMBER);}
        YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 96 "analyze.l"
+#line 100 "analyze.l"
 {return((yylval=ksymtocode(yytext))==-1?ERROR:LITERAL);}
        YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 97 "analyze.l"
+#line 101 "analyze.l"
 {return(CHARSET);}
        YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 98 "analyze.l"
+#line 102 "analyze.l"
 {return(KEYMAPS);}
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 99 "analyze.l"
+#line 103 "analyze.l"
 {return(KEYCODE);}
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 100 "analyze.l"
+#line 104 "analyze.l"
 {BEGIN(RVALUE);return(STRING);}
        YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 101 "analyze.l"
+#line 105 "analyze.l"
 {return(PLAIN);}
        YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 102 "analyze.l"
+#line 106 "analyze.l"
 {return(SHIFT);}
        YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 103 "analyze.l"
+#line 107 "analyze.l"
 {return(CONTROL);}
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 104 "analyze.l"
+#line 108 "analyze.l"
 {return(ALT);}
        YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 105 "analyze.l"
+#line 109 "analyze.l"
 {return(ALTGR);}
        YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 106 "analyze.l"
+#line 110 "analyze.l"
 {return(SHIFTL);}
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 107 "analyze.l"
+#line 111 "analyze.l"
 {return(SHIFTR);}
        YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 108 "analyze.l"
+#line 112 "analyze.l"
 {return(CTRLL);}
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 109 "analyze.l"
+#line 113 "analyze.l"
 {return(CTRLR);}
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 110 "analyze.l"
+#line 114 "analyze.l"
 {return(CAPSSHIFT);}
        YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 111 "analyze.l"
+#line 115 "analyze.l"
 {return(ALT_IS_META);}
        YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 112 "analyze.l"
+#line 116 "analyze.l"
 {return(STRINGS);}
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 113 "analyze.l"
+#line 117 "analyze.l"
 {return(COMPOSE);}
        YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 114 "analyze.l"
+#line 118 "analyze.l"
 {return(AS);}
        YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 115 "analyze.l"
+#line 119 "analyze.l"
 {return(USUAL);}
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 116 "analyze.l"
+#line 120 "analyze.l"
 {BEGIN(RVALUE); return(TO);}
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 117 "analyze.l"
+#line 121 "analyze.l"
 {return(ON);}
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 118 "analyze.l"
+#line 122 "analyze.l"
 {return(FOR);}
        YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 119 "analyze.l"
+#line 123 "analyze.l"
 {yylval = strtol(yytext+2,NULL,8); return(CCHAR);}
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 120 "analyze.l"
+#line 124 "analyze.l"
 {yylval = yytext[2]; return(CCHAR);}
        YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 121 "analyze.l"
+#line 125 "analyze.l"
 {yylval = yytext[1]; return(CCHAR);}
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 122 "analyze.l"
+#line 126 "analyze.l"
 {p=(char *) kbs_buf.kb_string;
                                pmax=p+sizeof(kbs_buf.kb_string)-1;
                                BEGIN(STR);}
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 125 "analyze.l"
+#line 129 "analyze.l"
 {if(p>=pmax)stringovfl();*p++=strtol(yytext+1,NULL,8);}
        YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 126 "analyze.l"
+#line 130 "analyze.l"
 {if(p>=pmax)stringovfl();*p++='"';}
        YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 127 "analyze.l"
+#line 131 "analyze.l"
 {if(p>=pmax)stringovfl();*p++='\\';}
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 128 "analyze.l"
+#line 132 "analyze.l"
 {if(p>=pmax)stringovfl();*p++='\n';}
        YY_BREAK
 case 45:
 /* rule 45 can match eol */
 YY_RULE_SETUP
-#line 129 "analyze.l"
+#line 133 "analyze.l"
 {char *ptmp=p;p+=strlen(yytext);
                                if(p>pmax)stringovfl();strcpy(ptmp,yytext);}
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 131 "analyze.l"
+#line 135 "analyze.l"
 {*p='\0';BEGIN(0);return(STRLITERAL);}
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 132 "analyze.l"
+#line 136 "analyze.l"
 {return(ERROR); /* report any unknown characters */}
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 133 "analyze.l"
+#line 137 "analyze.l"
 ECHO;
        YY_BREAK
-#line 1333 "analyze.c"
+#line 1376 "analyze.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(RVALUE):
 case YY_STATE_EOF(STR):
@@ -1587,6 +1630,14 @@ static int yy_get_next_buffer (void)
        else
                ret_val = EOB_ACT_CONTINUE_SCAN;
 
+       if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+               /* Extend the array by 50%, plus the number we really need. */
+               yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+               YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
+               if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+                       YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+       }
+
        (yy_n_chars) += number_to_move;
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
@@ -1653,43 +1704,6 @@ static int yy_get_next_buffer (void)
        return yy_is_jam ? 0 : yy_current_state;
 }
 
-    static void yyunput (int c, register char * yy_bp )
-{
-       register char *yy_cp;
-    
-    yy_cp = (yy_c_buf_p);
-
-       /* undo effects of setting up yytext */
-       *yy_cp = (yy_hold_char);
-
-       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
-               { /* need to shift things up to make room */
-               /* +2 for EOB chars. */
-               register int number_to_move = (yy_n_chars) + 2;
-               register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
-                                       YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
-               register char *source =
-                               &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
-               while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
-                       *--dest = *--source;
-
-               yy_cp += (int) (dest - source);
-               yy_bp += (int) (dest - source);
-               YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
-                       (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
-               if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
-                       YY_FATAL_ERROR( "flex scanner push-back overflow" );
-               }
-
-       *--yy_cp = (char) c;
-
-       (yytext_ptr) = yy_bp;
-       (yy_hold_char) = *yy_cp;
-       (yy_c_buf_p) = yy_cp;
-}
-
 #ifndef YY_NO_INPUT
 #ifdef __cplusplus
     static int yyinput (void)
@@ -2002,7 +2016,9 @@ static void yyensure_buffer_stack (void)
                (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
                                                                (num_to_alloc * sizeof(struct yy_buffer_state*)
                                                                );
-               
+               if ( ! (yy_buffer_stack) )
+                       YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+                                                                 
                memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
                                
                (yy_buffer_stack_max) = num_to_alloc;
@@ -2020,6 +2036,8 @@ static void yyensure_buffer_stack (void)
                                                                ((yy_buffer_stack),
                                                                num_to_alloc * sizeof(struct yy_buffer_state*)
                                                                );
+               if ( ! (yy_buffer_stack) )
+                       YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
                /* zero only the new slots.*/
                memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2078,8 +2096,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
 
 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  * 
  * @return the newly allocated buffer state object.
  */
@@ -2318,13 +2336,13 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 133 "analyze.l"
+#line 137 "analyze.l"
 
 
 #include "ksyms.h"
 #include <linux/keyboard.h>
 
-void
+void attr_noreturn
 stringovfl(void) {
        lkfatal("string too long");
 }
index 41104cc..9a02600 100644 (file)
@@ -1,7 +1,12 @@
+%option outfile="analyze.c"
+%option nounput
 %{
+#define YY_NO_INPUT 1
+
 #include <stdlib.h>
 #include <linux/kd.h>
 #include "ksyms.h"
+#include "kbd.h"
 #include "xmalloc.h"
 
 extern int line_nr;
@@ -134,7 +139,7 @@ To                      to|To|TO
 #include "ksyms.h"
 #include <linux/keyboard.h>
 
-void
+void attr_noreturn
 stringovfl(void) {
        lkfatal("string too long");
 }
index 73f913a..879c96f 100644 (file)
@@ -107,16 +107,16 @@ print_keymaps(void) {
 }
 
 static int
-get_bind(u_char index, u_char table) {
+get_bind(u_char kb_index, u_char kb_table) {
        struct kbentry ke;
 
-       ke.kb_index = index;
-       ke.kb_table = table;
+       ke.kb_index = kb_index;
+       ke.kb_table = kb_table;
        if (ioctl(fd, KDGKBENT, (unsigned long)&ke)) {
-               if (index < 128) {
+               if (kb_index < 128) {
                        perror("KDGKBENT");
                        fprintf(stderr, _("KDGKBENT error at index %d in table %d\n"),
-                               index, table);
+                               kb_index, kb_table);
                        exit(1);
                } else
                        return -1;
@@ -126,7 +126,7 @@ get_bind(u_char index, u_char table) {
 
 static void
 print_keysym(int code, char numeric) {
-       int t;
+       unsigned int t;
        int v;
        const char *p;
        int plus;
@@ -229,7 +229,7 @@ nr_of_diacs(void) {
 
 static void
 dump_diacs(void) {
-       int i;
+       unsigned int i;
 
        get_diacs();
        for (i = 0; i < kd.kb_cnt; i++) {
@@ -288,7 +288,7 @@ static struct {
 
 static void
 dump_symbols(void) {
-       int t;
+       unsigned int t;
        int v;
        const char *p;
 
@@ -316,7 +316,7 @@ dump_symbols(void) {
 
 static void
 print_mod(int x) {
-       int t;
+       unsigned int t;
 
        if (!x)
                printf("plain\t");
@@ -443,12 +443,12 @@ no_shorthands:
                    zapped[j] = 0;
            if (alt_is_meta) {
                 for(j = 0; j < keymapnr; j++) {
-                     int ka, ja, typ;
+                     int ka, ja, ktyp;
                      k = good_keymap[j];
                      ka = (k | M_ALT);
                      ja = keymap_index[ka];
                      if (k != ka && ja >= 0
-                      && ((typ=KTYP(buf[j])) == KT_LATIN || typ == KT_LETTER)
+                      && ((ktyp=KTYP(buf[j])) == KT_LATIN || ktyp == KT_LETTER)
                       && KVAL(buf[j]) < 128) {
                           if (buf[ja] != K(KT_META, KVAL(buf[j])))
                                fprintf(stderr, _("impossible: not meta?\n"));
@@ -526,7 +526,7 @@ dump_funcs(void) {
        }
 }
 
-static void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, _("dumpkeys version %s"), PACKAGE_VERSION);
        fprintf(stderr, _("\
index 23a6c24..268bfda 100644 (file)
@@ -11,7 +11,8 @@
 #include "nls.h"
 #include "version.h"
 
-static void usage(void)
+static void attr_noreturn
+usage(void)
 {
        fprintf(stderr, _("%s version %s\n"
 "\n"
index bc6de6a..77c0acc 100644 (file)
@@ -1,2 +1,7 @@
+#ifndef _FINDFILE_H
+#define _FINDFILE_H
+
 extern void fpclose(FILE *fp);
 extern FILE *findfile(char *fnam, char **dirpath, char **suffixes);
+
+#endif /* _FINDFILE_H */
index 991f33d..56f1ffb 100644 (file)
@@ -1 +1,6 @@
+#ifndef _GETFD_H
+#define _GETFD_H
+
 extern int getfd(const char *fnam);
+
+#endif /* _GETFD_H */
index e2d7962..9bee144 100644 (file)
@@ -13,7 +13,7 @@
 #include "nls.h"
 #include "version.h"
 
-static void
+static void attr_noreturn
 usage(void) {
     fprintf(stderr, _("usage: getkeycodes\n"));
     exit(1);
@@ -21,7 +21,8 @@ usage(void) {
 
 int
 main(int argc, char **argv) {
-       int fd, sc, sc0;
+       int fd;
+       unsigned int sc, sc0;
        struct kbkeycode a;
        int old_kernel = 0;
 
index 810e512..e36326d 100644 (file)
@@ -24,7 +24,7 @@ ud_compar(const void *u1, const void *u2){
        return (int) fp1 - (int) fp2;
 }
 
-static void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, _("Usage:\n\t%s [-s] [-C console]\n"), progname);
        exit(1);
diff --git a/src/kbd.h b/src/kbd.h
new file mode 100644 (file)
index 0000000..7b12a7f
--- /dev/null
+++ b/src/kbd.h
@@ -0,0 +1,7 @@
+#ifndef _KBD_H
+#define _KBD_H
+
+#define attr_noreturn __attribute__ ((noreturn))
+#define attr_unused __attribute__ ((unused))
+
+#endif /* _KBD_H */
index 3b03a0e..bc51e06 100644 (file)
@@ -14,7 +14,7 @@
 #include "nls.h"
 #include "version.h"
 
-static void
+static void attr_noreturn
 usage(void){
     fprintf(stderr, _("usage: kbd_mode [-a|-u|-k|-s] [-C device]\n"));
     exit(1);
index e4b4f20..95ff723 100644 (file)
@@ -178,8 +178,14 @@ KDKBDREP_ioctl_ok(double rate, int delay, int silent) {
        return 1;                       /* success! */
 }
 
+#ifndef KIOCSRATE
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
 static int
-KIOCSRATE_ioctl_ok(double rate, int delay, int silent) {
+KIOCSRATE_ioctl_ok(arg_state double rate, arg_state int delay, arg_state int silent) {
 #ifdef KIOCSRATE
        struct kbd_rate kbdrate_s;
        int fd;
@@ -212,7 +218,7 @@ KIOCSRATE_ioctl_ok(double rate, int delay, int silent) {
 }
 
 static void
-sigalrmhandler( int sig ) {
+sigalrmhandler( attr_unused int sig ) {
        fprintf( stderr, "kbdrate: Failed waiting for kbd controller!\n" );
        raise( SIGINT );
 }
@@ -232,7 +238,7 @@ main( int argc, char **argv ) {
        int         fd;
        char        data;
        int         c;
-       int         i;
+       unsigned int i;
        extern char *optarg;
 
        set_progname(argv[0]);
index 9918bc8..ac9dbbc 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef _KDFONTOP_H
+#define _KDFONTOP_H
 /*
  * Read kernel font into BUF with room for COUNT 32x32 glyphs.
  * Return 0 on success -1 on failure.
@@ -27,3 +29,5 @@ extern int getfontsize(int fd);
  * Restore font (doesn't work).
  */
 extern int restorefont(int fd);
+
+#endif /* _KDFONTOP_H */
index 6fcccfa..81cccbf 100644 (file)
@@ -1,6 +1,11 @@
+#ifndef _KDMAPOP_H
+#define _KDMAPOP_H
+
 extern int getscrnmap(int fd, char *map);
 extern int loadscrnmap(int fd, char *map);
 extern int getuniscrnmap(int fd, unsigned short *map);
 extern int loaduniscrnmap(int fd, unsigned short *map);
 extern int getunimap(int fd, struct unimapdesc *ud);
 extern int loadunimap(int fd, struct unimapinit *ui, struct unimapdesc *ud);
+
+#endif /* _KDMAPOP_H */
index 35fed29..e8a494a 100644 (file)
@@ -1613,8 +1613,8 @@ synonyms[] = {
        { "rightanglequote",    "guillemotright" }
 };
 
-const int syms_size = sizeof(syms) / sizeof(syms_entry);
-const int syn_size = sizeof(synonyms) / sizeof(synonyms[0]);
+const unsigned int syms_size = sizeof(syms) / sizeof(syms_entry);
+const unsigned int syn_size = sizeof(synonyms) / sizeof(synonyms[0]);
 
 struct cs {
     const char *charset;
@@ -1649,7 +1649,8 @@ static const char *chosen_charset = NULL;
 
 void
 list_charsets(FILE *f) {
-       int i,j,lth,ct;
+       int lth,ct;
+       unsigned int i, j;
        char *mm[] = { "iso-8859-", "koi8-" };
 
        for (j=0; j<sizeof(mm)/sizeof(mm[0]); j++) {
@@ -1682,7 +1683,7 @@ list_charsets(FILE *f) {
 int
 set_charset(const char *charset) {
        sym *p;
-       int i;
+       unsigned int i;
 
        if (!strcasecmp(charset, "unicode")) {
                prefer_unicode = 1;
@@ -1710,7 +1711,8 @@ set_charset(const char *charset) {
 
 const char *
 unicodetoksym(int code) {
-       int i, j;
+       unsigned int i;
+       int j;
        sym *p;
 
        if (code < 0)
@@ -1733,7 +1735,7 @@ int unicode_used = 0;
 
 int
 ksymtocode(const char *s) {
-       int i;
+       unsigned int i;
        int j, jmax;
        int keycode;
        sym *p;
@@ -1839,7 +1841,7 @@ add_capslock(int code)
 
        if (KTYP(code) == KT_LATIN)
                return K(KT_LETTER, KVAL(code));
-       if (KTYP(code) >= syms_size) {
+       if ((unsigned) KTYP(code) >= syms_size) {
                if ((p = unicodetoksym(code ^ 0xf000)) == NULL) {
                        sprintf(buf, "U+%04x", code ^ 0xf000);
                        p = buf;
index 2e35ef4..74cff92 100644 (file)
@@ -19,8 +19,8 @@ struct syn {
 };
 extern struct syn synonyms[];
 
-extern const int syms_size;
-extern const int syn_size;
+extern const unsigned int syms_size;
+extern const unsigned int syn_size;
 
 /* Returned by ksymtocode to report an unknown symbol */
 #define CODE_FOR_UNKNOWN_KSYM (-1)
index 7b4e7ae..76cb5e0 100644 (file)
@@ -216,6 +216,14 @@ extern struct kbsentry kbs_buf;
 int yyerror(const char *s);
 extern void lkfatal(const char *s);
 extern void lkfatal1(const char *s, const char *s2);
+void lk_push(void);
+int lk_pop(void);
+void lk_scan_string(char *s);
+void lk_end_string(void);
+
+FILE *find_incl_file_near_fn(char *s, char *fn);
+FILE *find_standard_incl_file(char *s);
+FILE *find_incl_file(char *s);
 
 #include "ksyms.h"
 int yylex (void);
@@ -252,7 +260,7 @@ typedef int YYSTYPE;
 
 
 /* Line 216 of yacc.c.  */
-#line 256 "loadkeys.c"
+#line 264 "loadkeys.c"
 
 #ifdef short
 # undef short
@@ -555,11 +563,11 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint8 yyrline[] =
 {
-       0,    93,    93,    94,    96,    97,    98,    99,   100,   101,
-     102,   103,   104,   105,   107,   112,   117,   122,   126,   131,
-     136,   137,   139,   145,   150,   159,   163,   168,   168,   173,
-     178,   179,   181,   182,   183,   184,   185,   186,   187,   188,
-     189,   191,   224,   225,   227,   234,   236,   238,   240,   242
+       0,   101,   101,   102,   104,   105,   106,   107,   108,   109,
+     110,   111,   112,   113,   115,   120,   125,   130,   134,   139,
+     144,   145,   147,   153,   158,   167,   171,   176,   176,   181,
+     186,   187,   189,   190,   191,   192,   193,   194,   195,   196,
+     197,   199,   232,   233,   235,   242,   244,   246,   248,   250
 };
 #endif
 
@@ -1516,49 +1524,49 @@ yyreduce:
   switch (yyn)
     {
         case 14:
-#line 108 "loadkeys.y"
+#line 116 "loadkeys.y"
     {
                            set_charset((char *) kbs_buf.kb_string);
                        }
     break;
 
   case 15:
-#line 113 "loadkeys.y"
+#line 121 "loadkeys.y"
     {
                            alt_is_meta = 1;
                        }
     break;
 
   case 16:
-#line 118 "loadkeys.y"
+#line 126 "loadkeys.y"
     {
                            strings_as_usual();
                        }
     break;
 
   case 17:
-#line 123 "loadkeys.y"
+#line 131 "loadkeys.y"
     {
                            compose_as_usual((char *) kbs_buf.kb_string);
                        }
     break;
 
   case 18:
-#line 127 "loadkeys.y"
+#line 135 "loadkeys.y"
     {
                            compose_as_usual(0);
                        }
     break;
 
   case 19:
-#line 132 "loadkeys.y"
+#line 140 "loadkeys.y"
     {
                            keymaps_line_seen = 1;
                        }
     break;
 
   case 22:
-#line 140 "loadkeys.y"
+#line 148 "loadkeys.y"
     {
                            int i;
                            for (i = (yyvsp[(1) - (3)]); i<= (yyvsp[(3) - (3)]); i++)
@@ -1567,14 +1575,14 @@ yyreduce:
     break;
 
   case 23:
-#line 146 "loadkeys.y"
+#line 154 "loadkeys.y"
     {
                            addmap((yyvsp[(1) - (1)]),1);
                        }
     break;
 
   case 24:
-#line 151 "loadkeys.y"
+#line 159 "loadkeys.y"
     {
                            if (KTYP((yyvsp[(2) - (5)])) != KT_FN)
                                lkfatal1(_("'%s' is not a function key symbol"),
@@ -1585,85 +1593,85 @@ yyreduce:
     break;
 
   case 25:
-#line 160 "loadkeys.y"
+#line 168 "loadkeys.y"
     {
                            compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
                        }
     break;
 
   case 26:
-#line 164 "loadkeys.y"
+#line 172 "loadkeys.y"
     {
                            compose((yyvsp[(2) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]));
                        }
     break;
 
   case 27:
-#line 168 "loadkeys.y"
+#line 176 "loadkeys.y"
     { mod = 0; }
     break;
 
   case 28:
-#line 170 "loadkeys.y"
+#line 178 "loadkeys.y"
     {
                            addkey((yyvsp[(4) - (7)]), mod, (yyvsp[(6) - (7)]));
                        }
     break;
 
   case 29:
-#line 174 "loadkeys.y"
+#line 182 "loadkeys.y"
     {
                            addkey((yyvsp[(3) - (6)]), 0, (yyvsp[(5) - (6)]));
                        }
     break;
 
   case 32:
-#line 181 "loadkeys.y"
+#line 189 "loadkeys.y"
     { mod |= M_SHIFT;  }
     break;
 
   case 33:
-#line 182 "loadkeys.y"
+#line 190 "loadkeys.y"
     { mod |= M_CTRL;   }
     break;
 
   case 34:
-#line 183 "loadkeys.y"
+#line 191 "loadkeys.y"
     { mod |= M_ALT;            }
     break;
 
   case 35:
-#line 184 "loadkeys.y"
+#line 192 "loadkeys.y"
     { mod |= M_ALTGR;  }
     break;
 
   case 36:
-#line 185 "loadkeys.y"
+#line 193 "loadkeys.y"
     { mod |= M_SHIFTL; }
     break;
 
   case 37:
-#line 186 "loadkeys.y"
+#line 194 "loadkeys.y"
     { mod |= M_SHIFTR; }
     break;
 
   case 38:
-#line 187 "loadkeys.y"
+#line 195 "loadkeys.y"
     { mod |= M_CTRLL;  }
     break;
 
   case 39:
-#line 188 "loadkeys.y"
+#line 196 "loadkeys.y"
     { mod |= M_CTRLR;  }
     break;
 
   case 40:
-#line 189 "loadkeys.y"
+#line 197 "loadkeys.y"
     { mod |= M_CAPSSHIFT;      }
     break;
 
   case 41:
-#line 192 "loadkeys.y"
+#line 200 "loadkeys.y"
     {
            int i, j;
 
@@ -1697,7 +1705,7 @@ yyreduce:
     break;
 
   case 44:
-#line 228 "loadkeys.y"
+#line 236 "loadkeys.y"
     {
                            if (rvalct >= MAX_NR_KEYMAPS)
                                lkfatal(_("too many key definitions on one line"));
@@ -1706,33 +1714,33 @@ yyreduce:
     break;
 
   case 45:
-#line 235 "loadkeys.y"
+#line 243 "loadkeys.y"
     {(yyval)=(yyvsp[(1) - (1)]);}
     break;
 
   case 46:
-#line 237 "loadkeys.y"
+#line 245 "loadkeys.y"
     {(yyval)=((yyvsp[(1) - (1)]) ^ 0xf000); unicode_used=1;}
     break;
 
   case 47:
-#line 239 "loadkeys.y"
+#line 247 "loadkeys.y"
     {(yyval)=add_capslock((yyvsp[(2) - (2)]));}
     break;
 
   case 48:
-#line 241 "loadkeys.y"
+#line 249 "loadkeys.y"
     {(yyval)=(yyvsp[(1) - (1)]);}
     break;
 
   case 49:
-#line 243 "loadkeys.y"
+#line 251 "loadkeys.y"
     {(yyval)=add_capslock((yyvsp[(2) - (2)]));}
     break;
 
 
 /* Line 1267 of yacc.c.  */
-#line 1736 "loadkeys.c"
+#line 1744 "loadkeys.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1946,12 +1954,12 @@ yyreturn:
 }
 
 
-#line 245 "loadkeys.y"
+#line 253 "loadkeys.y"
                        
 
 #include "analyze.c"
 
-void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, _("loadkeys version %s\n"
 "\n"
@@ -2069,11 +2077,11 @@ main(int argc, char *argv[]) {
                while (      *s == ' ' || *s == '\t' || *s == ',') s++;
                e = s;
                while (*e && *e != ' ' && *e != '\t' && *e != ',') e++;
-               char c = *e;
+               char ch = *e;
                *e = '\0';
                if (verbose) printf("%s\n", s);
                loadkeys(s, &warned);
-               *e = c;
+               *e = ch;
                s = e;
              }
            free(buf);
@@ -2095,13 +2103,13 @@ yyerror(const char *s) {
 }
 
 /* fatal errors - change to varargs next time */
-void
+void attr_noreturn
 lkfatal(const char *s) {
        fprintf(stderr, "%s: %s:%d: %s\n", progname, filename, line_nr, s);
        exit(1);
 }
 
-void
+void attr_noreturn
 lkfatal0(const char *s, int d) {
        fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
        fprintf(stderr, s, d);
@@ -2109,7 +2117,7 @@ lkfatal0(const char *s, int d) {
        exit(1);
 }
 
-void
+void attr_noreturn
 lkfatal1(const char *s, const char *s2) {
        fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
        fprintf(stderr, s, s2);
@@ -2220,8 +2228,8 @@ FILE *find_standard_incl_file(char *s) {
 
        /* If filename is a symlink, also look near its target. */
        if (!f) {
-               char buf[1024], path[1024], *p;
-               int n;
+               char buf[1024], path[1024], *ptr;
+               unsigned int n;
 
                n = readlink(filename, buf, sizeof(buf));
                if (n > 0 && n < sizeof(buf)) {
@@ -2231,9 +2239,9 @@ FILE *find_standard_incl_file(char *s) {
                     else if (strlen(filename) + n < sizeof(path)) {
                          strcpy(path, filename);
                          path[sizeof(path)-1] = 0;
-                         p = rindex(path, '/');
-                         if (p)
-                              p[1] = 0;
+                         ptr = rindex(path, '/');
+                         if (ptr)
+                              ptr[1] = 0;
                          strcat(path, buf);
                          f = find_incl_file_near_fn(s, path);
                     }
@@ -2387,67 +2395,67 @@ addmap(int i, int explicit) {
 
 /* unset a key */
 static void
-killkey(int index, int table) {
-       /* roughly: addkey(index, table, K_HOLE); */
-
-        if (index < 0 || index >= NR_KEYS)
-               lkfatal0(_("killkey called with bad index %d"), index);
-        if (table < 0 || table >= MAX_NR_KEYMAPS)
-               lkfatal0(_("killkey called with bad table %d"), table);
-       if (key_map[table])
-               (key_map[table])[index] = K_HOLE;
-       if (keymap_was_set[table])
-               (keymap_was_set[table])[index] = 0;
+killkey(int k_index, int k_table) {
+       /* roughly: addkey(k_index, k_table, K_HOLE); */
+
+        if (k_index < 0 || k_index >= NR_KEYS)
+               lkfatal0(_("killkey called with bad index %d"), k_index);
+        if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+               lkfatal0(_("killkey called with bad table %d"), k_table);
+       if (key_map[k_table])
+               (key_map[k_table])[k_index] = K_HOLE;
+       if (keymap_was_set[k_table])
+               (keymap_was_set[k_table])[k_index] = 0;
 }
 
 static void
-addkey(int index, int table, int keycode) {
+addkey(int k_index, int k_table, int keycode) {
        int i;
 
        if (keycode == CODE_FOR_UNKNOWN_KSYM)
          /* is safer not to be silent in this case, 
           * it can be caused by coding errors as well. */
                lkfatal0(_("addkey called with bad keycode %d"), keycode);
-        if (index < 0 || index >= NR_KEYS)
-               lkfatal0(_("addkey called with bad index %d"), index);
-        if (table < 0 || table >= MAX_NR_KEYMAPS)
-               lkfatal0(_("addkey called with bad table %d"), table);
-
-       if (!defining[table])
-               addmap(table, 0);
-       if (!key_map[table]) {
-               key_map[table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
+        if (k_index < 0 || k_index >= NR_KEYS)
+               lkfatal0(_("addkey called with bad index %d"), k_index);
+        if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+               lkfatal0(_("addkey called with bad table %d"), k_table);
+
+       if (!defining[k_table])
+               addmap(k_table, 0);
+       if (!key_map[k_table]) {
+               key_map[k_table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
                for (i = 0; i < NR_KEYS; i++)
-                 (key_map[table])[i] = K_HOLE;
+                 (key_map[k_table])[i] = K_HOLE;
        }
-       if (!keymap_was_set[table]) {
-               keymap_was_set[table] = (char *) xmalloc(NR_KEYS);
+       if (!keymap_was_set[k_table]) {
+               keymap_was_set[k_table] = (char *) xmalloc(NR_KEYS);
                for (i = 0; i < NR_KEYS; i++)
-                 (keymap_was_set[table])[i] = 0;
+                 (keymap_was_set[k_table])[i] = 0;
        }
 
-       if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[table])[index])
+       if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[k_table])[k_index])
                return;
 
-       (key_map[table])[index] = keycode;
-       (keymap_was_set[table])[index] = 1;
+       (key_map[k_table])[k_index] = keycode;
+       (keymap_was_set[k_table])[k_index] = 1;
 
        if (alt_is_meta) {
-            int alttable = table | M_ALT;
+            int alttable = k_table | M_ALT;
             int type = KTYP(keycode);
             int val = KVAL(keycode);
-            if (alttable != table && defining[alttable] &&
+            if (alttable != k_table && defining[alttable] &&
                 (!keymap_was_set[alttable] ||
-                 !(keymap_was_set[alttable])[index]) &&
+                 !(keymap_was_set[alttable])[k_index]) &&
                 (type == KT_LATIN || type == KT_LETTER) && val < 128)
-                 addkey(index, alttable, K(KT_META, val));
+                 addkey(k_index, alttable, K(KT_META, val));
        }
 }
 
 static void
 addfunc(struct kbsentry kbs) {
        int sh, i, x;
-       char *p, *q, *r;
+       char *ptr, *q, *r;
 
        x = kbs.kb_func;
 
@@ -2460,9 +2468,9 @@ addfunc(struct kbsentry kbs) {
        q = func_table[x];
        if (q) {                        /* throw out old previous def */
                sh = strlen(q) + 1;
-               p = q + sh;
-               while (p < fp)
-                       *q++ = *p++;
+               ptr = q + sh;
+               while (ptr < fp)
+                       *q++ = *ptr++;
                fp -= sh;
 
                for (i = x + 1; i < MAX_NR_FUNC; i++)
@@ -2470,13 +2478,13 @@ addfunc(struct kbsentry kbs) {
                          func_table[i] -= sh;
        }
 
-       p = func_buf;                        /* find place for new def */
+       ptr = func_buf;                        /* find place for new def */
        for (i = 0; i < x; i++)
                if (func_table[i]) {
-                       p = func_table[i];
-                       while(*p++);
+                       ptr = func_table[i];
+                       while(*ptr++);
                }
-       func_table[x] = p;
+       func_table[x] = ptr;
         sh = strlen((char *) kbs.kb_string) + 1;
        if (fp + sh > func_buf + sizeof(func_buf)) {
                fprintf(stderr,
@@ -2486,9 +2494,9 @@ addfunc(struct kbsentry kbs) {
        q = fp;
        fp += sh;
        r = fp;
-       while (q > p)
+       while (q > ptr)
                *--r = *--q;
-       strcpy(p, (char *) kbs.kb_string);
+       strcpy(ptr, (char *) kbs.kb_string);
        for (i = x + 1; i < MAX_NR_FUNC; i++)
                if (func_table[i])
                        func_table[i] += sh;
@@ -2496,15 +2504,15 @@ addfunc(struct kbsentry kbs) {
 
 static void
 compose(int diacr, int base, int res) {
-        struct kbdiacr *p;
+        struct kbdiacr *ptr;
         if (accent_table_size == MAX_DIACR) {
                fprintf(stderr, _("compose table overflow\n"));
                exit(1);
        }
-       p = &accent_table[accent_table_size++];
-       p->diacr = diacr;
-       p->base = base;
-       p->result = res;
+       ptr = &accent_table[accent_table_size++];
+       ptr->diacr = diacr;
+       ptr->base = base;
+       ptr->result = res;
 }
 
 static int
@@ -2642,15 +2650,15 @@ ostr(char *s) {
 static int
 deffuncs(int fd){
         int i, ct = 0;
-       char *p;
+       char *ptr;
 
         for (i = 0; i < MAX_NR_FUNC; i++) {
            kbs_buf.kb_func = i;
-           if ((p = func_table[i])) {
-               strcpy((char *) kbs_buf.kb_string, p);
+           if ((ptr = func_table[i])) {
+               strcpy((char *) kbs_buf.kb_string, ptr);
                if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
                  fprintf(stderr, _("failed to bind string '%s' to function %s\n"),
-                         ostr(kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
+                         ostr((char *) kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
                else
                  ct++;
            } else if (opts) {
@@ -2668,7 +2676,7 @@ deffuncs(int fd){
 static int
 defdiacs(int fd){
         struct kbdiacrs kd;
-       int i;
+       unsigned int i;
 
        kd.kb_cnt = accent_table_size;
        if (kd.kb_cnt > MAX_DIACR) {
@@ -2838,8 +2846,8 @@ compose_as_usual(char *charset) {
                };
                int i;
                for(i=0; i<68; i++) {
-                       struct ccc p = def_latin1_composes[i];
-                       compose(p.c1, p.c2, p.c3);
+                       struct ccc ptr = def_latin1_composes[i];
+                       compose(ptr.c1, ptr.c2, ptr.c3);
                }
        }
 }
@@ -2852,15 +2860,15 @@ static char *modifiers[8] = {
     "shift", "altgr", "ctrl", "alt", "shl", "shr", "ctl", "ctr"
 };
 
-static char *mk_mapname(char mod) {
+static char *mk_mapname(char modifier) {
     static char buf[60];
     int i;
 
-    if (!mod)
+    if (!modifier)
       return "plain";
     buf[0] = 0;
     for (i=0; i<8; i++)
-      if (mod & (1<<i)) {
+      if (modifier & (1<<i)) {
          if (buf[0])
            strcat(buf, "_");
          strcat(buf, modifiers[i]);
@@ -2877,12 +2885,13 @@ outchar (unsigned char c, int comma) {
        printf(comma ? "', " : "'");
 }
 
-static void
+static void attr_noreturn
 mktable () {
-       int i, imax, j;
+       int j;
+       unsigned int i, imax;
 
-       u_char *p;
-       int maxfunc;
+       char *ptr;
+       unsigned int maxfunc;
        unsigned int keymap_count = 0;
 
        printf(
@@ -2937,11 +2946,11 @@ mktable () {
 
        printf("char func_buf[] = {\n");
        for (i = 0; i < maxfunc; i++) {
-           p = func_table[i];
-           if (p) {
+           ptr = func_table[i];
+           if (ptr) {
                printf("\t");
-               for ( ; *p; p++)
-                       outchar(*p, 1);
+               for ( ; *ptr; ptr++)
+                       outchar(*ptr, 1);
                printf("0, \n");
            }
        }
@@ -2983,11 +2992,11 @@ mktable () {
        exit(0);
 }
 
-static void
+static void attr_noreturn
 bkeymap () {
        int i, j;
 
-       u_char *p;
+       //u_char *p;
        char flag, magic[] = "bkeymap";
        unsigned short v;
 
index 6502166..d90ce33 100644 (file)
@@ -84,6 +84,14 @@ extern struct kbsentry kbs_buf;
 int yyerror(const char *s);
 extern void lkfatal(const char *s);
 extern void lkfatal1(const char *s, const char *s2);
+void lk_push(void);
+int lk_pop(void);
+void lk_scan_string(char *s);
+void lk_end_string(void);
+
+FILE *find_incl_file_near_fn(char *s, char *fn);
+FILE *find_standard_incl_file(char *s);
+FILE *find_incl_file(char *s);
 
 #include "ksyms.h"
 int yylex (void);
@@ -246,7 +254,7 @@ rvalue              : NUMBER
 
 #include "analyze.c"
 
-void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, _("loadkeys version %s\n"
 "\n"
@@ -364,11 +372,11 @@ main(int argc, char *argv[]) {
                while (      *s == ' ' || *s == '\t' || *s == ',') s++;
                e = s;
                while (*e && *e != ' ' && *e != '\t' && *e != ',') e++;
-               char c = *e;
+               char ch = *e;
                *e = '\0';
                if (verbose) printf("%s\n", s);
                loadkeys(s, &warned);
-               *e = c;
+               *e = ch;
                s = e;
              }
            free(buf);
@@ -390,13 +398,13 @@ yyerror(const char *s) {
 }
 
 /* fatal errors - change to varargs next time */
-void
+void attr_noreturn
 lkfatal(const char *s) {
        fprintf(stderr, "%s: %s:%d: %s\n", progname, filename, line_nr, s);
        exit(1);
 }
 
-void
+void attr_noreturn
 lkfatal0(const char *s, int d) {
        fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
        fprintf(stderr, s, d);
@@ -404,7 +412,7 @@ lkfatal0(const char *s, int d) {
        exit(1);
 }
 
-void
+void attr_noreturn
 lkfatal1(const char *s, const char *s2) {
        fprintf(stderr, "%s: %s:%d: ", progname, filename, line_nr);
        fprintf(stderr, s, s2);
@@ -515,8 +523,8 @@ FILE *find_standard_incl_file(char *s) {
 
        /* If filename is a symlink, also look near its target. */
        if (!f) {
-               char buf[1024], path[1024], *p;
-               int n;
+               char buf[1024], path[1024], *ptr;
+               unsigned int n;
 
                n = readlink(filename, buf, sizeof(buf));
                if (n > 0 && n < sizeof(buf)) {
@@ -526,9 +534,9 @@ FILE *find_standard_incl_file(char *s) {
                     else if (strlen(filename) + n < sizeof(path)) {
                          strcpy(path, filename);
                          path[sizeof(path)-1] = 0;
-                         p = rindex(path, '/');
-                         if (p)
-                              p[1] = 0;
+                         ptr = rindex(path, '/');
+                         if (ptr)
+                              ptr[1] = 0;
                          strcat(path, buf);
                          f = find_incl_file_near_fn(s, path);
                     }
@@ -682,67 +690,67 @@ addmap(int i, int explicit) {
 
 /* unset a key */
 static void
-killkey(int index, int table) {
-       /* roughly: addkey(index, table, K_HOLE); */
-
-        if (index < 0 || index >= NR_KEYS)
-               lkfatal0(_("killkey called with bad index %d"), index);
-        if (table < 0 || table >= MAX_NR_KEYMAPS)
-               lkfatal0(_("killkey called with bad table %d"), table);
-       if (key_map[table])
-               (key_map[table])[index] = K_HOLE;
-       if (keymap_was_set[table])
-               (keymap_was_set[table])[index] = 0;
+killkey(int k_index, int k_table) {
+       /* roughly: addkey(k_index, k_table, K_HOLE); */
+
+        if (k_index < 0 || k_index >= NR_KEYS)
+               lkfatal0(_("killkey called with bad index %d"), k_index);
+        if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+               lkfatal0(_("killkey called with bad table %d"), k_table);
+       if (key_map[k_table])
+               (key_map[k_table])[k_index] = K_HOLE;
+       if (keymap_was_set[k_table])
+               (keymap_was_set[k_table])[k_index] = 0;
 }
 
 static void
-addkey(int index, int table, int keycode) {
+addkey(int k_index, int k_table, int keycode) {
        int i;
 
        if (keycode == CODE_FOR_UNKNOWN_KSYM)
          /* is safer not to be silent in this case, 
           * it can be caused by coding errors as well. */
                lkfatal0(_("addkey called with bad keycode %d"), keycode);
-        if (index < 0 || index >= NR_KEYS)
-               lkfatal0(_("addkey called with bad index %d"), index);
-        if (table < 0 || table >= MAX_NR_KEYMAPS)
-               lkfatal0(_("addkey called with bad table %d"), table);
-
-       if (!defining[table])
-               addmap(table, 0);
-       if (!key_map[table]) {
-               key_map[table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
+        if (k_index < 0 || k_index >= NR_KEYS)
+               lkfatal0(_("addkey called with bad index %d"), k_index);
+        if (k_table < 0 || k_table >= MAX_NR_KEYMAPS)
+               lkfatal0(_("addkey called with bad table %d"), k_table);
+
+       if (!defining[k_table])
+               addmap(k_table, 0);
+       if (!key_map[k_table]) {
+               key_map[k_table] = (u_short *)xmalloc(NR_KEYS * sizeof(u_short));
                for (i = 0; i < NR_KEYS; i++)
-                 (key_map[table])[i] = K_HOLE;
+                 (key_map[k_table])[i] = K_HOLE;
        }
-       if (!keymap_was_set[table]) {
-               keymap_was_set[table] = (char *) xmalloc(NR_KEYS);
+       if (!keymap_was_set[k_table]) {
+               keymap_was_set[k_table] = (char *) xmalloc(NR_KEYS);
                for (i = 0; i < NR_KEYS; i++)
-                 (keymap_was_set[table])[i] = 0;
+                 (keymap_was_set[k_table])[i] = 0;
        }
 
-       if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[table])[index])
+       if (alt_is_meta && keycode == K_HOLE && (keymap_was_set[k_table])[k_index])
                return;
 
-       (key_map[table])[index] = keycode;
-       (keymap_was_set[table])[index] = 1;
+       (key_map[k_table])[k_index] = keycode;
+       (keymap_was_set[k_table])[k_index] = 1;
 
        if (alt_is_meta) {
-            int alttable = table | M_ALT;
+            int alttable = k_table | M_ALT;
             int type = KTYP(keycode);
             int val = KVAL(keycode);
-            if (alttable != table && defining[alttable] &&
+            if (alttable != k_table && defining[alttable] &&
                 (!keymap_was_set[alttable] ||
-                 !(keymap_was_set[alttable])[index]) &&
+                 !(keymap_was_set[alttable])[k_index]) &&
                 (type == KT_LATIN || type == KT_LETTER) && val < 128)
-                 addkey(index, alttable, K(KT_META, val));
+                 addkey(k_index, alttable, K(KT_META, val));
        }
 }
 
 static void
 addfunc(struct kbsentry kbs) {
        int sh, i, x;
-       char *p, *q, *r;
+       char *ptr, *q, *r;
 
        x = kbs.kb_func;
 
@@ -755,9 +763,9 @@ addfunc(struct kbsentry kbs) {
        q = func_table[x];
        if (q) {                        /* throw out old previous def */
                sh = strlen(q) + 1;
-               p = q + sh;
-               while (p < fp)
-                       *q++ = *p++;
+               ptr = q + sh;
+               while (ptr < fp)
+                       *q++ = *ptr++;
                fp -= sh;
 
                for (i = x + 1; i < MAX_NR_FUNC; i++)
@@ -765,13 +773,13 @@ addfunc(struct kbsentry kbs) {
                          func_table[i] -= sh;
        }
 
-       p = func_buf;                        /* find place for new def */
+       ptr = func_buf;                        /* find place for new def */
        for (i = 0; i < x; i++)
                if (func_table[i]) {
-                       p = func_table[i];
-                       while(*p++);
+                       ptr = func_table[i];
+                       while(*ptr++);
                }
-       func_table[x] = p;
+       func_table[x] = ptr;
         sh = strlen((char *) kbs.kb_string) + 1;
        if (fp + sh > func_buf + sizeof(func_buf)) {
                fprintf(stderr,
@@ -781,9 +789,9 @@ addfunc(struct kbsentry kbs) {
        q = fp;
        fp += sh;
        r = fp;
-       while (q > p)
+       while (q > ptr)
                *--r = *--q;
-       strcpy(p, (char *) kbs.kb_string);
+       strcpy(ptr, (char *) kbs.kb_string);
        for (i = x + 1; i < MAX_NR_FUNC; i++)
                if (func_table[i])
                        func_table[i] += sh;
@@ -791,15 +799,15 @@ addfunc(struct kbsentry kbs) {
 
 static void
 compose(int diacr, int base, int res) {
-        struct kbdiacr *p;
+        struct kbdiacr *ptr;
         if (accent_table_size == MAX_DIACR) {
                fprintf(stderr, _("compose table overflow\n"));
                exit(1);
        }
-       p = &accent_table[accent_table_size++];
-       p->diacr = diacr;
-       p->base = base;
-       p->result = res;
+       ptr = &accent_table[accent_table_size++];
+       ptr->diacr = diacr;
+       ptr->base = base;
+       ptr->result = res;
 }
 
 static int
@@ -937,15 +945,15 @@ ostr(char *s) {
 static int
 deffuncs(int fd){
         int i, ct = 0;
-       char *p;
+       char *ptr;
 
         for (i = 0; i < MAX_NR_FUNC; i++) {
            kbs_buf.kb_func = i;
-           if ((p = func_table[i])) {
-               strcpy((char *) kbs_buf.kb_string, p);
+           if ((ptr = func_table[i])) {
+               strcpy((char *) kbs_buf.kb_string, ptr);
                if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs_buf))
                  fprintf(stderr, _("failed to bind string '%s' to function %s\n"),
-                         ostr(kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
+                         ostr((char *) kbs_buf.kb_string), syms[KT_FN].table[kbs_buf.kb_func]);
                else
                  ct++;
            } else if (opts) {
@@ -963,7 +971,7 @@ deffuncs(int fd){
 static int
 defdiacs(int fd){
         struct kbdiacrs kd;
-       int i;
+       unsigned int i;
 
        kd.kb_cnt = accent_table_size;
        if (kd.kb_cnt > MAX_DIACR) {
@@ -1133,8 +1141,8 @@ compose_as_usual(char *charset) {
                };
                int i;
                for(i=0; i<68; i++) {
-                       struct ccc p = def_latin1_composes[i];
-                       compose(p.c1, p.c2, p.c3);
+                       struct ccc ptr = def_latin1_composes[i];
+                       compose(ptr.c1, ptr.c2, ptr.c3);
                }
        }
 }
@@ -1147,15 +1155,15 @@ static char *modifiers[8] = {
     "shift", "altgr", "ctrl", "alt", "shl", "shr", "ctl", "ctr"
 };
 
-static char *mk_mapname(char mod) {
+static char *mk_mapname(char modifier) {
     static char buf[60];
     int i;
 
-    if (!mod)
+    if (!modifier)
       return "plain";
     buf[0] = 0;
     for (i=0; i<8; i++)
-      if (mod & (1<<i)) {
+      if (modifier & (1<<i)) {
          if (buf[0])
            strcat(buf, "_");
          strcat(buf, modifiers[i]);
@@ -1172,12 +1180,13 @@ outchar (unsigned char c, int comma) {
        printf(comma ? "', " : "'");
 }
 
-static void
+static void attr_noreturn
 mktable () {
-       int i, imax, j;
+       int j;
+       unsigned int i, imax;
 
-       u_char *p;
-       int maxfunc;
+       char *ptr;
+       unsigned int maxfunc;
        unsigned int keymap_count = 0;
 
        printf(
@@ -1232,11 +1241,11 @@ mktable () {
 
        printf("char func_buf[] = {\n");
        for (i = 0; i < maxfunc; i++) {
-           p = func_table[i];
-           if (p) {
+           ptr = func_table[i];
+           if (ptr) {
                printf("\t");
-               for ( ; *p; p++)
-                       outchar(*p, 1);
+               for ( ; *ptr; ptr++)
+                       outchar(*ptr, 1);
                printf("0, \n");
            }
        }
@@ -1278,11 +1287,11 @@ mktable () {
        exit(0);
 }
 
-static void
+static void attr_noreturn
 bkeymap () {
        int i, j;
 
-       u_char *p;
+       //u_char *p;
        char flag, magic[] = "bkeymap";
        unsigned short v;
 
index 864a8a6..249e900 100644 (file)
@@ -37,7 +37,7 @@ int verbose = 0;
 int force = 0;
 int debug = 0;
 
-static void
+static void attr_noreturn
 usage(void) {
         fprintf(stderr,
                _("Usage:\n\t%s [-C console] [-o map.orig]\n"), progname);
@@ -301,24 +301,24 @@ loadunicodemap(int fd, char *tblname) {
 
 static struct unimapdesc
 getunicodemap(int fd) {
-  struct unimapdesc descr;
+  struct unimapdesc unimap_descr;
 
-  if (getunimap(fd, &descr))
+  if (getunimap(fd, &unimap_descr))
          exit(1);
 
 #ifdef MAIN
-  fprintf(stderr, "# %d %s\n", descr.entry_ct,
-        (descr.entry_ct == 1) ? _("entry") : _("entries"));
+  fprintf(stderr, "# %d %s\n", unimap_descr.entry_ct,
+        (unimap_descr.entry_ct == 1) ? _("entry") : _("entries"));
 #endif
 
-  return descr;
+  return unimap_descr;
 }
 
 void
 saveunicodemap(int fd, char *oufil) {
   FILE *fpo;
-  struct unimapdesc descr;
-  struct unipair *list;
+  struct unimapdesc unimap_descr;
+  struct unipair *unilist;
   int i;
 
   if ((fpo = fopen(oufil, "w")) == NULL) {
@@ -326,11 +326,11 @@ saveunicodemap(int fd, char *oufil) {
       exit(1);
   }
 
-  descr = getunicodemap(fd);
-  list = descr.entries;
+  unimap_descr = getunicodemap(fd);
+  unilist = unimap_descr.entries;
 
-  for(i=0; i<descr.entry_ct; i++)
-      fprintf(fpo, "0x%02x\tU+%04x\n", list[i].fontpos, list[i].unicode);
+  for(i=0; i<unimap_descr.entry_ct; i++)
+      fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode);
   fclose(fpo);
 
   if (verbose)
@@ -339,30 +339,30 @@ saveunicodemap(int fd, char *oufil) {
 
 void
 appendunicodemap(int fd, FILE *fp, int fontsize, int utf8) {
-       struct unimapdesc descr;
-       struct unipair *list;
+       struct unimapdesc unimap_descr;
+       struct unipair *unilist;
        int i, j;
 
-       descr = getunicodemap(fd);
-       list = descr.entries;
+       unimap_descr = getunicodemap(fd);
+       unilist = unimap_descr.entries;
 
                
        for(i=0; i<fontsize; i++) {
 #if 0
                /* More than one mapping is not a sequence! */
                int no = 0;
-               for(j=0; j<descr.entry_ct; j++) 
-                       if (list[j].fontpos == i)
+               for(j=0; j<unimap_descr.entry_ct; j++) 
+                       if (unilist[j].fontpos == i)
                                no++;
                if (no > 1)
                        appendseparator(fp, 1, utf8);
 #endif         
                if (debug) printf ("\nchar %03x: ", i);
-               for(j=0; j<descr.entry_ct; j++)
-                       if (list[j].fontpos == i) {
+               for(j=0; j<unimap_descr.entry_ct; j++)
+                       if (unilist[j].fontpos == i) {
                                if (debug)
-                                       printf ("%04x ", list[j].unicode);
-                               appendunicode(fp, list[j].unicode, utf8);
+                                       printf ("%04x ", unilist[j].unicode);
+                               appendunicode(fp, unilist[j].unicode, utf8);
                        }
                appendseparator(fp, 0, utf8);
        }
index 6c3ffc7..a08634e 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <linux/kd.h>
+#include "kbd.h"
 #include "paths.h"
 #include "findfile.h"
 #include "kdmapop.h"
@@ -122,7 +123,7 @@ parsemap(FILE *fp, char *buf, unsigned short *ubuf, int *u, int *lineno) {
 }
 
 static int
-readnewmapfromfile(int fd, char *mfil, char *buf, unsigned short *ubuf) {
+readnewmapfromfile(attr_unused int fd, char *mfil, char *buf, unsigned short *ubuf) {
        FILE *fp;
        struct stat stbuf;
        int u = 0;
index 19d58be..afcadf5 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _MODIFIERS_H
+#define _MODIFIERS_H
+
 #define M_PLAIN  0
 #define M_SHIFT  (1 << KG_SHIFT)
 #define M_CTRL   (1 << KG_CTRL)
@@ -8,3 +11,5 @@
 #define M_CTRLL  (1 << KG_CTRLL)
 #define M_CTRLR  (1 << KG_CTRLR)
 #define M_CAPSSHIFT (1 << KG_CAPSSHIFT)
+
+#endif /* _MODIFIERS_H */
index 0d23d96..53cc28b 100644 (file)
@@ -25,6 +25,7 @@
  * Applied patch by damjan@legolas (-e option), aeb, 2004-01-03.
  */
 
+#include "kbd.h"
 #include "openvt.h"
 #include "nls.h"
 
@@ -159,7 +160,6 @@ main(int argc, char *argv[])
                 to the kernel, but we cannot open it. Maybe X
                 used it and did a chown.  Try a few vt's more
                 before giving up. Note: the 16 is a kernel limitation. */
-             int i;
              for (i=vtno+1; i<16; i++) {
                      if((vtstat.v_state & (1<<i)) == 0) {
                              sprintf(vtname, VTNAME, i);
@@ -325,11 +325,12 @@ got_vtno:
 }
 
 
-void usage(int stat)
+void attr_noreturn
+usage(int ret)
 {
    fprintf(stderr, _(
      "Usage: openvt [-c vtnumber] [-f] [-l] [-u] [-s] [-v] [-w] -- command_line\n"));
-   exit (stat);
+   exit (ret);
 }
 
 /*
index 166703c..32b71c6 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _OPENVT_H
+#define _OPENVT_H
+
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -41,3 +44,5 @@ char *authenticate_user(int);
 #ifdef ESIX_5_3_2_D
 #define        VTBASE          "/dev/vt%02d"
 #endif
+
+#endif /* _OPENVT_H */
index b00dce5..1083b9f 100644 (file)
@@ -2,9 +2,10 @@
 /* assumes a little-endian machine */
 #include <stdio.h>
 #include <stdlib.h>    /* exit */
+#include "kbd.h"
 #include "psf.h"
 
-static void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n");
        exit(1);
index 9da48b3..7937d84 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef _PATHS_H
+#define _PATHS_H
 /*
  * All data is in subdirectories of DATADIR, by default /usr/lib/kbd
  * The following five subdirectories are defined:
@@ -29,3 +31,5 @@ extern void fpclose(FILE *fp);
 
 extern int verbose;
 extern int debug;
+
+#endif /* _PATHS_H */
index 461ab96..553c2d8 100644 (file)
@@ -181,9 +181,9 @@ readpsffont(FILE *fontf, char **allbufp, int *allszp,
            int *fontwidthp, int *fontlenp, int fontpos0,
            struct unicode_list **uclistheadsp) {
        char *inputbuf = NULL;
-       int inputbuflth = 0;
-       int inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8;
-       int i, k, n;
+       size_t inputbuflth = 0;
+       size_t inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8;
+       size_t i, k, n;
 
        /*
         * We used to look at the length of the input file
@@ -446,9 +446,10 @@ writepsffontheader(FILE *ofil, int width, int height, int fontlen,
 
 
 int
-writepsffont(FILE *ofil, char *fontbuf, int width, int height, int fontlen,
+writepsffont(FILE *ofil, char *fontbuf, int width, int height, size_t fontlen,
             int psftype, struct unicode_list *uclistheads) {
-       int bytewidth, charsize, flags, utf8, i;
+       int bytewidth, charsize, flags, utf8;
+       size_t i;
 
        bytewidth = (width+7)/8;
        charsize = bytewidth * height;
index 525a50f..455d9b7 100644 (file)
@@ -26,7 +26,7 @@ extern int readpsffont(FILE *fontf, char **allbufp, int *allszp,
                       struct unicode_list **uclistheadsp);
 
 extern int writepsffont(FILE *ofil, char *fontbuf,
-                        int width, int height, int fontlen, int psftype,
+                        int width, int height, size_t fontlen, int psftype,
                         struct unicode_list *uclistheads);
 
 #define WPSFH_HASTAB   1
index c4a8e9d..2a6e488 100644 (file)
@@ -331,7 +331,7 @@ main(int argc, char **argv) {
     return 0;
 }
 
-static void
+static void attr_noreturn
 usage() {
     fprintf(stderr,
            _("resizecons:\n"
index 1ebd290..fda16f0 100644 (file)
@@ -32,7 +32,8 @@ main(int argc, char **argv) {
     char infile[20];
     unsigned char header[4];
     unsigned int rows, cols;
-    int fd, i, j;
+    int fd;
+    unsigned int i, j;
     char *inbuf, *outbuf, *p, *q;
 
     set_progname(argv[0]);
@@ -74,7 +75,7 @@ main(int argc, char **argv) {
     inbuf = xmalloc(rows*cols*2);
     outbuf = xmalloc(rows*(cols+1));
 
-    if (read(fd, inbuf, rows*cols*2) != rows*cols*2) {
+    if (read(fd, inbuf, rows*cols*2) != (ssize_t) (rows*cols*2)) {
         fprintf(stderr, _("Error reading %s\n"), infile);
         exit(1);
     }
index b979cb7..511a94b 100644 (file)
@@ -67,7 +67,7 @@ findpartialfont(char *fnam) {
     return findfile(fnam, partfontdirpath, partfontsuffixes);
 }
 
-static void
+static void attr_noreturn
 usage(void)
 {
         fprintf(stderr, _(
@@ -247,7 +247,7 @@ static int erase_mode = 1;
 
 static void
 do_loadfont(int fd, char *inbuf, int width, int height, int hwunit,
-           int fontsize, char *pathname) {
+           int fontsize, char *filename) {
        unsigned char *buf;
        int i, buflen;
        int bytewidth = (width+7)/8;
@@ -306,15 +306,15 @@ do_loadfont(int fd, char *inbuf, int width, int height, int hwunit,
        }
 
        if (verbose) {
-               if (height == hwunit && pathname)
+               if (height == hwunit && filename)
                        printf(_("Loading %d-char %dx%d font from file %s\n"),
-                              fontsize, width, height, pathname);
+                              fontsize, width, height, filename);
                else if (height == hwunit)
                        printf(_("Loading %d-char %dx%d font\n"),
                               fontsize, width, height);
-               else if (pathname)
+               else if (filename)
                        printf(_("Loading %d-char %dx%d (%d) font from file %s\n"),
-                              fontsize, width, height, hwunit, pathname);
+                              fontsize, width, height, hwunit, filename);
                else
                        printf(_("Loading %d-char %dx%d (%d) font\n"),
                               fontsize, width, height, hwunit);
index d834fdc..f48da2a 100644 (file)
@@ -14,7 +14,7 @@
 #include "nls.h"
 #include "version.h"
 
-static void
+static void attr_noreturn
 usage(char *s) {
        fprintf(stderr, "setkeycode: %s\n", s);
        fprintf(stderr, _(
index 6f1a6db..3577aee 100644 (file)
@@ -14,7 +14,7 @@
 #include "nls.h"
 #include "version.h"
 
-static void
+static void attr_noreturn
 usage(void)
 {
     fprintf(stderr, _(
@@ -79,8 +79,8 @@ struct led {
 };
 
 static void
-getleds(char *leds) {
-    if (ioctl(0, KDGETLED, leds)) {
+getleds(char *cur_leds) {
+    if (ioctl(0, KDGETLED, cur_leds)) {
        perror("KDGETLED");
        fprintf(stderr,
          _("Error reading current led setting. Maybe stdin is not a VT?\n"));
@@ -89,8 +89,8 @@ getleds(char *leds) {
 }
 
 static int
-setleds(char leds) {
-    if (ioctl(0, KDSETLED, leds)) {
+setleds(char cur_leds) {
+    if (ioctl(0, KDSETLED, cur_leds)) {
        perror("KDSETLED");
        return -1;
     }
@@ -110,10 +110,16 @@ getflags(char *flags) {
 
 static int sunkbdfd = -1;
 
-static void
-sungetleds(char *leds) {
+#ifndef KIOCGLED
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
+static void attr_noreturn
+sungetleds(arg_state char *cur_leds) {
 #ifdef KIOCGLED
-    if (ioctl(sunkbdfd, KIOCGLED, leds)) {
+    if (ioctl(sunkbdfd, KIOCGLED, cur_leds)) {
        perror("KIOCGLED");
        fprintf(stderr,
          _("Error reading current led setting from /dev/kbd.\n"));
@@ -125,10 +131,16 @@ sungetleds(char *leds) {
 #endif
 }
 
-static void
-sunsetleds(char *leds) {
+#ifndef KIOCSLED
+#define arg_state attr_unused
+#else
+#define arg_state
+#endif
+
+static void attr_noreturn
+sunsetleds(arg_state char *cur_leds) {
 #ifdef KIOCSLED
-    if (ioctl(sunkbdfd, KIOCSLED, leds)) {
+    if (ioctl(sunkbdfd, KIOCSLED, cur_leds)) {
        perror("KIOCSLED");
        fprintf(stderr,
          _("Error reading current led setting from /dev/kbd.\n"));
@@ -236,7 +248,7 @@ main(int argc, char **argv) {
            sign = 0;
            ap++;
        }
-       for (lp = leds; lp-leds < sizeof(leds)/sizeof(leds[0]); lp++) {
+       for (lp = leds; (unsigned) (lp-leds) < sizeof(leds)/sizeof(leds[0]); lp++) {
            if(!strcmp(ap, lp->name)) {
                if(sign) {
                  nval |= lp->bit;
index ecbaaa3..1d927b0 100644 (file)
@@ -13,7 +13,7 @@
 #include "nls.h"
 #include "version.h"
 
-static void
+static void attr_noreturn
 usage(void)
 {
     fprintf(stderr, _(
@@ -85,7 +85,7 @@ main(int argc, char **argv) {
     }
 
     nmeta = 0;                 /* make gcc happy */
-    for (mp = metas; mp-metas < SIZE(metas); mp++) {
+    for (mp = metas; (unsigned) (mp-metas) < SIZE(metas); mp++) {
        if(!strcmp(argv[1], mp->name)) {
            nmeta = mp->val;
            goto fnd;
index 1ccb81b..c0b58d6 100644 (file)
@@ -26,7 +26,7 @@ int fd = 0;
 int have_obuf = 0;
 int have_ounimap = 0;
 
-static void
+static void attr_noreturn
 leave(int n) {
        if (have_obuf && loaduniscrnmap(fd,obuf)) {
                fprintf(stderr,
@@ -58,7 +58,7 @@ settrivialscreenmap(void) {
        }
 }
 
-static void
+static void attr_noreturn
 out_of_memory(void) {
        fprintf(stderr, _("%s: out of memory?\n"), progname);
        leave(1);
@@ -98,7 +98,7 @@ setnewunicodemap(int *list, int cnt) {
                leave(1);
 }
 
-static void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr,
                _("usage: showconsolefont -V|--version\n"
index d758842..2d8e3df 100644 (file)
@@ -60,20 +60,20 @@ clean_up(void) {
        close(fd);
 }
 
-static void
+static void attr_noreturn
 die(int x) {
        printf(_("caught signal %d, cleaning up...\n"), x);
        clean_up();
        exit(1);
 }
 
-static void
-watch_dog(int x) {
+static void attr_noreturn
+watch_dog(attr_unused int x) {
        clean_up();
        exit(0);
 }
 
-static void
+static void attr_noreturn
 usage(void) {
        fprintf(stderr, _(
 "showkey version %s\n\n"
index ef84d10..61e3475 100644 (file)
 #include <sys/ioctl.h> /* ioctl */
 #include <unistd.h>    /* sleep */
 
+#include "kbd.h"
+
 static void
-sighup(int n) {
+sighup(attr_unused int n) {
     if (system("openvt -s -l bash") == -1) {
       perror("system");
       exit(1);
index 921bbd9..cd7c4bd 100644 (file)
 #include <sys/ioctl.h>
 #include <linux/kd.h>
 
+#include "kbd.h"
+
 static void
-sighup(int n) {
+sighup(attr_unused int n) {
     if (system("openvt -s -l -- login -h spawn") == -1) {
        perror("system");
        exit(1);
index 0baff10..e1c780e 100644 (file)
@@ -1,4 +1,9 @@
+#ifndef _UTF8_H
+#define _UTF8_H
+
 extern unsigned long from_utf8(char **inptr, int cnt, int *err);
 
 #define UTF8_BAD       (-1)
 #define UTF8_SHORT     (-2)
+
+#endif /* _UTF8_H */
index 7e9be9d..2c257cd 100644 (file)
@@ -1,6 +1,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "kbd.h"
 #include "../config.h"
 
 char *progname;
@@ -13,7 +14,7 @@ set_progname(char *name) {
        progname = (p ? p+1 : name);
 }
 
-static inline void
+static inline void attr_noreturn
 print_version_and_exit(void) {
        printf(_("%s from %s\n"), progname, PACKAGE_STRING);
        exit(0);
index 4ab5b11..081db0a 100644 (file)
@@ -4,12 +4,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sysexits.h>
+#include "kbd.h"
 #include "nls.h"
 #include "xmalloc.h"
 
 extern char *progname;
 
-static void
+static void attr_noreturn
 nomem(void) {
        fprintf(stderr, _("%s: out of memory\n"), progname);
        exit(EX_OSERR);
index 5ea1fa1..0120235 100644 (file)
@@ -1,4 +1,9 @@
+#ifndef _XMALLOC_H
+#define _XMALLOC_H
+
 /* Error-free versions of some libc routines */
 extern void *xmalloc(size_t sz);
 extern void *xrealloc(void *p, size_t sz);
 extern char *xstrdup(char *p);
+
+#endif /* _XMALLOC_H */