Bug Summary

File:gtx/gtxtest.c
Location:line 48, column 2
Description:Value stored to 'code' is never read

Annotated Source Code

1/*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10#include <afsconfig.h>
11#include <afs/param.h>
12
13#include <roken.h>
14
15#include "gtxwindows.h"
16#include "gtxobjects.h"
17#include "gtxtextobj.h"
18#include "gtxlightobj.h"
19#include "gtxkeymap.h"
20#include "gtxframe.h"
21#include "gtxinput.h"
22
23struct gtx_frame *frameA, *frameB;
24
25struct onode *objectA, *objectB;
26struct onode *lightA, *lightB;
27
28static int
29ChangeMenuCmd(void *param1, void *param2)
30{
31 struct gwin * awin = (struct gwin *) param1;
32 afs_int32 arock = (intptr_t)param2;
33
34 struct gtx_frame *tf;
35 afs_int32 code;
36
37 tf = awin->w_frame;
38 if (!tf)
39 return -1;
40
41 if (arock == 1) {
42 gtxframe_ClearMenus(tf);
43 } else if (arock == 2) {
44 code = gtxframe_DeleteMenu(tf, "NewLabel");
45 if (code)
46 gtxframe_DisplayString(tf, "Can't delete menu!");
47 } else if (arock == 3) {
48 code = gtxframe_ClearMenus(tf);
Value stored to 'code' is never read
49 gtxframe_AddMenu(frameA, "FrameB", "b");
50 gtxframe_AddMenu(frameA, "NewLabel", "c");
51 }
52 return 0;
53}
54
55static int
56ChangeListCmd(void *param1, void *param2)
57{
58 struct gwin *awin = (struct gwin *) param1;
59 afs_int32 arock = (intptr_t)param2;
60
61 struct gtx_frame *tf;
62 afs_int32 code;
63
64 tf = awin->w_frame;
65 if (!tf)
66 return -1;
67
68 if (arock == 1) {
69 gtxframe_ClearList(tf);
70 } else if (arock == 2) {
71 code = gtxframe_RemoveFromList(tf, lightA);
72 if (code)
73 gtxframe_DisplayString(tf, "Can't delete light!");
74 } else if (arock == 3) {
75 code = gtxframe_ClearList(tf);
76 gtxframe_AddToList(frameA, objectA);
77 gtxframe_AddToList(frameA, lightA);
78 }
79 return 0;
80}
81
82static int
83NoCallCmd(void *param, void *unused)
84{
85 struct gwin *awin = (struct gwin *)param;
86
87 gtxframe_DisplayString(awin->w_frame,
88 "Function should be mapped on '$d', not 'd'");
89 return 0;
90}
91
92static int
93ChangeCmd(void *param, void *unused)
94{
95 struct gwin *awin = (struct gwin *) param;
96 char tbuffer[100];
97 afs_int32 code;
98
99 code =
100 gtxframe_AskForString(awin->w_frame, "New object string: ", "TestNew",
101 tbuffer, sizeof(tbuffer));
102 if (code == 0) {
103 /* have new value, write it to object A */
104 gator_text_Write(objectA, tbuffer, 0, 0, 0);
105 }
106 return 0;
107}
108
109static int
110StupidCmd(void *param, void *unused)
111{
112 struct gwin *awin = (struct gwin *)param;
113
114 gtxframe_DisplayString(awin->w_frame,
115 "You're already showing that frame!");
116 return 0;
117}
118
119static int
120SwitchToACmd(void *param, void *unused)
121{
122 struct gwin *awin = (struct gwin *)param;
123 gtxframe_SetFrame(awin, frameA);
124 return 0;
125}
126
127static int
128SwitchToBCmd(void *param, void *unused)
129{
130 struct gwin *awin = (struct gwin *)param;
131 gtxframe_SetFrame(awin, frameB);
132 return 0;
133}
134
135#include "AFS_component_version_number.c"
136
137int
138main(int argc, char **argv)
139{
140 struct gwin *win;
141 struct gator_textobj_params textcrparams;
142 struct gator_light_crparams lightcrparams;
143 struct keymap_map *tmap;
144
145 win = gtx_Init(0, -1);
146
147 /* create a couple of objects, a and b, and have the "a" and "b" keys
148 * switch the display from one to the other */
149 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT0;
150 strcpy(textcrparams.onode_params.cr_name, "Text1-A");
151 textcrparams.onode_params.cr_x = 30;
152 textcrparams.onode_params.cr_y = 10;
153 textcrparams.onode_params.cr_width = 35;
154 textcrparams.onode_params.cr_height = 7;
155 textcrparams.onode_params.cr_window = win; /* ???? */
156 textcrparams.onode_params.cr_home_obj = NULL((void *)0);
157 textcrparams.onode_params.cr_prev_obj = NULL((void *)0);
158 textcrparams.onode_params.cr_parent_obj = NULL((void *)0);
159 textcrparams.onode_params.cr_helpstring = "Help string for text";
160 textcrparams.maxEntries = 7;
161 textcrparams.maxCharsPerEntry = 35;
162
163 objectA =
164 gator_objects_create((struct onode_createparams *)(&textcrparams));
165 gator_text_Write(objectA, "This is object A", 0, 0, 0);
166
167 /* create a couple of objects, a and b, and have the "a" and "b" keys
168 * switch the display from one to the other */
169 textcrparams.onode_params.cr_type = GATOR_OBJ_TEXT0;
170 strcpy(textcrparams.onode_params.cr_name, "Text2-B");
171 textcrparams.onode_params.cr_x = 30;
172 textcrparams.onode_params.cr_y = 10;
173 textcrparams.onode_params.cr_width = 35;
174 textcrparams.onode_params.cr_height = 7;
175 textcrparams.onode_params.cr_window = win; /* ???? */
176 textcrparams.onode_params.cr_home_obj = NULL((void *)0);
177 textcrparams.onode_params.cr_prev_obj = NULL((void *)0);
178 textcrparams.onode_params.cr_parent_obj = NULL((void *)0);
179 textcrparams.onode_params.cr_helpstring = "Help string for text";
180 textcrparams.maxEntries = 7;
181 textcrparams.maxCharsPerEntry = 35;
182
183 objectB =
184 gator_objects_create((struct onode_createparams *)(&textcrparams));
185 gator_text_Write(objectB, "This is object B", 0, 0, 0);
186
187 lightcrparams.onode_params.cr_type = GATOR_OBJ_LIGHT1;
188 lightcrparams.onode_params.cr_x = 10;
189 lightcrparams.onode_params.cr_y = 10;
190 lightcrparams.onode_params.cr_width = 10;
191 lightcrparams.onode_params.cr_height = 10;
192 lightcrparams.onode_params.cr_window = win; /* ???? */
193 lightcrparams.onode_params.cr_home_obj = NULL((void *)0);
194 lightcrparams.onode_params.cr_prev_obj = NULL((void *)0);
195 lightcrparams.onode_params.cr_parent_obj = NULL((void *)0);
196 lightcrparams.onode_params.cr_helpstring = "Help string for text";
197 strcpy(lightcrparams.label, "Light-1");
198 lightcrparams.label_x = 0;
199 lightcrparams.label_y = 0;
200 lightcrparams.flashfreq = 100;
201 lightcrparams.appearance = GATOR_LIGHTMASK_INVVIDEO0x2;
202 lightA =
203 gator_objects_create((struct onode_createparams *)(&lightcrparams));
204
205 /* create basic frames */
206 frameA = gtxframe_Create();
207 frameB = gtxframe_Create();
208
209 /* setup A's frame */
210 gtxframe_ClearList(frameA);
211 gtxframe_AddToList(frameA, objectA);
212 gtxframe_AddToList(frameA, lightA);
213 keymap_BindToString(frameA->keymap, "b", SwitchToBCmd, NULL((void *)0), NULL((void *)0));
214 keymap_BindToString(frameA->keymap, "a", StupidCmd, NULL((void *)0), NULL((void *)0));
215 keymap_BindToString(frameA->keymap, "c", ChangeCmd, NULL((void *)0), NULL((void *)0));
216 keymap_BindToString(frameA->keymap, "\033a", ChangeMenuCmd, "ChangeMenu",
217 (char *)1);
218 keymap_BindToString(frameA->keymap, "\033b", ChangeMenuCmd, "ChangeMenu",
219 (char *)2);
220 keymap_BindToString(frameA->keymap, "\033c", ChangeMenuCmd, "ChangeMenu",
221 (char *)3);
222 keymap_BindToString(frameA->keymap, "\0331", ChangeListCmd, "ChangeList",
223 (char *)1);
224 keymap_BindToString(frameA->keymap, "\0332", ChangeListCmd, "ChangeList",
225 (char *)2);
226 keymap_BindToString(frameA->keymap, "\0333", ChangeListCmd, "ChangeList",
227 (char *)3);
228 gtxframe_AddMenu(frameA, "FrameB", "b");
229 gtxframe_AddMenu(frameA, "NewLabel", "c");
230
231 /* setup B's frame */
232 gtxframe_ClearList(frameB);
233 gtxframe_AddToList(frameB, objectB);
234 keymap_BindToString(frameB->keymap, "a", SwitchToACmd, NULL((void *)0), NULL((void *)0));
235 keymap_BindToString(frameB->keymap, "b", StupidCmd, NULL((void *)0), NULL((void *)0));
236 keymap_BindToString(frameB->keymap, "d", NoCallCmd, NULL((void *)0), NULL((void *)0));
237 keymap_BindToString(frameB->keymap, "d", (int (*)())0, NULL((void *)0), NULL((void *)0));
238 keymap_BindToString(frameB->keymap, "\033d", NoCallCmd, NULL((void *)0), NULL((void *)0));
239 gtxframe_AddMenu(frameB, "FrameA", "a");
240
241 /* finally setup the first window */
242 gtxframe_AddToList(frameA, objectA);
243 gtxframe_SetFrame(win, frameA);
244
245 /* play with maps for a while */
246 tmap = (struct keymap_map *)keymap_Create();
247 keymap_BindToString(tmap, "d", NoCallCmd, "test", (char *)1);
248 keymap_BindToString(tmap, "cd", NoCallCmd, "bozo", NULL((void *)0));
249 keymap_Delete(tmap);
250
251 gtx_InputServer(win);
252 return 0;
253}