diff --git a/checks.c b/checks.c index ee96a25..11a4086 100644 --- a/checks.c +++ b/checks.c @@ -53,7 +53,7 @@ struct check { void *data; bool warn, error; enum checkstatus status; - int inprogress; + bool inprogress; int num_prereqs; struct check **prereq; }; @@ -141,9 +141,9 @@ static void check_nodes_props(struct check *c, struct node *dt, struct node *nod check_nodes_props(c, dt, child); } -static int run_check(struct check *c, struct node *dt) +static bool run_check(struct check *c, struct node *dt) { - int error = 0; + bool error = false; int i; assert(!c->inprogress); @@ -151,11 +151,11 @@ static int run_check(struct check *c, struct node *dt) if (c->status != UNCHECKED) goto out; - c->inprogress = 1; + c->inprogress = true; for (i = 0; i < c->num_prereqs; i++) { struct check *prq = c->prereq[i]; - error |= run_check(prq, dt); + error = error || run_check(prq, dt); if (prq->status != PASSED) { c->status = PREREQ; check_msg(c, "Failed prerequisite '%s'", @@ -177,9 +177,9 @@ static int run_check(struct check *c, struct node *dt) TRACE(c, "\tCompleted, status %d", c->status); out: - c->inprogress = 0; + c->inprogress = false; if ((c->status != PASSED) && (c->error)) - error = 1; + error = true; return error; } @@ -733,7 +733,7 @@ void parse_checks_option(bool warn, bool error, const char *optarg) die("Unrecognized check name \"%s\"\n", name); } -void process_checks(int force, struct boot_info *bi) +void process_checks(bool force, struct boot_info *bi) { struct node *dt = bi->dt; int i; diff --git a/data.c b/data.c index 4a40c5b..4c50b12 100644 --- a/data.c +++ b/data.c @@ -250,20 +250,20 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref) return data_append_markers(d, m); } -int data_is_one_string(struct data d) +bool data_is_one_string(struct data d) { int i; int len = d.len; if (len == 0) - return 0; + return false; for (i = 0; i < len-1; i++) if (d.val[i] == '\0') - return 0; + return false; if (d.val[len-1] != '\0') - return 0; + return false; - return 1; + return true; } diff --git a/dtc-lexer.l b/dtc-lexer.l index 3b41bfc..369407a 100644 --- a/dtc-lexer.l +++ b/dtc-lexer.l @@ -61,7 +61,7 @@ static int dts_version = 1; BEGIN(V1); \ static void push_input_file(const char *filename); -static int pop_input_file(void); +static bool pop_input_file(void); %} %% @@ -238,13 +238,13 @@ static void push_input_file(const char *filename) } -static int pop_input_file(void) +static bool pop_input_file(void) { if (srcfile_pop() == 0) - return 0; + return false; yypop_buffer_state(); yyin = current_srcfile->f; - return 1; + return true; } diff --git a/dtc-parser.y b/dtc-parser.y index f412460..4864631 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -31,7 +31,7 @@ extern void print_error(char const *fmt, ...); extern void yyerror(char const *s); extern struct boot_info *the_boot_info; -extern int treesource_error; +extern bool treesource_error; static unsigned long long eval_literal(const char *s, int base, int bits); static unsigned char eval_char_literal(const char *s); @@ -478,7 +478,7 @@ void print_error(char const *fmt, ...) srcpos_verror(&yylloc, fmt, va); va_end(va); - treesource_error = 1; + treesource_error = true; } void yyerror(char const *s) { diff --git a/dtc.c b/dtc.c index e3c9653..d36ccdc 100644 --- a/dtc.c +++ b/dtc.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) const char *outform = "dts"; const char *outname = "-"; const char *depname = NULL; - int force = 0, sort = 0; + bool force = false, sort = false; const char *arg; int opt; FILE *outf = NULL; @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) padsize = strtol(optarg, NULL, 0); break; case 'f': - force = 1; + force = true; break; case 'q': quiet++; @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) break; case 's': - sort = 1; + sort = true; break; case 'W': diff --git a/dtc.h b/dtc.h index 264a20c..20e4d56 100644 --- a/dtc.h +++ b/dtc.h @@ -118,7 +118,7 @@ struct data data_append_align(struct data d, int align); struct data data_add_marker(struct data d, enum markertype type, char *ref); -int data_is_one_string(struct data d); +bool data_is_one_string(struct data d); /* DT constraints */ @@ -127,13 +127,13 @@ int data_is_one_string(struct data d); /* Live trees */ struct label { - int deleted; + bool deleted; char *label; struct label *next; }; struct property { - int deleted; + bool deleted; char *name; struct data val; @@ -143,7 +143,7 @@ struct property { }; struct node { - int deleted; + bool deleted; char *name; struct property *proplist; struct node *children; @@ -248,7 +248,7 @@ void sort_tree(struct boot_info *bi); /* Checks */ void parse_checks_option(bool warn, bool error, const char *optarg); -void process_checks(int force, struct boot_info *bi); +void process_checks(bool force, struct boot_info *bi); /* Flattened trees */ diff --git a/flattree.c b/flattree.c index 665dad7..bd99fa2 100644 --- a/flattree.c +++ b/flattree.c @@ -261,7 +261,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, { struct property *prop; struct node *child; - int seen_name_prop = 0; + bool seen_name_prop = false; if (tree->deleted) return; @@ -279,7 +279,7 @@ static void flatten_tree(struct node *tree, struct emitter *emit, int nameoff; if (streq(prop->name, "name")) - seen_name_prop = 1; + seen_name_prop = true; nameoff = stringtable_insert(strbuf, prop->name); diff --git a/srcpos.c b/srcpos.c index c20bc53..294568b 100644 --- a/srcpos.c +++ b/srcpos.c @@ -159,7 +159,7 @@ void srcfile_push(const char *fname) current_srcfile = srcfile; } -int srcfile_pop(void) +bool srcfile_pop(void) { struct srcfile_state *srcfile = current_srcfile; @@ -177,7 +177,7 @@ int srcfile_pop(void) * fix this we could either allocate all the files from a * table, or use a pool allocator. */ - return current_srcfile ? 1 : 0; + return current_srcfile ? true : false; } void srcfile_add_search_path(const char *dirname) diff --git a/srcpos.h b/srcpos.h index 93a2712..57dfa0f 100644 --- a/srcpos.h +++ b/srcpos.h @@ -21,6 +21,7 @@ #define _SRCPOS_H_ #include +#include struct srcfile_state { FILE *f; @@ -55,7 +56,7 @@ extern struct srcfile_state *current_srcfile; /* = NULL */ FILE *srcfile_relative_open(const char *fname, char **fullnamep); void srcfile_push(const char *fname); -int srcfile_pop(void); +bool srcfile_pop(void); /** * Add a new directory to the search path for input files diff --git a/treesource.c b/treesource.c index 33eeba5..ffebb77 100644 --- a/treesource.c +++ b/treesource.c @@ -26,12 +26,12 @@ extern int yyparse(void); extern YYLTYPE yylloc; struct boot_info *the_boot_info; -int treesource_error; +bool treesource_error; struct boot_info *dt_from_source(const char *fname) { the_boot_info = NULL; - treesource_error = 0; + treesource_error = false; srcfile_push(fname); yyin = current_srcfile->f; @@ -54,7 +54,7 @@ static void write_prefix(FILE *f, int level) fputc('\t', f); } -static int isstring(char c) +static bool isstring(char c) { return (isprint(c) || (c == '\0') diff --git a/util.c b/util.c index e87d6c1..2347af9 100644 --- a/util.c +++ b/util.c @@ -70,7 +70,7 @@ char *join_path(const char *path, const char *name) return str; } -int util_is_printable_string(const void *data, int len) +bool util_is_printable_string(const void *data, int len) { const char *s = data; const char *ss, *se; diff --git a/util.h b/util.h index 8f40b44..ccfdf4b 100644 --- a/util.h +++ b/util.h @@ -2,6 +2,7 @@ #define _UTIL_H #include +#include #include /* @@ -68,7 +69,7 @@ extern char *join_path(const char *path, const char *name); * @param len The string length including terminator * @return 1 if a valid printable string, 0 if not */ -int util_is_printable_string(const void *data, int len); +bool util_is_printable_string(const void *data, int len); /* * Parse an escaped character starting at index i in string s. The resulting