Patch 3: Fix warnings in ipmi_ekanalyzer.c
Index: lib/ipmi_ekanalyzer.c
===================================================================
RCS file: /cvsroot/ipmitool/ipmitool/lib/ipmi_ekanalyzer.c,v
retrieving revision 1.20
diff -r1.20 ipmi_ekanalyzer.c
2373,2376c2373,2375
<    FILE * input_file;
<    /* this structure is declared in ipmi_fru.h */
<    struct fru_header header;
<    int return_status = ERROR_STATUS;
---
>       FILE * input_file;
>       struct fru_header header;
>       int ret;
2378,2396c2377,2398
<    input_file = fopen ( filename, "r");
<    if ( input_file == NULL ){
<       lprintf(LOG_ERR, "file: '%s' is not found", filename);
<       return_status = ERROR_STATUS;
<    }
<    else{
<       if ( !feof (input_file) ){
<          fread ( &header, sizeof (struct fru_header), 1, input_file );
<          printf("%s\n", EQUAL_LINE_LIMITER);
<          printf("FRU Header Info\n");
<          printf("%s\n", EQUAL_LINE_LIMITER);
<          printf("Format Version          :0x%02x %s\n", (header.version & 
0x0f),
<                   ((header.version & 0x0f)==1) ? "" : "{unsupported}");
<          printf("Internal Use Offset     :0x%02x\n", header.offset.internal);
<          printf("Chassis Info Offset     :0x%02x\n", header.offset.chassis);
<          printf("Board Info Offset       :0x%02x\n", header.offset.board);
<          printf("Product Info Offset     :0x%02x\n", header.offset.product);
<          printf("MultiRecord Offset      :0x%02x\n", header.offset.multi);
<          printf("Common header Checksum  :0x%02x\n", header.checksum);
---
>       input_file = fopen ( filename, "r");
>       if ( input_file == NULL ){
>               lprintf(LOG_ERR, "file: '%s' is not found", filename);
>               return (ERROR_STATUS);
>       }
>       ret = fread(&header, sizeof (struct fru_header), 1, input_file );
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Failed to read FRU header!");
>               return (ERROR_STATUS);
>       }
>       printf("%s\n", EQUAL_LINE_LIMITER);
>       printf("FRU Header Info\n");
>       printf("%s\n", EQUAL_LINE_LIMITER);
>       printf("Format Version          :0x%02x %s\n", 
>               (header.version & 0x0f),
>               ((header.version & 0x0f) == 1) ? "" : "{unsupported}");
>       printf("Internal Use Offset     :0x%02x\n", header.offset.internal);
>       printf("Chassis Info Offset     :0x%02x\n", header.offset.chassis);
>       printf("Board Info Offset       :0x%02x\n", header.offset.board);
>       printf("Product Info Offset     :0x%02x\n", header.offset.product);
>       printf("MultiRecord Offset      :0x%02x\n", header.offset.multi);
>       printf("Common header Checksum  :0x%02x\n", header.checksum);
2398,2406c2400,2401
<          return_status = OK_STATUS;
<       }
<       else{
<          lprintf(LOG_ERR, "Invalid FRU header!");
<          return_status = ERROR_STATUS;
<       }
<       fclose( input_file );
<    }
<    return return_status;
---
>       fclose( input_file );
>       return OK_STATUS;
2461c2456,2460
<          fread ( &format_version, 1, 1, input_file );
---
>        ret = fread(&format_version, 1, 1, input_file );
>        if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid format version!");
>               return;
>        }
2476c2475,2479
<             fread ( &data, 1, 1, input_file );
---
>           ret = fread(&data, 1, 1, input_file);
>           if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid data!");
>               return;
>           }
2491c2494,2498
<          fseek ( input_file, (header.offset.board * FACTOR_OFFSET), SEEK_SET);
---
>        ret = fseek(input_file, (header.offset.board * FACTOR_OFFSET), 
> SEEK_SET);
>        if ((ret != 0)) {
>               lprintf(LOG_ERR, "Invalid FRU Board Info Area!\n");
>               return;
>        }
2501c2508,2512
<             fread ( &data, 1, 1, input_file ); /* Format version */
---
>           ret = fread(&data, 1, 1, input_file); /* Format version */
>           if ((ret != 1) || ferror(input_file)) {
>                   lprintf(LOG_ERR, "Invalid FRU Format Version!\n");
>                   return;
>           }
2504c2515,2519
<                fread ( &data, 1, 1, input_file ); /* Board Area Length */
---
>              ret = fread(&data, 1, 1, input_file); /* Board Area Length */
>              if ((ret != 1) || ferror(input_file)) {
>                      lprintf(LOG_ERR, "Invalid Board Area Length!\n");
>                      return;
>              }
2515c2530,2534
<                fread ( &lan_code, 1, 1, input_file ); /* Language Code */
---
>              ret = fread(&lan_code, 1, 1, input_file); /* Language Code */
>              if ((ret != 1) || ferror(input_file)) {
>                      lprintf(LOG_ERR, "Invalid Language Code in input!\n");
>                      return;
>              }
2597a2617
>       int ret;
2614,2616c2634,2643
<       fread(&data, 1, 1, input_file);
<       printf("Format Version Number: %d\n", (data & 0x0f));
<       if (feof(input_file)) {
---
>       ret = fread (&data, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Version Number!");
>               return;
>       }
> 
>       printf("Format Version Number: %d\n", (data & 0x0f) );
>       ret = fread (&ch_len, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid length!");
2619,2622d2645
<       /* Have to read this into a char or else
<        * it ends up byte swapped on big endian machines
<        */
<       fread(&ch_len, 1, 1, input_file);
2631c2654,2658
<       fread(&ch_type, 1, 1, input_file);
---
>       ret = fread (&ch_type, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Chassis Type!");
>               return;
>       }
2673a2701
>       int ret;
2681,2688c2709,2713
<       /* Board length */
<       if (!feof(input_file)) {
<               fread(&len, 1, 1, input_file);
<               (*board_length)--;
<       }
<       /* Board Data */
<       if (feof(input_file)) {
<               printf("No Board Data found!\n");
---
> 
>       /* Board length*/
>       ret = fread(&len, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Length!");
2690a2716,2717
>       (*board_length)--;
> 
2705c2732,2736
<               fread(data, size_board, 1, input_file);
---
>               ret = fread(data, size_board, 1, input_file);
>               if ((ret != 1) || ferror(input_file)) {
>                       lprintf(LOG_ERR, "Invalid board type size!");
>                       goto out;
>               }
2725a2757
>                       unsigned char checksum = 0;
2735,2738c2767,2770
<                       if (!feof(input_file)) {
<                               unsigned char checksum = 0;
<                               fread(&checksum, 1, 1, input_file);
<                               printf("Checksum: 0x%02x\n", checksum);
---
>                       ret = fread(&checksum, 1, 1, input_file);
>                       if ((ret != 1) || ferror(input_file)) {
>                               lprintf(LOG_ERR, "Invalid Checksum!");
>                               goto out;
2739a2772
>                       printf("Checksum: 0x%02x\n", checksum);
2752c2785,2789
<                       fread(additional_data, size_board, 1, input_file);
---
>                       ret = fread(additional_data, size_board, 1, input_file);
>                       if ((ret != 1) || ferror(input_file)) {
>                               lprintf(LOG_ERR, "Invalid Additional Data!");
>                               goto out;
>                       }
2798a2836
>       int ret;
2815,2817c2853,2855
<       fread(&data, 1, 1, input_file);
<       printf("Format Version Number: %d\n", (data & 0x0f));
<       if (feof(input_file)) {
---
>       ret = fread(&data, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Data!");
2819a2858,2861
>       printf("Format Version Number: %d\n", (data & 0x0f) );
>       if ( feof(input_file) )
>               return;
> 
2821,2823c2863,2868
<        * it ends up byte swapped on big endian machines
<        */
<       fread(&ch_len, 1, 1, input_file);
---
>        * it ends up byte swapped on big endian machines */
>       ret = fread (&clen, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Length!");
>               return;
>       }
2828c2873,2876
<       if (feof(input_file)) {
---
> 
>       ret = fread (&data, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Length!");
3978,3982c4026,4035
<       fread(&data, 1, 1, input_file);
<       if (data < 1) {
<               lprintf(LOG_NOTICE, "There is no multi record in the file %s\n",
<                               filename);
<               fclose(input_file);
---
>       data = 0;
>       ret = fread(&data, 1, 1, input_file);
>       if ((ret != 1) || ferror(input_file)) {
>               lprintf(LOG_ERR, "Invalid Offset!");
>               return ERROR_STATUS;
>       }
>       if ( data == 0 ) {
>               lprintf(LOG_ERR, "There is no multi record in the file %s\n",
>                       filename);
>               fclose( input_file );
3987,3989c4040,4042
<       if (verbose == LOG_DEBUG) {
<               printf("start multi offset = 0x%02lx\n", multi_offset);
<       }
---
>       lprintf(LOG_DEBUG, "start multi offset = 0x%02x\n", 
>               multi_offset );
> 
3993,3994c4046,4052
<               fread(&(*list_record)->header, START_DATA_OFFSET, 1, 
input_file);
<               if ((*list_record)->header.len == 0) {
---
>               ret = fread(&(*list_record)->header, START_DATA_OFFSET, 1, 
>                               input_file);
>               if ((ret != 1) || ferror(input_file)) {
>                       lprintf(LOG_ERR, "Invalid Header!");
>                       return ERROR_STATUS;
>               }
>               if ( (*list_record)->header.len == 0 ){
4006,4010c4064,4068
<               fread((*list_record)->data, ((*list_record)->header.len), 1, 
<                               input_file);
<               if (verbose > 0) {
<                       printf("Record %d has length = %02x\n", record_count,
<                                       (*list_record)->header.len);
---
>               ret = fread((*list_record)->data, ((*list_record)->header.len),
>                                1, input_file);
>               if ((ret != 1) || ferror(input_file)) {
>                       lprintf(LOG_ERR, "Invalid Record Data!");
>                       return ERROR_STATUS;
4011a4070,4072
>               if (verbose > 0)
>                       printf("Record %d has length = %02x\n", record_count,
>                              (*list_record)->header.len);
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to