Skip to content

Commit 9abaf70

Browse files
Matsievskiy S.VSergey Matsievskiy
authored andcommitted
Reindent files
1 parent f57e093 commit 9abaf70

File tree

2 files changed

+64
-65
lines changed

2 files changed

+64
-65
lines changed

fru.c

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
322321
static
323322
bool 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
*/
370369
static
371370
bool 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

450449
bool 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
*/
542541
static
543542
fru_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

831830
bool 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 ");

frugen.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ json_object_to_fd(int fd, struct json_object *obj, int flags)
202202
wpos = 0;
203203
while(wpos < wsize) {
204204
if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) {
205-
return -1;
205+
return -1;
206206
}
207207

208208
/* because of the above check for ret < 0, we can safely cast and add */
@@ -247,16 +247,16 @@ bool json_fill_fru_area_fields(json_object *jso, int count,
247247
debug(2, "Field %s '%s' (%s) loaded from JSON",
248248
fieldnames[i], val, type);
249249
data_in_this_area = true;
250-
} else {
250+
} else {
251251
const char *s = json_object_get_string(jsfield);
252252
debug(2, "Field %s '%s' loaded from JSON",
253253
fieldnames[i], s);
254254
fru_loadfield(fields[i]->val, s);
255255
fields[i]->type = FIELD_TYPE_AUTO;
256256
data_in_this_area = true;
257-
}
258-
}
259-
}
257+
}
258+
}
259+
}
260260

261261
return data_in_this_area;
262262
}
@@ -420,9 +420,9 @@ bool json_fill_fru_mr_reclist(json_object *jso, fru_mr_reclist_t **mr_reclist)
420420

421421
static
422422
int json_object_add_with_type(struct json_object* obj,
423-
const char* key,
424-
const unsigned char* val,
425-
int type) {
423+
const char* key,
424+
const unsigned char* val,
425+
int type) {
426426
struct json_object *string, *type_string, *entry;
427427
if ((string = json_object_new_string(val)) == NULL)
428428
goto STRING_ERR;
@@ -918,7 +918,7 @@ int main(int argc, char *argv[])
918918
}
919919
has_multirec = true;
920920

921-
switch(opt) {
921+
switch(opt) {
922922
case 'U': // UUID
923923
errno = fru_mr_uuid2rec(&mr_reclist_tail->rec, optarg);
924924
if (errno) {
@@ -970,7 +970,7 @@ int main(int argc, char *argv[])
970970
fru_reclist_t *next = chassis.cust;
971971
while (next != NULL) {
972972
json_object_add_with_type(temp_obj, NULL, next->rec->data,
973-
typelen2ind(next->rec->typelen));
973+
typelen2ind(next->rec->typelen));
974974
next = next->next;
975975
}
976976
json_object_object_add(section, "custom", temp_obj);
@@ -992,7 +992,7 @@ int main(int argc, char *argv[])
992992
fru_reclist_t *next = product.cust;
993993
while (next != NULL) {
994994
json_object_add_with_type(temp_obj, NULL, next->rec->data,
995-
typelen2ind(next->rec->typelen));
995+
typelen2ind(next->rec->typelen));
996996
next = next->next;
997997
}
998998
json_object_object_add(section, "custom", temp_obj);
@@ -1013,7 +1013,7 @@ int main(int argc, char *argv[])
10131013
fru_reclist_t *next = board.cust;
10141014
while (next != NULL) {
10151015
json_object_add_with_type(temp_obj, NULL, next->rec->data,
1016-
typelen2ind(next->rec->typelen));
1016+
typelen2ind(next->rec->typelen));
10171017
next = next->next;
10181018
}
10191019
json_object_object_add(section, "custom", temp_obj);
@@ -1185,11 +1185,11 @@ int main(int argc, char *argv[])
11851185

11861186
fd = open(fname,
11871187
#if __WIN32__ || __WIN64__
1188-
O_CREAT | O_TRUNC | O_WRONLY | O_BINARY,
1188+
O_CREAT | O_TRUNC | O_WRONLY | O_BINARY,
11891189
#else
1190-
O_CREAT | O_TRUNC | O_WRONLY,
1190+
O_CREAT | O_TRUNC | O_WRONLY,
11911191
#endif
1192-
0644);
1192+
0644);
11931193

11941194
if (fd < 0)
11951195
fatal("Couldn't create file %s: %m", fname);

0 commit comments

Comments
 (0)