Mon Mar 16 11:18:10 2009 UTC ()
fix sign-compare issues


(lukem)
diff -r1.1 -r1.2 src/sbin/amrctl/amrctl.c

cvs diff -r1.1 -r1.2 src/sbin/amrctl/amrctl.c (expand / switch to unified diff)

--- src/sbin/amrctl/amrctl.c 2006/07/23 12:01:26 1.1
+++ src/sbin/amrctl/amrctl.c 2009/03/16 11:18:10 1.2
@@ -82,27 +82,27 @@ void describe_drive(int, int, int, int,  @@ -82,27 +82,27 @@ void describe_drive(int, int, int, int,
82 */ 82 */
83 83
84#define MB_COMMAND 0 84#define MB_COMMAND 0
85#define MB_CHANNEL 1 85#define MB_CHANNEL 1
86#define MB_PARAM 2 86#define MB_PARAM 2
87#define MB_PAD 3 87#define MB_PAD 3
88#define MB_DRIVE 4 88#define MB_DRIVE 4
89 89
90#define FIRMWARE_40LD 1 90#define FIRMWARE_40LD 1
91#define FIRMWARE_8LD 2 91#define FIRMWARE_8LD 2
92 92
93static struct { 93static struct {
94 const char *product; 94 const char *product;
95 const int signature; 95 const uint32_t signature;
96} prodtable[] = { 96} prodtable[] = {
97 { "Series 431", AMR_SIG_431 }, 97 { "Series 431", AMR_SIG_431 },
98 { "Series 438", AMR_SIG_438 }, 98 { "Series 438", AMR_SIG_438 },
99 { "Series 762", AMR_SIG_762 }, 99 { "Series 762", AMR_SIG_762 },
100 { "Integrated HP NetRAID (T5)", AMR_SIG_T5 }, 100 { "Integrated HP NetRAID (T5)", AMR_SIG_T5 },
101 { "Series 466", AMR_SIG_466 }, 101 { "Series 466", AMR_SIG_466 },
102 { "Series 467", AMR_SIG_467 }, 102 { "Series 467", AMR_SIG_467 },
103 { "Integrated HP NetRAID (T7)", AMR_SIG_T7 }, 103 { "Integrated HP NetRAID (T7)", AMR_SIG_T7 },
104 { "Series 490", AMR_SIG_490 } 104 { "Series 490", AMR_SIG_490 }
105}; 105};
106 106
107static struct { 107static struct {
108 const int code; 108 const int code;
@@ -202,27 +202,27 @@ usage(char *prog) @@ -202,27 +202,27 @@ usage(char *prog)
202 "-v\t\tverbose output\n", 202 "-v\t\tverbose output\n",
203 prog); 203 prog);
204 exit(1); 204 exit(1);
205} 205}
206 206
207/****************************************************************************** 207/******************************************************************************
208 * Card description 208 * Card description
209 */ 209 */
210 210
211int 211int
212describe_card(int fd, int verbosity, int globalparam) 212describe_card(int fd, int verbosity, int globalparam)
213{ 213{
214 struct amr_enquiry *ae; 214 struct amr_enquiry *ae;
215 int cardtype; 215 uint32_t cardtype;
216 216
217 /* 217 /*
218 * Try the 40LD firmware interface 218 * Try the 40LD firmware interface
219 */ 219 */
220 220
221 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG, 221 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG,
222 AMR_CONFIG_PRODUCT_INFO, 0); 222 AMR_CONFIG_PRODUCT_INFO, 0);
223 if (enq_result == AMR_STATUS_SUCCESS) { 223 if (enq_result == AMR_STATUS_SUCCESS) {
224 struct amr_prodinfo *ap; 224 struct amr_prodinfo *ap;
225 225
226 ap = (struct amr_prodinfo *)enq_buffer; 226 ap = (struct amr_prodinfo *)enq_buffer;
227 nschan = ap->ap_nschan; 227 nschan = ap->ap_nschan;
228 if (globalparam) { 228 if (globalparam) {
@@ -257,27 +257,27 @@ describe_card(int fd, int verbosity, int @@ -257,27 +257,27 @@ describe_card(int fd, int verbosity, int
257 ae = (struct amr_enquiry *)enq_buffer; 257 ae = (struct amr_enquiry *)enq_buffer;
258 if (enq_result == AMR_STATUS_SUCCESS) { 258 if (enq_result == AMR_STATUS_SUCCESS) {
259 cardtype = ae->ae_signature; 259 cardtype = ae->ae_signature;
260 } else { 260 } else {
261 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_ENQUIRY, 0, 0); 261 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_ENQUIRY, 0, 0);
262 cardtype = 0; 262 cardtype = 0;
263 } 263 }
264 264
265 if (enq_result == AMR_STATUS_SUCCESS) { 265 if (enq_result == AMR_STATUS_SUCCESS) {
266 266
267 if (globalparam) { 267 if (globalparam) {
268 const char *product = NULL; 268 const char *product = NULL;
269 char bios[100], firmware[100]; 269 char bios[100], firmware[100];
270 int i; 270 size_t i;
271 271
272 for (i = 0; i < NTAB(prodtable); i++) { 272 for (i = 0; i < NTAB(prodtable); i++) {
273 if (cardtype == prodtable[i].signature) { 273 if (cardtype == prodtable[i].signature) {
274 product = prodtable[i].product; 274 product = prodtable[i].product;
275 break; 275 break;
276 } 276 }
277 } 277 }
278 if (product == NULL) 278 if (product == NULL)
279 product = "unknown card signature"; 279 product = "unknown card signature";
280 280
281 /* 281 /*
282 * HP NetRaid controllers have a special encoding of 282 * HP NetRaid controllers have a special encoding of
283 * the firmware and BIOS versions. The AMI version 283 * the firmware and BIOS versions. The AMI version
@@ -338,66 +338,66 @@ describe_card(int fd, int verbosity, int @@ -338,66 +338,66 @@ describe_card(int fd, int verbosity, int
338 } 338 }
339 /* 339 /*
340 * Neither firmware interface succeeded. Abort. 340 * Neither firmware interface succeeded. Abort.
341 */ 341 */
342 342
343 fprintf(stderr, "Firmware interface not supported\n"); 343 fprintf(stderr, "Firmware interface not supported\n");
344 exit(1); 344 exit(1);
345 345
346} 346}
347 347
348char * 348char *
349describe_property(u_int8_t prop, char *buffer) 349describe_property(u_int8_t prop, char *buffer)
350{ 350{
351 int i; 351 size_t i;
352 352
353 strcpy(buffer, "<"); 353 strcpy(buffer, "<");
354 for (i = 0; i < NTAB(proptable); i++) { 354 for (i = 0; i < NTAB(proptable); i++) {
355 if (i > 0) 355 if (i > 0)
356 strcat(buffer, ","); 356 strcat(buffer, ",");
357 if (prop & proptable[i].code) 357 if (prop & proptable[i].code)
358 strcat(buffer, proptable[i].ifyes); 358 strcat(buffer, proptable[i].ifyes);
359 else 359 else
360 strcat(buffer, proptable[i].ifno); 360 strcat(buffer, proptable[i].ifno);
361 } 361 }
362 strcat(buffer, ">"); 362 strcat(buffer, ">");
363 363
364 return buffer; 364 return buffer;
365} 365}
366 366
367const char * 367const char *
368describe_state(int verbosity, u_int8_t state) 368describe_state(int verbosity, u_int8_t state)
369{ 369{
370 int i; 370 size_t i;
371 371
372 if ((AMR_DRV_PREVSTATE(state) == AMR_DRV_CURSTATE(state)) && 372 if ((AMR_DRV_PREVSTATE(state) == AMR_DRV_CURSTATE(state)) &&
373 (AMR_DRV_CURSTATE(state) == AMR_DRV_OFFLINE) && verbosity == 0) 373 (AMR_DRV_CURSTATE(state) == AMR_DRV_OFFLINE) && verbosity == 0)
374 return NULL; 374 return NULL;
375 375
376 for (i = 0; i < NTAB(statetable); i++) 376 for (i = 0; i < NTAB(statetable); i++)
377 if (AMR_DRV_CURSTATE(state) == statetable[i].code) 377 if (AMR_DRV_CURSTATE(state) == statetable[i].code)
378 return (statetable[i].status); 378 return (statetable[i].status);
379 379
380 return NULL; 380 return NULL;
381} 381}
382 382
383/****************************************************************************** 383/******************************************************************************
384 * Battery status 384 * Battery status
385 */ 385 */
386void 386void
387describe_battery(int fd, int verbosity, int fwint, int bflags, int globalparam) 387describe_battery(int fd, int verbosity, int fwint, int bflags, int globalparam)
388{ 388{
389 u_int8_t batt_status; 389 u_int8_t batt_status;
390 int i; 390 size_t i;
391 391
392 if (fwint == FIRMWARE_40LD) { 392 if (fwint == FIRMWARE_40LD) {
393 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG, 393 enq_result = amr_ioctl_enquiry(fd, AMR_CMD_CONFIG,
394 AMR_CONFIG_ENQ3, AMR_CONFIG_ENQ3_SOLICITED_FULL); 394 AMR_CONFIG_ENQ3, AMR_CONFIG_ENQ3_SOLICITED_FULL);
395 if (enq_result == AMR_STATUS_SUCCESS) { 395 if (enq_result == AMR_STATUS_SUCCESS) {
396 struct amr_enquiry3 *ae3; 396 struct amr_enquiry3 *ae3;
397 397
398 ae3 = (struct amr_enquiry3 *)enq_buffer; 398 ae3 = (struct amr_enquiry3 *)enq_buffer;
399 if (bflags || globalparam) { 399 if (bflags || globalparam) {
400 batt_status = ae3->ae_batterystatus; 400 batt_status = ae3->ae_batterystatus;
401 printf("Battery status\t\t"); 401 printf("Battery status\t\t");
402 for (i = 0; i < NTAB(battable); i++) { 402 for (i = 0; i < NTAB(battable); i++) {
403 if (batt_status & battable[i].code) 403 if (batt_status & battable[i].code)