cbfstool: Fix strange flashmap whitespace

This is being fixed in a separate commit so we can diff against the
library as it existed in its own repo.

Change-Id: Id87cd8f4e015a5ed7dd8a19302cc22ab744fefe8
Signed-off-by: Sol Boucher <solb@chromium.org>
Reviewed-on: http://review.coreboot.org/10141
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Sol Boucher 2015-05-07 16:41:46 -07:00 committed by Patrick Georgi
parent 65d9520e15
commit fa7a45524f
6 changed files with 73 additions and 73 deletions

View File

@ -76,8 +76,8 @@ static long int fmap_lsearch(const uint8_t *image, size_t len)
for (offset = 0; offset < len - strlen(FMAP_SIGNATURE); offset++) { for (offset = 0; offset < len - strlen(FMAP_SIGNATURE); offset++) {
if (!memcmp(&image[offset], if (!memcmp(&image[offset],
FMAP_SIGNATURE, FMAP_SIGNATURE,
strlen(FMAP_SIGNATURE))) { strlen(FMAP_SIGNATURE))) {
fmap_found = 1; fmap_found = 1;
break; break;
} }
@ -114,8 +114,8 @@ static long int fmap_bsearch(const uint8_t *image, size_t len)
if ((offset % (stride * 2) == 0) && (offset != 0)) if ((offset % (stride * 2) == 0) && (offset != 0))
continue; continue;
if (!memcmp(&image[offset], if (!memcmp(&image[offset],
FMAP_SIGNATURE, FMAP_SIGNATURE,
strlen(FMAP_SIGNATURE))) { strlen(FMAP_SIGNATURE))) {
fmap_found = 1; fmap_found = 1;
break; break;
} }
@ -163,19 +163,19 @@ int fmap_print(const struct fmap *fmap)
struct kv_pair *kv = NULL; struct kv_pair *kv = NULL;
const uint8_t *tmp; const uint8_t *tmp;
kv = kv_pair_new(); kv = kv_pair_new();
if (!kv) if (!kv)
return -1; return -1;
tmp = fmap->signature; tmp = fmap->signature;
kv_pair_fmt(kv, "fmap_signature", kv_pair_fmt(kv, "fmap_signature",
"0x%02x%02x%02x%02x%02x%02x%02x%02x", "0x%02x%02x%02x%02x%02x%02x%02x%02x",
tmp[0], tmp[1], tmp[2], tmp[3], tmp[0], tmp[1], tmp[2], tmp[3],
tmp[4], tmp[5], tmp[6], tmp[7]); tmp[4], tmp[5], tmp[6], tmp[7]);
kv_pair_fmt(kv, "fmap_ver_major", "%d", fmap->ver_major); kv_pair_fmt(kv, "fmap_ver_major", "%d", fmap->ver_major);
kv_pair_fmt(kv, "fmap_ver_minor","%d", fmap->ver_minor); kv_pair_fmt(kv, "fmap_ver_minor","%d", fmap->ver_minor);
kv_pair_fmt(kv, "fmap_base", "0x%016llx", kv_pair_fmt(kv, "fmap_base", "0x%016llx",
(unsigned long long)fmap->base); (unsigned long long)fmap->base);
kv_pair_fmt(kv, "fmap_size", "0x%04x", fmap->size); kv_pair_fmt(kv, "fmap_size", "0x%04x", fmap->size);
kv_pair_fmt(kv, "fmap_name", "%s", fmap->name); kv_pair_fmt(kv, "fmap_name", "%s", fmap->name);
kv_pair_fmt(kv, "fmap_nareas", "%d", fmap->nareas); kv_pair_fmt(kv, "fmap_nareas", "%d", fmap->nareas);
@ -241,14 +241,14 @@ int fmap_get_csum(const uint8_t *image, unsigned int image_len, uint8_t **digest
/* sanity check the offset */ /* sanity check the offset */
if (fmap->areas[i].size + fmap->areas[i].offset > image_len) { if (fmap->areas[i].size + fmap->areas[i].offset > image_len) {
fprintf(stderr, fprintf(stderr,
"(%s) invalid parameter detected in area %d\n", "(%s) invalid parameter detected in area %d\n",
__func__, i); __func__, i);
return -1; return -1;
} }
SHA_update(&ctx, SHA_update(&ctx,
image + fmap->areas[i].offset, image + fmap->areas[i].offset,
fmap->areas[i].size); fmap->areas[i].size);
} }
SHA_final(&ctx); SHA_final(&ctx);
@ -278,7 +278,7 @@ char *fmap_flags_to_string(uint16_t flags)
total_size += strlen(tmp); total_size += strlen(tmp);
str = realloc(str, total_size); str = realloc(str, total_size);
strcat(str, tmp); strcat(str, tmp);
flags &= ~(1 << i); flags &= ~(1 << i);
if (flags) { if (flags) {
total_size++; total_size++;
@ -318,8 +318,8 @@ void fmap_destroy(struct fmap *fmap) {
/* append area to existing structure, return new total size if successful */ /* append area to existing structure, return new total size if successful */
int fmap_append_area(struct fmap **fmap, int fmap_append_area(struct fmap **fmap,
uint32_t offset, uint32_t size, uint32_t offset, uint32_t size,
const uint8_t *name, uint16_t flags) const uint8_t *name, uint16_t flags)
{ {
struct fmap_area *area; struct fmap_area *area;
int orig_size, new_size; int orig_size, new_size;
@ -513,10 +513,10 @@ static int fmap_append_area_test(struct fmap **fmap)
total_size = sizeof(**fmap) + sizeof(test_area); total_size = sizeof(**fmap) + sizeof(test_area);
if (fmap_append_area(fmap, if (fmap_append_area(fmap,
test_area.offset, test_area.offset,
test_area.size, test_area.size,
test_area.name, test_area.name,
test_area.flags test_area.flags
) != total_size) { ) != total_size) {
printf("failed to append area\n"); printf("failed to append area\n");
goto fmap_append_area_test_exit; goto fmap_append_area_test_exit;
@ -618,7 +618,7 @@ static int fmap_find_test(struct fmap *fmap)
status = fail; status = fail;
/* /*
* Note: In these tests, we'll use fmap_find() and control usage of * Note: In these tests, we'll use fmap_find() and control usage of
* lsearch and bsearch by using a power-of-2 total_size. For lsearch, * lsearch and bsearch by using a power-of-2 total_size. For lsearch,
* use total_size - 1. For bsearch, use total_size. * use total_size - 1. For bsearch, use total_size.
*/ */

View File

@ -54,10 +54,10 @@ enum fmap_flags {
/* Mapping of volatile and static regions in firmware binary */ /* Mapping of volatile and static regions in firmware binary */
struct fmap_area { struct fmap_area {
uint32_t offset; /* offset relative to base */ uint32_t offset; /* offset relative to base */
uint32_t size; /* size in bytes */ uint32_t size; /* size in bytes */
uint8_t name[FMAP_STRLEN]; /* descriptive name */ uint8_t name[FMAP_STRLEN]; /* descriptive name */
uint16_t flags; /* flags for this area */ uint16_t flags; /* flags for this area */
} __attribute__((packed)); } __attribute__((packed));
struct fmap { struct fmap {
@ -111,7 +111,7 @@ extern int fmap_print(const struct fmap *map);
* returns <0 to indicate error * returns <0 to indicate error
*/ */
extern int fmap_get_csum(const uint8_t *image, extern int fmap_get_csum(const uint8_t *image,
unsigned int image_len, uint8_t **digest); unsigned int image_len, uint8_t **digest);
/* /*
@ -144,7 +144,7 @@ char *fmap_flags_to_string(uint16_t flags);
* returns NULL to indicate failure * returns NULL to indicate failure
*/ */
extern struct fmap *fmap_create(uint64_t base, extern struct fmap *fmap_create(uint64_t base,
uint32_t size, uint8_t *name); uint32_t size, uint8_t *name);
/* free memory used by an fmap structure */ /* free memory used by an fmap structure */
extern void fmap_destroy(struct fmap *fmap); extern void fmap_destroy(struct fmap *fmap);
@ -172,8 +172,8 @@ extern int fmap_size(struct fmap *fmap);
* returns <0 to indicate failure * returns <0 to indicate failure
*/ */
extern int fmap_append_area(struct fmap **fmap, extern int fmap_append_area(struct fmap **fmap,
uint32_t offset, uint32_t size, uint32_t offset, uint32_t size,
const uint8_t *name, uint16_t flags); const uint8_t *name, uint16_t flags);
/* /*
* fmap_find_area - find an fmap_area entry (by name) and return pointer to it * fmap_find_area - find an fmap_area entry (by name) and return pointer to it

View File

@ -76,7 +76,7 @@ struct kv_pair **kv_pair_new_array(size_t size)
} }
struct kv_pair *kv_pair_add(struct kv_pair *kv_list, struct kv_pair *kv_pair_add(struct kv_pair *kv_list,
const char *key, const char *value) const char *key, const char *value)
{ {
struct kv_pair *kv_new; struct kv_pair *kv_new;
struct kv_pair *kv_ptr; struct kv_pair *kv_ptr;
@ -117,7 +117,7 @@ kv_pair_add_failed:
} }
struct kv_pair *kv_pair_add_bool(struct kv_pair *kv_list, struct kv_pair *kv_pair_add_bool(struct kv_pair *kv_list,
const char *key, int value) const char *key, int value)
{ {
const char *str; const char *str;
@ -130,7 +130,7 @@ struct kv_pair *kv_pair_add_bool(struct kv_pair *kv_list,
} }
struct kv_pair *kv_pair_fmt(struct kv_pair *kv_list, struct kv_pair *kv_pair_fmt(struct kv_pair *kv_list,
const char *kv_key, const char *format, ...) const char *kv_key, const char *format, ...)
{ {
char kv_value[KV_PAIR_MAX_VALUE_LEN]; char kv_value[KV_PAIR_MAX_VALUE_LEN];
va_list vptr; va_list vptr;
@ -173,7 +173,7 @@ void kv_pair_free_array(struct kv_pair **kv_array, size_t size)
} }
void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list, void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list,
enum kv_pair_style style) enum kv_pair_style style)
{ {
struct kv_pair *kv_ptr; struct kv_pair *kv_ptr;
@ -182,7 +182,7 @@ void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list,
for (kv_ptr = kv_list; kv_ptr != NULL; kv_ptr = kv_ptr->next) { for (kv_ptr = kv_list; kv_ptr != NULL; kv_ptr = kv_ptr->next) {
if (kv_ptr->key && kv_ptr->value) { if (kv_ptr->key && kv_ptr->value) {
fprintf(fp, "%s=\"%s\" ", fprintf(fp, "%s=\"%s\" ",
kv_ptr->key, kv_ptr->value); kv_ptr->key, kv_ptr->value);
} }
} }
break; break;
@ -201,7 +201,7 @@ void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list,
for (kv_ptr = kv_list; kv_ptr != NULL; kv_ptr = kv_ptr->next) { for (kv_ptr = kv_list; kv_ptr != NULL; kv_ptr = kv_ptr->next) {
if (kv_ptr->key && kv_ptr->value) if (kv_ptr->key && kv_ptr->value)
fprintf(fp, "%-20s | %s\n", fprintf(fp, "%-20s | %s\n",
kv_ptr->key, kv_ptr->value); kv_ptr->key, kv_ptr->value);
} }
break; break;
} }

View File

@ -41,13 +41,13 @@
#include <string.h> #include <string.h>
/* key=value string pair list */ /* key=value string pair list */
#define KV_PAIR_MAX_VALUE_LEN 1024 #define KV_PAIR_MAX_VALUE_LEN 1024
enum kv_pair_style { enum kv_pair_style {
KV_STYLE_PAIR, /* key1="value1" key2="value2" */ KV_STYLE_PAIR, /* key1="value1" key2="value2" */
KV_STYLE_VALUE, /* | value1 | value2 | */ KV_STYLE_VALUE, /* | value1 | value2 | */
KV_STYLE_LONG, /* key1 | value1 */ KV_STYLE_LONG, /* key1 | value1 */
/* key2 | value2 */ /* key2 | value2 */
}; };
struct kv_pair { struct kv_pair {
@ -61,7 +61,7 @@ extern enum kv_pair_style kv_pair_get_style();
extern void kv_pair_set_style(enum kv_pair_style style); extern void kv_pair_set_style(enum kv_pair_style style);
/* /*
* kv_pair_new - create new key=value pair * kv_pair_new - create new key=value pair
* *
* returns pointer to new key=value pair * returns pointer to new key=value pair
* returns NULL to indicate error * returns NULL to indicate error
@ -69,67 +69,67 @@ extern void kv_pair_set_style(enum kv_pair_style style);
extern struct kv_pair *kv_pair_new(void); extern struct kv_pair *kv_pair_new(void);
/* /*
* kv_pair_add - add new key=value pair to list * kv_pair_add - add new key=value pair to list
* *
* @kv_list: key=value pair list * @kv_list: key=value pair list
* @key: key string * @key: key string
* @value: value string * @value: value string
* *
* returns pointer to new key=value pair * returns pointer to new key=value pair
* returns NULL to indicate error * returns NULL to indicate error
*/ */
extern struct kv_pair *kv_pair_add(struct kv_pair *kv_list, extern struct kv_pair *kv_pair_add(struct kv_pair *kv_list,
const char *key, const char *value); const char *key, const char *value);
/* /*
* kv_pair_add_bool - add new boolean kvpair to list * kv_pair_add_bool - add new boolean kvpair to list
* *
* @kv_list: key=value pair list * @kv_list: key=value pair list
* @key: key string * @key: key string
* @value: value * @value: value
* *
* returns pointer to new key=value pair * returns pointer to new key=value pair
* returns NULL to indicate error * returns NULL to indicate error
*/ */
extern struct kv_pair *kv_pair_add_bool(struct kv_pair *kv_list, extern struct kv_pair *kv_pair_add_bool(struct kv_pair *kv_list,
const char *key, int value); const char *key, int value);
/* /*
* kv_pair_fmt - add key=value pair based on printf format * kv_pair_fmt - add key=value pair based on printf format
* NOTE: uses variable argument list * NOTE: uses variable argument list
* *
* @kv_list: list of key=value pairs * @kv_list: list of key=value pairs
* @kv_key: key string * @kv_key: key string
* @format: printf-style format for value input * @format: printf-style format for value input
* @...: arguments to format * @...: arguments to format
* *
* returns pointer to new key=value pair * returns pointer to new key=value pair
* returns NULL to indicate error * returns NULL to indicate error
*/ */
extern struct kv_pair *kv_pair_fmt(struct kv_pair *kv_list, extern struct kv_pair *kv_pair_fmt(struct kv_pair *kv_list,
const char *kv_key, const char *format, ...) const char *kv_key, const char *format, ...)
__attribute__((format(printf, 3, 4))); __attribute__((format(printf, 3, 4)));
/* /*
* kv_pair_free - clean a key=value pair list * kv_pair_free - clean a key=value pair list
* *
* @kv_list: pointer to key=value list * @kv_list: pointer to key=value list
*/ */
extern void kv_pair_free(struct kv_pair *kv_list); extern void kv_pair_free(struct kv_pair *kv_list);
/* /*
* kv_pair_print - print a key=value pair list * kv_pair_print - print a key=value pair list
* *
* @kv_list: pointer to key=value list * @kv_list: pointer to key=value list
* @style: print style * @style: print style
*/ */
extern void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list, extern void kv_pair_print_to_file(FILE* fp, struct kv_pair *kv_list,
enum kv_pair_style style); enum kv_pair_style style);
/* /*
* kv_pair_print - print a key=value pair list to gsys output * kv_pair_print - print a key=value pair list to gsys output
* *
* @kv_list: pointer to key=value list * @kv_list: pointer to key=value list
*/ */
extern void kv_pair_print(struct kv_pair *kv_list); extern void kv_pair_print(struct kv_pair *kv_list);
@ -137,16 +137,16 @@ extern void kv_pair_print(struct kv_pair *kv_list);
/* /*
* kv_pair_get_value - return first value with key match * kv_pair_get_value - return first value with key match
* *
* @kv_list: pointer to key=value list * @kv_list: pointer to key=value list
* @kv_key: key string * @kv_key: key string
*/ */
extern const char *kv_pair_get_value(struct kv_pair *kv_list, extern const char *kv_pair_get_value(struct kv_pair *kv_list,
const char *kv_key); const char *kv_key);
/* /*
* kv_pair_size - return number of kv pairs in the chain * kv_pair_size - return number of kv pairs in the chain
* *
* @kv_list: pointer to key=value list * @kv_list: pointer to key=value list
*/ */
extern int kv_pair_size(struct kv_pair *kv_list); extern int kv_pair_size(struct kv_pair *kv_list);

View File

@ -35,7 +35,7 @@
#include <valstr.h> #include <valstr.h>
const char *val2str_default(uint32_t val, const struct valstr *vs, const char *val2str_default(uint32_t val, const struct valstr *vs,
const char *def_str) const char *def_str)
{ {
int i; int i;

View File

@ -43,21 +43,21 @@ struct valstr {
/* /*
* val2str_default - convert value to string * val2str_default - convert value to string
* *
* @val: value to convert * @val: value to convert
* @vs: value-string data * @vs: value-string data
* @def_str: default string to return if no matching value found * @def_str: default string to return if no matching value found
* *
* returns pointer to string * returns pointer to string
* returns def_str if no matching value found * returns def_str if no matching value found
*/ */
const char *val2str_default(uint32_t val, const struct valstr *vs, const char *val2str_default(uint32_t val, const struct valstr *vs,
const char *def_str); const char *def_str);
/* /*
* val2str - convert value to string * val2str - convert value to string
* *
* @val: value to convert * @val: value to convert
* @vs: value-string data * @vs: value-string data
* *
* returns pointer to string * returns pointer to string
* returns pointer to "unknown" static string if not found * returns pointer to "unknown" static string if not found
@ -67,8 +67,8 @@ const char *val2str(uint32_t val, const struct valstr *vs);
/* /*
* str2val - convert string to value * str2val - convert string to value
* *
* @str: string to convert * @str: string to convert
* @vs: value-string data * @vs: value-string data
* *
* returns value for string * returns value for string
* returns value for last entry in value-string data if not found * returns value for last entry in value-string data if not found