Bug Summary

File:keymap.c
Location:line 179, column 9
Description:Value stored to 'ok' is never read

Annotated Source Code

1/************************************************************
2 Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
3
4 Permission to use, copy, modify, and distribute this
5 software and its documentation for any purpose and without
6 fee is hereby granted, provided that the above copyright
7 notice appear in all copies and that both that copyright
8 notice and this permission notice appear in supporting
9 documentation, and that the name of Silicon Graphics not be
10 used in advertising or publicity pertaining to distribution
11 of the software without specific prior written permission.
12 Silicon Graphics makes no representation about the suitability
13 of this software for any purpose. It is provided "as is"
14 without any express or implied warranty.
15
16 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25 ********************************************************/
26
27#include "xkbcomp.h"
28#include "tokens.h"
29#include "expr.h"
30#include "vmod.h"
31#include "action.h"
32#include "misc.h"
33#include "indicators.h"
34
35#define KEYCODES0 0
36#define GEOMETRY1 1
37#define TYPES2 2
38#define COMPAT3 3
39#define SYMBOLS4 4
40#define MAX_SECTIONS5 5
41
42static XkbFile *sections[MAX_SECTIONS5];
43
44/**
45 * Compile the given file and store the output in result.
46 * @param file A list of XkbFiles, each denoting one type (e.g.
47 * XkmKeyNamesIdx, etc.)
48 */
49Boolint
50CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge)
51{
52 unsigned have;
53 Boolint ok;
54 unsigned required, legal;
55 unsigned mainType;
56 char *mainName;
57 LEDInfo *unbound = NULL((void*)0);
58
59 bzero(sections, MAX_SECTIONS * sizeof(XkbFile *))memset(sections,0,5 * sizeof(XkbFile *));
60 mainType = file->type;
61 mainName = file->name;
62 switch (mainType)
63 {
64 case XkmSemanticsFile20:
65 required = XkmSemanticsRequired((1<<1));
66 legal = XkmSemanticsLegal(((1<<1))|((1<<0)|(1<<6)|(1<<3)));
67 break;
68 case XkmLayoutFile21: /* standard type if setxkbmap -print */
69 required = XkmLayoutRequired((1<<4)|(1<<2)|(1<<0));
70 legal = XkmKeymapLegal((((1<<1))|((1<<4)|(1<<2)|(1<<0)))|((
((1<<0)|(1<<6)|(1<<3))|((1<<6)|(1<<
5)))&(~(((1<<1))|((1<<4)|(1<<2)|(1<<
0))))))
;
71 break;
72 case XkmKeymapFile22:
73 required = XkmKeymapRequired(((1<<1))|((1<<4)|(1<<2)|(1<<0)));
74 legal = XkmKeymapLegal((((1<<1))|((1<<4)|(1<<2)|(1<<0)))|((
((1<<0)|(1<<6)|(1<<3))|((1<<6)|(1<<
5)))&(~(((1<<1))|((1<<4)|(1<<2)|(1<<
0))))))
;
75 break;
76 default:
77 ERROR1uError("Cannot compile %s alone into an XKM file\n",
78 XkbConfigText(mainType, XkbMessage3));
79 return False0;
80 }
81 have = 0;
82 ok = 1;
83 file = (XkbFile *) file->defs;
84 /* Check for duplicate entries in the input file */
85 while ((file) && (ok))
86 {
87 file->topName = mainName;
88 if ((have & (1 << file->type)) != 0)
89 {
90 ERROR2uError("More than one %s section in a %s file\n",
91 XkbConfigText(file->type, XkbMessage3),
92 XkbConfigText(mainType, XkbMessage3));
93 ACTIONuAction("All sections after the first ignored\n");
94 ok = False0;
95 }
96 else if ((1 << file->type) & (~legal))
97 {
98 ERROR2uError("Cannot define %s in a %s file\n",
99 XkbConfigText(file->type, XkbMessage3),
100 XkbConfigText(mainType, XkbMessage3));
101 ok = False0;
102 }
103 else
104 switch (file->type)
105 {
106 case XkmSemanticsFile20:
107 case XkmLayoutFile21:
108 case XkmKeymapFile22:
109 WSGO2uInternalError("Illegal %s configuration in a %s file\n",
110 XkbConfigText(file->type, XkbMessage3),
111 XkbConfigText(mainType, XkbMessage3));
112 ACTIONuAction("Ignored\n");
113 ok = False0;
114 break;
115 case XkmKeyNamesIndex4:
116 sections[KEYCODES0] = file;
117 break;
118 case XkmTypesIndex0:
119 sections[TYPES2] = file;
120 break;
121 case XkmSymbolsIndex2:
122 sections[SYMBOLS4] = file;
123 break;
124 case XkmCompatMapIndex1:
125 sections[COMPAT3] = file;
126 break;
127 case XkmGeometryIndex5:
128 case XkmGeometryFile23:
129 sections[GEOMETRY1] = file;
130 break;
131 case XkmVirtualModsIndex6:
132 case XkmIndicatorsIndex3:
133 WSGO1uInternalError("Found an isolated %s section\n",
134 XkbConfigText(file->type, XkbMessage3));
135 break;
136 default:
137 WSGO1uInternalError("Unknown file type %d\n", file->type);
138 break;
139 }
140 if (ok)
141 have |= (1 << file->type);
142 file = (XkbFile *) file->common.next;
143 }
144 /* compile the sections we have in the file one-by-one, or fail. */
145 if (ok)
146 {
147 if (ok && (sections[KEYCODES0] != NULL((void*)0)))
148 ok = CompileKeycodes(sections[KEYCODES0], result, MergeOverride2);
149 if (ok && (sections[GEOMETRY1] != NULL((void*)0)))
150 ok = CompileGeometry(sections[GEOMETRY1], result, MergeOverride2);
151 if (ok && (sections[TYPES2] != NULL((void*)0)))
152 ok = CompileKeyTypes(sections[TYPES2], result, MergeOverride2);
153 if (ok && (sections[COMPAT3] != NULL((void*)0)))
154 ok = CompileCompatMap(sections[COMPAT3], result, MergeOverride2,
155 &unbound);
156 if (ok && (sections[SYMBOLS4] != NULL((void*)0)))
157 ok = CompileSymbols(sections[SYMBOLS4], result, MergeOverride2);
158 }
159 if (!ok)
160 return False0;
161 result->defined = have;
162 if (required & (~have))
163 {
164 register int i, bit;
165 unsigned missing;
166 missing = required & (~have);
167 for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
168 {
169 if (missing & bit)
170 {
171 ERROR2uError("Missing %s section in a %s file\n",
172 XkbConfigText(i, XkbMessage3),
173 XkbConfigText(mainType, XkbMessage3));
174 missing &= ~bit;
175 }
176 }
177 ACTION1uAction("Description of %s not compiled\n",
178 XkbConfigText(mainType, XkbMessage3));
179 ok = False0;
Value stored to 'ok' is never read
180 }
181 ok = BindIndicators(result, True1, unbound, NULL((void*)0));
182 return ok;
183}