@@ -96,11 +96,11 @@ static inline uint8_t fru_field_copy(void *dest, const fru_field_t *fieldp)
9696 * @retval FRU_FIELD_TERMINATOR The data exceeded the maximum length (63 bytes)
9797 *
9898 */
99- static
100- uint8_t fru_get_typelen (int len , /**< [in] Length of the data,
101- LEN_AUTO for pure text zero-terminated data or
102- one of LEN_BCDPLUS, LEN_6BITASCII, LEN_TEXT for explicit text type */
103- const uint8_t * data ) /**< [in] The input data */
99+ static uint8_t
100+ fru_get_typelen (int len , /**< [in] Length of the data,
101+ LEN_AUTO for pure text zero-terminated data or
102+ one of LEN_BCDPLUS, LEN_6BITASCII, LEN_TEXT for explicit text type */
103+ const uint8_t * data ) /**< [in] The input data */
104104{
105105 uint8_t typelen = len ;
106106 int i ;
@@ -111,16 +111,16 @@ uint8_t fru_get_typelen(int len, /**< [in] Length of the data,
111111 if (len < 0 ) {
112112 DEBUG ("Forcing string '%s' to ...\n" , (char * )data );
113113 // Explicit text type
114- if (len == LEN_BCDPLUS ) {
114+ if (len == LEN_BCDPLUS ) {
115115 DEBUG ("BCDPLUS type\n" );
116116 return FRU_TYPELEN (BCDPLUS , (strlen (data ) + 1 ) / 2 );
117- } else if (len == LEN_6BITASCII ) {
117+ } else if (len == LEN_6BITASCII ) {
118118 DEBUG ("6BIT ASCII type\n" );
119119 return FRU_TYPELEN (ASCII_6BIT , FRU_6BIT_LENGTH (strlen (data )));
120- } else if (len == LEN_TEXT ) {
120+ } else if (len == LEN_TEXT ) {
121121 DEBUG ("ASCII type\n" );
122122 return FRU_TYPELEN (TEXT , strlen (data ));
123- } else {
123+ } else {
124124 DEBUG ("Nothing... Unknown text type\n" );
125125 return FRU_FIELD_TERMINATOR ;
126126 }
@@ -162,9 +162,9 @@ uint8_t fru_get_typelen(int len, /**< [in] Length of the data,
162162 // Go through the data and expand charset as needed
163163 for (i = 0 ; i < len ; i ++ ) {
164164 if (data [i ] < ' '
165- && data [i ] != '\t'
166- && data [i ] != '\r'
167- && data [i ] != '\n' )
165+ && data [i ] != '\t'
166+ && data [i ] != '\r'
167+ && data [i ] != '\n' )
168168 {
169169 // They lied! The data is binary!
170170 // That's the widest range type.
@@ -176,7 +176,7 @@ uint8_t fru_get_typelen(int len, /**< [in] Length of the data,
176176
177177 if (autodetect ) {
178178 if (typelen < FRU_MAKETYPE (TEXT )
179- && (data [i ] > '_' || data [i ] < ' ' ))
179+ && (data [i ] > '_' || data [i ] < ' ' ))
180180 { // Do not reduce the range
181181 // The data doesn't fit into 6-bit ASCII, expand to simple text.
182182 DEBUG ("[%c] Data is simple text!\n" , data [i ]);
@@ -211,8 +211,7 @@ static fru_field_t *fru_encode_6bit(const unsigned char *s /**< [in] Input strin
211211 fru_field_t * out = NULL ;
212212 size_t outlen = sizeof (fru_field_t ) + len6bit + 1 ; // 1 extra for null-byte
213213
214- if (len6bit > FRU_FIELDDATALEN (len6bit ) ||
215- !(out = calloc (1 , outlen )))
214+ if (len6bit > FRU_FIELDDATALEN (len6bit ) || !(out = calloc (1 , outlen )))
216215 {
217216 return out ;
218217 }
@@ -321,8 +320,8 @@ bool fru_decode_6bit(const fru_field_t *field,
321320 */
322321static
323322bool fru_decode_bcdplus (const fru_field_t * field ,
324- uint8_t * out ,
325- size_t out_len )
323+ uint8_t * out ,
324+ size_t out_len )
326325{
327326 int i ;
328327 uint8_t c ;
@@ -369,8 +368,8 @@ bool fru_decode_bcdplus(const fru_field_t *field,
369368 */
370369static
371370bool fru_decode_binary (const fru_field_t * field ,
372- uint8_t * out ,
373- size_t out_len )
371+ uint8_t * out ,
372+ size_t out_len )
374373{
375374 int i ;
376375 uint8_t c ;
@@ -448,8 +447,8 @@ fru_field_t * fru_encode_data(int len, const uint8_t *data)
448447}
449448
450449bool fru_decode_data (fru_field_t * field ,
451- typed_field_t * out ,
452- size_t out_len )
450+ typed_field_t * out ,
451+ size_t out_len )
453452{
454453 if (!field ) return false;
455454
@@ -541,11 +540,11 @@ uint8_t fru_area_checksum(fru_info_area_t *area)
541540 */
542541static
543542fru_info_area_t * fru_create_info_area (fru_area_type_t atype , ///< [in] Area type (FRU_[CHASSIS|BOARD|PRODUCT]_INFO)
544- uint8_t langtype , ///< [in] Language code for areas that use it (board, product) or Chassis Type for chassis info area
545- const struct timeval * tv , ///< [in] Manufacturing time since the Epoch (1970/01/01 00:00:00 +0000 UTC) for areas that use it (board)
546- fru_reclist_t * fields , ///< [in] Single-linked list of data fields
547- size_t nstrings , ///< [in] Number of strings for mandatory fields
548- const typed_field_t strings []) ///<[in] Array of typed strings for mandatory fields
543+ uint8_t langtype , ///< [in] Language code for areas that use it (board, product) or Chassis Type for chassis info area
544+ const struct timeval * tv , ///< [in] Manufacturing time since the Epoch (1970/01/01 00:00:00 +0000 UTC) for areas that use it (board)
545+ fru_reclist_t * fields , ///< [in] Single-linked list of data fields
546+ size_t nstrings , ///< [in] Number of strings for mandatory fields
547+ const typed_field_t strings []) ///<[in] Array of typed strings for mandatory fields
549548{
550549 int i = 0 ;
551550 int field_count ;
@@ -768,13 +767,13 @@ bool fru_decode_chassis_info(
768767 fru_field_t * field = (fru_field_t * )data ;
769768
770769 if (!fru_decode_data (field , & chassis_out -> pn ,
771- sizeof (chassis_out -> pn .val )))
770+ sizeof (chassis_out -> pn .val )))
772771 return false;
773772
774773 data += FRU_FIELDSIZE (field -> typelen );
775774 field = (fru_field_t * )data ;
776775 if (!fru_decode_data (field , & chassis_out -> serial ,
777- sizeof (chassis_out -> serial .val )))
776+ sizeof (chassis_out -> serial .val )))
778777 return false;
779778 data += FRU_FIELDSIZE (field -> typelen );
780779
@@ -829,7 +828,7 @@ fru_board_area_t * fru_encode_board_info(const fru_exploded_board_t *board) ///<
829828}
830829
831830bool fru_decode_board_info (const fru_board_area_t * area ,
832- fru_exploded_board_t * board_out )
831+ fru_exploded_board_t * board_out )
833832{
834833 fru_field_t * field ;
835834 const uint8_t * data = area -> data ;
@@ -850,31 +849,31 @@ bool fru_decode_board_info(const fru_board_area_t *area,
850849
851850 field = (fru_field_t * )data ;
852851 if (!fru_decode_data (field , & board_out -> mfg ,
853- sizeof (board_out -> mfg .val )))
852+ sizeof (board_out -> mfg .val )))
854853 return false;
855854 data += FRU_FIELDSIZE (field -> typelen );
856855
857856 field = (fru_field_t * )data ;
858857 if (!fru_decode_data (field , & board_out -> pname ,
859- sizeof (board_out -> pname .val )))
858+ sizeof (board_out -> pname .val )))
860859 return false;
861860 data += FRU_FIELDSIZE (field -> typelen );
862861
863862 field = (fru_field_t * )data ;
864863 if (!fru_decode_data (field , & board_out -> serial ,
865- sizeof (board_out -> serial .val )))
864+ sizeof (board_out -> serial .val )))
866865 return false;
867866 data += FRU_FIELDSIZE (field -> typelen );
868867
869868 field = (fru_field_t * )data ;
870869 if (!fru_decode_data (field , & board_out -> pn ,
871- sizeof (board_out -> pn .val )))
870+ sizeof (board_out -> pn .val )))
872871 return false;
873872 data += FRU_FIELDSIZE (field -> typelen );
874873
875874 field = (fru_field_t * )data ;
876875 if (!fru_decode_data (field , & board_out -> file ,
877- sizeof (board_out -> file .val )))
876+ sizeof (board_out -> file .val )))
878877 return false;
879878 data += FRU_FIELDSIZE (field -> typelen );
880879
@@ -901,7 +900,7 @@ bool fru_decode_board_info(const fru_board_area_t *area,
901900 * @returns fru_info_area_t *area A newly allocated buffer containing the created area
902901 *
903902 */
904- fru_product_area_t * fru_product_info (const fru_exploded_product_t * product ) ///< [in] Exploded product information area
903+ fru_product_area_t * fru_encode_product_info (const fru_exploded_product_t * product ) ///< [in] Exploded product information area
905904{
906905 int i ;
907906
@@ -920,10 +919,11 @@ fru_product_area_t * fru_product_info(const fru_exploded_product_t *product) ///
920919 [FRU_PROD_FILE ] = { NULL , product -> cust },
921920 };
922921
923- const typed_field_t strings [] = { product -> mfg , product -> pname ,
924- product -> pn , product -> ver ,
925- product -> serial , product -> atag ,
926- product -> file };
922+ const typed_field_t strings [] = {
923+ product -> mfg , product -> pname ,
924+ product -> pn , product -> ver ,
925+ product -> serial , product -> atag ,
926+ product -> file };
927927 fru_product_area_t * out = NULL ;
928928
929929 out = fru_create_info_area (FRU_PRODUCT_INFO ,
@@ -1124,43 +1124,43 @@ bool fru_decode_product_info(
11241124
11251125 field = (fru_field_t * )data ;
11261126 if (!fru_decode_data (field , & product_out -> mfg ,
1127- sizeof (product_out -> mfg .val )))
1127+ sizeof (product_out -> mfg .val )))
11281128 return false;
11291129 data += FRU_FIELDSIZE (field -> typelen );
11301130
11311131 field = (fru_field_t * )data ;
11321132 if (!fru_decode_data (field , & product_out -> pname ,
1133- sizeof (product_out -> pname .val )))
1133+ sizeof (product_out -> pname .val )))
11341134 return false;
11351135 data += FRU_FIELDSIZE (field -> typelen );
11361136
11371137 field = (fru_field_t * )data ;
11381138 if (!fru_decode_data (field , & product_out -> pn ,
1139- sizeof (product_out -> pn .val )))
1139+ sizeof (product_out -> pn .val )))
11401140 return false;
11411141 data += FRU_FIELDSIZE (field -> typelen );
11421142
11431143 field = (fru_field_t * )data ;
11441144 if (!fru_decode_data (field , & product_out -> ver ,
1145- sizeof (product_out -> ver .val )))
1145+ sizeof (product_out -> ver .val )))
11461146 return false;
11471147 data += FRU_FIELDSIZE (field -> typelen );
11481148
11491149 field = (fru_field_t * )data ;
11501150 if (!fru_decode_data (field , & product_out -> serial ,
1151- sizeof (product_out -> serial .val )))
1151+ sizeof (product_out -> serial .val )))
11521152 return false;
11531153 data += FRU_FIELDSIZE (field -> typelen );
11541154
11551155 field = (fru_field_t * )data ;
11561156 if (!fru_decode_data (field , & product_out -> atag ,
1157- sizeof (product_out -> atag .val )))
1157+ sizeof (product_out -> atag .val )))
11581158 return false;
11591159 data += FRU_FIELDSIZE (field -> typelen );
11601160
11611161 field = (fru_field_t * )data ;
11621162 if (!fru_decode_data (field , & product_out -> file ,
1163- sizeof (product_out -> file .val )))
1163+ sizeof (product_out -> file .val )))
11641164 return false;
11651165 data += FRU_FIELDSIZE (field -> typelen );
11661166
@@ -1211,7 +1211,7 @@ fru_t * fru_create(fru_area_t area[FRU_MAX_AREAS], size_t *size)
12111211 if (!data || // No data is provided or
12121212 !FRU_AREA_HAS_SIZE (atype ) && !blocks || // no size is given for a non-sized area or
12131213 !((fru_info_area_t * )data )-> blocks // the sized area contains a zero size
1214- ) {
1214+ ) {
12151215 // Mark the area as
12161216 * offset = 0 ;
12171217 continue ;
@@ -1248,8 +1248,7 @@ fru_t * fru_create(fru_area_t area[FRU_MAX_AREAS], size_t *size)
12481248 if (!blocks ) continue ;
12491249
12501250 DEBUG ("copying %d bytes of area of type %d to offset 0x%03X (0x%03lX)\n" ,
1251- FRU_BYTES (blocks ), atype , FRU_BYTES (* offset ), dst - (uint8_t * )out
1252- );
1251+ FRU_BYTES (blocks ), atype , FRU_BYTES (* offset ), dst - (uint8_t * )out );
12531252 memcpy (dst , data , FRU_BYTES (blocks ));
12541253 }
12551254
@@ -1342,7 +1341,7 @@ void test_encodings(void)
13421341
13431342 for (i = 0 ; i < ARRAY_SZ (test_strings ); i ++ ) {
13441343 fru_field_t * field ;
1345- const unsigned char * out ;
1344+ const unsigned char out [ FRU_FIELDMAXARRAY ] ;
13461345
13471346 printf ("Data set %d.\n" , i );
13481347 printf ("Original data " );
0 commit comments