Bug Summary

File:fsprobe/fsprobe_test.c
Location:line 234, column 5
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/*
11 * Description:
12 * Test of the fsprobe module.
13 *
14 *------------------------------------------------------------------------*/
15
16#include <afsconfig.h>
17#include <afs/param.h>
18
19#include <roken.h>
20
21#include "fsprobe.h" /*Interface for fsprobe module */
22#include <afs/afsutil.h>
23
24/*------------------------------------------------------------------------
25 * FS_Handler
26 *
27 * Description:
28 * Handler routine passed to the fsprobe module. This handler is
29 * called immediately after a poll of all the FileServers has taken
30 * place. All it needs to know is exported by the fsprobe module,
31 * namely the data structure where the probe results are stored.
32 *
33 * Arguments:
34 * None.
35 *
36 * Returns:
37 * 0 on success,
38 * -1 otherwise.
39 *
40 * Environment:
41 * See above. All we do now is print out what we got.
42 *
43 * Side Effects:
44 * As advertised.
45 *------------------------------------------------------------------------*/
46
47int
48FS_Handler(void)
49{ /*FS_Handler */
50
51 static char rn[] = "FS_Handler"; /*Routine name */
52 struct ProbeViceStatistics *curr_stats; /*Ptr to current stats */
53 int curr_srvidx, i; /*Current server index */
54 int *curr_probeOK; /*Ptr to current probeOK value */
55
56 printf("[%s] Called; results of poll %d are:\n", rn,
57 fsprobe_Results.probeNum);
58 curr_stats = fsprobe_Results.stats;
59 curr_probeOK = fsprobe_Results.probeOK;
60
61 for (curr_srvidx = 0; curr_srvidx < 3; curr_srvidx++) {
62 printf("\nServer %s:\n", (fsprobe_ConnInfo + curr_srvidx)->hostName);
63 printf("\tValue of probeOK for this server: %d\n", *curr_probeOK);
64 printf("\tCurrentMsgNumber:\t%d\n", curr_stats->CurrentMsgNumber);
65 printf("\tOldestMsgNumber:\t%d\n", curr_stats->OldestMsgNumber);
66 printf("\tCurrentTime:\t%d\n", curr_stats->CurrentTime);
67 printf("\tBootTime:\t%d\n", curr_stats->BootTime);
68 printf("\tStartTime:\t%d\n", curr_stats->StartTime);
69 printf("\tCurrentConnections:\t%d\n", curr_stats->CurrentConnections);
70 printf("\tTotalViceCalls:\t%d\n", curr_stats->TotalViceCalls);
71 printf("\tTotalFetchs:\t%d\n", curr_stats->TotalFetchs);
72 printf("\tFetchDatas:\t%d\n", curr_stats->FetchDatas);
73 printf("\tFetchedBytes:\t%d\n", curr_stats->FetchedBytes);
74 printf("\tFetchDataRate:\t%d\n", curr_stats->FetchDataRate);
75 printf("\tTotalStores:\t%d\n", curr_stats->TotalStores);
76 printf("\tStoreDatas:\t%d\n", curr_stats->StoreDatas);
77 printf("\tStoredBytes:\t%d\n", curr_stats->StoredBytes);
78 printf("\tStoreDataRate:\t%d\n", curr_stats->StoreDataRate);
79 printf("\tTotalRPCBytesSent:\t%d\n", curr_stats->TotalRPCBytesSent);
80 printf("\tTotalRPCBytesReceived:\t%d\n",
81 curr_stats->TotalRPCBytesReceived);
82 printf("\tTotalRPCPacketsSent:\t%d\n",
83 curr_stats->TotalRPCPacketsSent);
84 printf("\tTotalRPCPacketsReceived:\t%d\n",
85 curr_stats->TotalRPCPacketsReceived);
86 printf("\tTotalRPCPacketsLost:\t%d\n",
87 curr_stats->TotalRPCPacketsLost);
88 printf("\tTotalRPCBogusPackets:\t%d\n",
89 curr_stats->TotalRPCBogusPackets);
90 printf("\tSystemCPU:\t%d\n", curr_stats->SystemCPU);
91 printf("\tUserCPU:\t%d\n", curr_stats->UserCPU);
92 printf("\tNiceCPU:\t%d\n", curr_stats->NiceCPU);
93 printf("\tIdleCPU:\t%d\n", curr_stats->IdleCPU);
94 printf("\tTotalIO:\t%d\n", curr_stats->TotalIO);
95 printf("\tActiveVM:\t%d\n", curr_stats->ActiveVM);
96 printf("\tTotalVM:\t%d\n", curr_stats->TotalVM);
97 printf("\tEtherNetTotalErrors:\t%d\n",
98 curr_stats->EtherNetTotalErrors);
99 printf("\tEtherNetTotalWrites:\t%d\n",
100 curr_stats->EtherNetTotalWrites);
101 printf("\tEtherNetTotalInterupts:\t%d\n",
102 curr_stats->EtherNetTotalInterupts);
103 printf("\tEtherNetGoodReads:\t%d\n", curr_stats->EtherNetGoodReads);
104 printf("\tEtherNetTotalBytesWritten:\t%d\n",
105 curr_stats->EtherNetTotalBytesWritten);
106 printf("\tEtherNetTotalBytesRead:\t%d\n",
107 curr_stats->EtherNetTotalBytesRead);
108 printf("\tProcessSize:\t%d\n", curr_stats->ProcessSize);
109 printf("\tWorkStations:\t%d\n", curr_stats->WorkStations);
110 printf("\tActiveWorkStations:\t%d\n", curr_stats->ActiveWorkStations);
111 printf("\tSpare1:\t%d\n", curr_stats->Spare1);
112 printf("\tSpare2:\t%d\n", curr_stats->Spare2);
113 printf("\tSpare3:\t%d\n", curr_stats->Spare3);
114 printf("\tSpare4:\t%d\n", curr_stats->Spare4);
115 printf("\tSpare5:\t%d\n", curr_stats->Spare5);
116 printf("\tSpare6:\t%d\n", curr_stats->Spare6);
117 printf("\tSpare7:\t%d\n", curr_stats->Spare7);
118 printf("\tSpare8:\t%d\n", curr_stats->Spare8);
119
120 for (i = 0; i < 26; i++) {
121 printf("\tDisk %d: blocks avail=%d, ttl blocks=%d, name=%s\n", i,
122 curr_stats->Disk[i].BlocksAvailable,
123 curr_stats->Disk[i].TotalBlocks, curr_stats->Disk[i].Name);
124 }
125 /*
126 * Bump out statistics pointer to the next server's region. Ditto
127 * for probeOK;
128 */
129 curr_stats++;
130 curr_probeOK++;
131
132 } /*For each server */
133
134 /*
135 * Return the happy news.
136 */
137 return (0);
138
139} /*FS_Handler */
140
141#include "AFS_component_version_number.c"
142
143int
144main(int argc, char **argv)
145{ /*Main routine */
146
147 static char rn[] = "fsprobe_test"; /*Routine name */
148 afs_int32 code; /*Return code */
149 struct sockaddr_in FSSktArray[3]; /*socket array */
150 struct hostent *he; /*Host entry */
151 struct timeval tv; /*Time structure */
152 int sleep_secs; /*Number of seconds to sleep */
153
154 printf("\n\nTest of the fsprobe facility.\n\n");
155
156 /*
157 * Fill in the socket array for bigbird, vice1, and vice2.
158 */
159 FSSktArray[0].sin_family = AF_INET2;
160 FSSktArray[0].sin_port = htons(7000)(__builtin_constant_p(7000) ? (__uint16_t)(((__uint16_t)(7000
)) << 8 | ((__uint16_t)(7000)) >> 8) : __bswap16_var
(7000))
; /* FileServer port */
161 he = hostutil_GetHostByName("servername1");
162 if (he == NULL((void *)0)) {
163 fprintf(stderr__stderrp, "[%s] Can't get host info for servername1\n", rn);
164 exit(-1);
165 }
166 memcpy(&(FSSktArray[0].sin_addr.s_addr), he->h_addrh_addr_list[0], 4);
167
168 FSSktArray[1].sin_family = AF_INET2;
169 FSSktArray[1].sin_port = htons(7000)(__builtin_constant_p(7000) ? (__uint16_t)(((__uint16_t)(7000
)) << 8 | ((__uint16_t)(7000)) >> 8) : __bswap16_var
(7000))
; /* FileServer port */
170 he = hostutil_GetHostByName("servername2");
171 if (he == NULL((void *)0)) {
172 fprintf(stderr__stderrp, "[%s] Can't get host info for servername2\n", rn);
173 exit(-1);
174 }
175 memcpy(&(FSSktArray[1].sin_addr.s_addr), he->h_addrh_addr_list[0], 4);
176
177 FSSktArray[2].sin_family = AF_INET2;
178 FSSktArray[2].sin_port = htons(7000)(__builtin_constant_p(7000) ? (__uint16_t)(((__uint16_t)(7000
)) << 8 | ((__uint16_t)(7000)) >> 8) : __bswap16_var
(7000))
; /* FileServer port */
179 he = hostutil_GetHostByName("servername3");
180 if (he == NULL((void *)0)) {
181 fprintf(stderr__stderrp, "[%s] Can't get host info for servername3\n", rn);
182 exit(-1);
183 }
184 memcpy(&(FSSktArray[2].sin_addr.s_addr), he->h_addrh_addr_list[0], 4);
185
186 printf("Sockets for the 3 AFS FileServers to be probed:\n");
187 printf("\t Host servername1: IP addr 0x%x, port %d\n",
188 FSSktArray[0].sin_addr.s_addr, FSSktArray[0].sin_port);
189 printf("\t Host servername2: IP addr 0x%x, port %d\n",
190 FSSktArray[1].sin_addr.s_addr, FSSktArray[1].sin_port);
191 printf("\t Host servername3: IP addr 0x%x, port %d\n",
192 FSSktArray[2].sin_addr.s_addr, FSSktArray[2].sin_port);
193
194 /*
195 * Crank up the FileServer prober, then sit back and have fun.
196 */
197 printf("Starting up the fsprobe service\n");
198 code = fsprobe_Init(3, /*Num servers */
199 FSSktArray, /*FileServer socket array */
200 30, /*Probe every 30 seconds */
201 FS_Handler, /*Handler routine */
202 1); /*Turn debugging output on */
203 if (code) {
204 fprintf(stderr__stderrp, "[%s] Error returned by fsprobe_Init: %d\n", rn,
205 code);
206 fsprobe_Cleanup(1); /*Get rid of malloc'ed structures */
207 exit(-1);
208 }
209 sleep_secs = 60 * 10; /*Allow 10 minutes of data collection */
210 printf
211 ("Fsprobe service started, main thread sleeping for %d seconds...\n",
212 sleep_secs);
213
214 /*
215 * Let's just fall asleep for a while, then we'll clean up.
216 */
217 tv.tv_sec = sleep_secs;
218 tv.tv_usec = 0;
219 code = IOMGR_Select(0, /*Num fds */
220 0, /*Descriptors ready for reading */
221 0, /*Descriptors ready for writing */
222 0, /*Descriptors with exceptional conditions */
223 &tv); /*Timeout structure */
224 if (code) {
225 fprintf(stderr__stderrp, "[%s] IOMGR_Select() returned non-zero value: %d\n",
226 rn, code);
227 }
228
229 /*
230 * We're all done. Clean up, put the last nail in Rx, then
231 * exit happily.
232 */
233 printf("Yawn, main thread just woke up. Cleaning things out...\n");
234 code = fsprobe_Cleanup(1); /*Get rid of malloc'ed data */
Value stored to 'code' is never read
235 rx_Finalize();
236 exit(0);
237
238} /*Main routine */