* [PATCH] Microsoft Visual C patches @ 2014-06-15 15:46 Andrei Errapart [not found] ` <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Andrei Errapart @ 2014-06-15 15:46 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 885 bytes --] Hallo, The attached patches are the result of compiling the dtc with the Microsoft Visual C (MSVC) in order to be able to run the dtc under Microsoft Windows. Short descriptions of the patches: checks: MSVC is unable to handle 0-sized array literals. fopen: Binary files should be opened in binary mode. signed-char: For MSVC, char defaults to signed char. dtc-header: 1) Variadic macro in the form "args..." is a GCC extension. 2) MSVC requires 0 to be present in a struct literal. On a Linux, all tests pass when these patches have been applied. We have been using the dtc on Windows computers for a few days and haven't had any problems so far. In the case people are interested in having the MSVC project file(s) and the few lightweight compatibility functions required for compilation, let me know and I can clean them up for public use. best regards, Andrei [-- Attachment #2: checks.patch --] [-- Type: text/plain, Size: 5687 bytes --] diff --git a/checks.c b/checks.c index 47eda65..cf07864 100644 --- a/checks.c +++ b/checks.c @@ -61,17 +61,19 @@ struct check { #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ static struct check nm = { \ - .name = #nm, \ - .tree_fn = (tfn), \ - .node_fn = (nfn), \ - .prop_fn = (pfn), \ - .data = (d), \ - .warn = (w), \ - .error = (e), \ - .status = UNCHECKED, \ - .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ - .prereq = nm##_prereqs, \ + #nm, \ + (tfn), \ + (nfn), \ + (pfn), \ + (d), \ + (w), \ + (e), \ + UNCHECKED, \ + false, \ + ARRAY_SIZE(nm##_prereqs), \ + nm##_prereqs \ }; + #define WARNING(nm, tfn, nfn, pfn, d, ...) \ CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) #define ERROR(nm, tfn, nfn, pfn, d, ...) \ @@ -153,7 +155,7 @@ static bool run_check(struct check *c, struct node *dt) c->inprogress = true; - for (i = 0; i < c->num_prereqs; i++) { + for (i = 0; i < c->num_prereqs && c->prereq[i]!=NULL; i++) { struct check *prq = c->prereq[i]; error = error || run_check(prq, dt); if (prq->status != PASSED) { @@ -192,7 +194,7 @@ static inline void check_always_fail(struct check *c, struct node *dt) { FAIL(c, "always_fail check"); } -TREE_CHECK(always_fail, NULL); +TREE_CHECK(always_fail, NULL, 0); static void check_is_string(struct check *c, struct node *root, struct node *node) @@ -209,9 +211,9 @@ static void check_is_string(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_STRING(nm, propname) \ - WARNING(nm, NULL, check_is_string, NULL, (propname)) + WARNING(nm, NULL, check_is_string, NULL, (propname), 0) #define ERROR_IF_NOT_STRING(nm, propname) \ - ERROR(nm, NULL, check_is_string, NULL, (propname)) + ERROR(nm, NULL, check_is_string, NULL, (propname), 0) static void check_is_cell(struct check *c, struct node *root, struct node *node) @@ -228,9 +230,9 @@ static void check_is_cell(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_CELL(nm, propname) \ - WARNING(nm, NULL, check_is_cell, NULL, (propname)) + WARNING(nm, NULL, check_is_cell, NULL, (propname), 0) #define ERROR_IF_NOT_CELL(nm, propname) \ - ERROR(nm, NULL, check_is_cell, NULL, (propname)) + ERROR(nm, NULL, check_is_cell, NULL, (propname), 0) /* * Structural check functions @@ -249,7 +251,7 @@ static void check_duplicate_node_names(struct check *c, struct node *dt, FAIL(c, "Duplicate node name %s", child->fullpath); } -NODE_ERROR(duplicate_node_names, NULL); +NODE_ERROR(duplicate_node_names, NULL, 0); static void check_duplicate_property_names(struct check *c, struct node *dt, struct node *node) @@ -266,7 +268,7 @@ static void check_duplicate_property_names(struct check *c, struct node *dt, } } } -NODE_ERROR(duplicate_property_names, NULL); +NODE_ERROR(duplicate_property_names, NULL, 0); #define LOWERCASE "abcdefghijklmnopqrstuvwxyz" #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -282,7 +284,7 @@ static void check_node_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in node %s", node->name[n], node->fullpath); } -NODE_ERROR(node_name_chars, PROPNODECHARS "@"); +NODE_ERROR(node_name_chars, PROPNODECHARS "@", 0); static void check_node_name_format(struct check *c, struct node *dt, struct node *node) @@ -302,7 +304,7 @@ static void check_property_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in property name \"%s\", node %s", prop->name[n], prop->name, node->fullpath); } -PROP_ERROR(property_name_chars, PROPNODECHARS); +PROP_ERROR(property_name_chars, PROPNODECHARS, 0); #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ @@ -358,7 +360,7 @@ static void check_duplicate_label_prop(struct check *c, struct node *dt, check_duplicate_label(c, dt, m->ref, node, prop, m); } ERROR(duplicate_label, NULL, check_duplicate_label_node, - check_duplicate_label_prop, NULL); + check_duplicate_label_prop, NULL, 0); static void check_explicit_phandles(struct check *c, struct node *root, struct node *node, struct property *prop) @@ -417,7 +419,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, node->phandle = phandle; } -PROP_ERROR(explicit_phandles, NULL); +PROP_ERROR(explicit_phandles, NULL, 0); static void check_name_properties(struct check *c, struct node *root, struct node *node) @@ -649,7 +651,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, FAIL(c, "/chosen has obsolete \"interrupt-controller\" " "property"); } -TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); +TREE_WARNING(obsolete_chosen_interrupt_controller, NULL, 0); static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, @@ -678,7 +680,7 @@ static void enable_warning_error(struct check *c, bool warn, bool error) /* Raising level, also raise it for prereqs */ if ((warn && !c->warn) || (error && !c->error)) - for (i = 0; i < c->num_prereqs; i++) + for (i = 0; i < c->num_prereqs && c->prereq[i] != NULL; i++) enable_warning_error(c->prereq[i], warn, error); c->warn = c->warn || warn; @@ -696,7 +698,7 @@ static void disable_warning_error(struct check *c, bool warn, bool error) struct check *cc = check_table[i]; int j; - for (j = 0; j < cc->num_prereqs; j++) + for (j = 0; j < cc->num_prereqs && cc->prereq[j] != NULL; j++) if (cc->prereq[j] == c) disable_warning_error(cc, warn, error); } [-- Attachment #3: fopen.patch --] [-- Type: text/plain, Size: 1055 bytes --] diff --git a/fstree.c b/fstree.c index 4d2791c..6d1beec 100644 --- a/fstree.c +++ b/fstree.c @@ -52,7 +52,7 @@ static struct node *read_fstree(const char *dirname) struct property *prop; FILE *pfile; - pfile = fopen(tmpname, "r"); + pfile = fopen(tmpname, "rb"); if (! pfile) { fprintf(stderr, "WARNING: Cannot open %s: %s\n", diff --git a/srcpos.c b/srcpos.c index 4549773..f534c22 100644 --- a/srcpos.c +++ b/srcpos.c @@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp) else fullname = join_path(dirname, fname); - *fp = fopen(fullname, "r"); + *fp = fopen(fullname, "rb"); if (!*fp) { free(fullname); fullname = NULL; diff --git a/dtc.c b/dtc.c index d36ccdc..e3665b6 100644 --- a/dtc.c +++ b/dtc.c @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) if (streq(outname, "-")) { outf = stdout; } else { - outf = fopen(outname, "w"); + outf = fopen(outname, "wb"); if (! outf) die("Couldn't open output file %s: %s\n", outname, strerror(errno)); [-- Attachment #4: signed-char.patch --] [-- Type: text/plain, Size: 359 bytes --] diff --git a/treesource.c b/treesource.c index bf7a626..2386b93 100644 --- a/treesource.c +++ b/treesource.c @@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val) m = m->next; } - fprintf(f, "%02hhx", *bp++); + fprintf(f, "%02hhx", (unsigned char)(*bp++)); if ((const void *)bp >= propend) break; fprintf(f, " "); [-- Attachment #5: dtc-header.patch --] [-- Type: text/plain, Size: 561 bytes --] diff --git a/dtc.h b/dtc.h index 20de073..a9d1775 100644 --- a/dtc.h +++ b/dtc.h @@ -38,9 +38,9 @@ #include "util.h" #ifdef DEBUG -#define debug(fmt,args...) printf(fmt, ##args) +#define debug(...) printf(__VA_ARGS__) #else -#define debug(fmt,args...) +#define debug(...) #endif @@ -87,8 +87,7 @@ struct data { struct marker *markers; }; - -#define empty_data ((struct data){ /* all .members = 0 or NULL */ }) +#define empty_data ((struct data){ 0 /* all .members = 0 or NULL */ }) #define for_each_marker(m) \ for (; (m); (m) = (m)->next) ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>]
* Re: [PATCH] Microsoft Visual C patches [not found] ` <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> @ 2014-06-16 10:46 ` David Gibson [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: David Gibson @ 2014-06-16 10:46 UTC (permalink / raw) To: Andrei Errapart; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 4537 bytes --] On Sun, Jun 15, 2014 at 06:46:16PM +0300, Andrei Errapart wrote: > Hallo, > > > The attached patches are the result of compiling the dtc with the Microsoft > Visual C (MSVC) in order to be able to run the dtc under Microsoft > Windows. Ok, so, in order to apply these, I'll need them one by one, with their own commit messages and Signed-off-by lines. > > Short descriptions of the patches: > checks: MSVC is unable to handle 0-sized array literals. > fopen: Binary files should be opened in binary mode. > signed-char: For MSVC, char defaults to signed char. > dtc-header: > 1) Variadic macro in the form "args..." is a GCC extension. > 2) MSVC requires 0 to be present in a struct literal. > > On a Linux, all tests pass when these patches have been applied. > > We have been using the dtc on Windows computers for a few days and haven't > had any problems so far. In the case people are interested in having the > MSVC project file(s) and the few lightweight compatibility functions > required for compilation, let me know and I can clean them up for public > use. > > > best regards, > Andrei > diff --git a/checks.c b/checks.c > index 47eda65..cf07864 100644 > --- a/checks.c > +++ b/checks.c > @@ -61,17 +61,19 @@ struct check { > #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ > static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ > static struct check nm = { \ > - .name = #nm, \ > - .tree_fn = (tfn), \ > - .node_fn = (nfn), \ > - .prop_fn = (pfn), \ > - .data = (d), \ > - .warn = (w), \ > - .error = (e), \ > - .status = UNCHECKED, \ > - .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ > - .prereq = nm##_prereqs, \ > + #nm, \ > + (tfn), \ > + (nfn), \ > + (pfn), \ > + (d), \ > + (w), \ > + (e), \ > + UNCHECKED, \ > + false, \ > + ARRAY_SIZE(nm##_prereqs), \ > + nm##_prereqs \ Um.. I don't see what removing the C99 initializers has to do with MSVC not supporting 0 size arrays > }; > + Please don't include unrelated whitespace changes. > #define WARNING(nm, tfn, nfn, pfn, d, ...) \ > CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) > #define ERROR(nm, tfn, nfn, pfn, d, ...) \ > @@ -153,7 +155,7 @@ static bool run_check(struct check *c, struct node *dt) > > c->inprogress = true; > > - for (i = 0; i < c->num_prereqs; i++) { > + for (i = 0; i < c->num_prereqs && c->prereq[i]!=NULL; i++) { Hrm. I think I see what you're doing here, but it's kinda subtle. Without a comment, I think someone's very likely to take it out again. [snip] > diff --git a/fstree.c b/fstree.c > index 4d2791c..6d1beec 100644 > --- a/fstree.c > +++ b/fstree.c > @@ -52,7 +52,7 @@ static struct node *read_fstree(const char *dirname) > struct property *prop; > FILE *pfile; > > - pfile = fopen(tmpname, "r"); > + pfile = fopen(tmpname, "rb"); > if (! pfile) { > fprintf(stderr, > "WARNING: Cannot open %s: %s\n", > diff --git a/srcpos.c b/srcpos.c > index 4549773..f534c22 100644 > --- a/srcpos.c > +++ b/srcpos.c > @@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp) > else > fullname = join_path(dirname, fname); > > - *fp = fopen(fullname, "r"); > + *fp = fopen(fullname, "rb"); > if (!*fp) { > free(fullname); > fullname = NULL; > diff --git a/dtc.c b/dtc.c > index d36ccdc..e3665b6 100644 > --- a/dtc.c > +++ b/dtc.c > @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) > if (streq(outname, "-")) { > outf = stdout; > } else { > - outf = fopen(outname, "w"); > + outf = fopen(outname, "wb"); > if (! outf) > die("Couldn't open output file %s: %s\n", > outname, strerror(errno)); The fopen() mode patch I'm happy to take once it's sent with its own comment and signed-off-by lines. > diff --git a/treesource.c b/treesource.c > index bf7a626..2386b93 100644 > --- a/treesource.c > +++ b/treesource.c > @@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val) > m = m->next; > } > > - fprintf(f, "%02hhx", *bp++); > + fprintf(f, "%02hhx", (unsigned char)(*bp++)); > if ((const void *)bp >= propend) > break; > fprintf(f, " "); Likewise the unsigned char patch. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org>]
* Re: [PATCH] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> @ 2014-06-17 17:18 ` Matthew Gerlach 2014-06-18 17:01 ` [PATCH 1/4] " Andrei Errapart ` (4 subsequent siblings) 5 siblings, 0 replies; 13+ messages in thread From: Matthew Gerlach @ 2014-06-17 17:18 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA Hi Andrei, Your patches are very timely for us. We were wondering how to compile dtc for Windows. We look forward to your resubmissions being accepted. Thanks, Matthew Gerlach On Mon, Jun 16, 2014 at 3:46 AM, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote: > On Sun, Jun 15, 2014 at 06:46:16PM +0300, Andrei Errapart wrote: >> Hallo, >> >> >> The attached patches are the result of compiling the dtc with the Microsoft >> Visual C (MSVC) in order to be able to run the dtc under Microsoft >> Windows. > > Ok, so, in order to apply these, I'll need them one by one, with their > own commit messages and Signed-off-by lines. > >> >> Short descriptions of the patches: >> checks: MSVC is unable to handle 0-sized array literals. >> fopen: Binary files should be opened in binary mode. >> signed-char: For MSVC, char defaults to signed char. >> dtc-header: >> 1) Variadic macro in the form "args..." is a GCC extension. >> 2) MSVC requires 0 to be present in a struct literal. >> >> On a Linux, all tests pass when these patches have been applied. >> >> We have been using the dtc on Windows computers for a few days and haven't >> had any problems so far. In the case people are interested in having the >> MSVC project file(s) and the few lightweight compatibility functions >> required for compilation, let me know and I can clean them up for public >> use. >> >> >> best regards, >> Andrei > >> diff --git a/checks.c b/checks.c >> index 47eda65..cf07864 100644 >> --- a/checks.c >> +++ b/checks.c >> @@ -61,17 +61,19 @@ struct check { >> #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ >> static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ >> static struct check nm = { \ >> - .name = #nm, \ >> - .tree_fn = (tfn), \ >> - .node_fn = (nfn), \ >> - .prop_fn = (pfn), \ >> - .data = (d), \ >> - .warn = (w), \ >> - .error = (e), \ >> - .status = UNCHECKED, \ >> - .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ >> - .prereq = nm##_prereqs, \ >> + #nm, \ >> + (tfn), \ >> + (nfn), \ >> + (pfn), \ >> + (d), \ >> + (w), \ >> + (e), \ >> + UNCHECKED, \ >> + false, \ >> + ARRAY_SIZE(nm##_prereqs), \ >> + nm##_prereqs \ > > Um.. I don't see what removing the C99 initializers has to do with > MSVC not supporting 0 size arrays > >> }; >> + > > Please don't include unrelated whitespace changes. > >> #define WARNING(nm, tfn, nfn, pfn, d, ...) \ >> CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) >> #define ERROR(nm, tfn, nfn, pfn, d, ...) \ >> @@ -153,7 +155,7 @@ static bool run_check(struct check *c, struct node *dt) >> >> c->inprogress = true; >> >> - for (i = 0; i < c->num_prereqs; i++) { >> + for (i = 0; i < c->num_prereqs && c->prereq[i]!=NULL; i++) { > > Hrm. I think I see what you're doing here, but it's kinda subtle. > Without a comment, I think someone's very likely to take it out again. > > [snip] > >> diff --git a/fstree.c b/fstree.c >> index 4d2791c..6d1beec 100644 >> --- a/fstree.c >> +++ b/fstree.c >> @@ -52,7 +52,7 @@ static struct node *read_fstree(const char *dirname) >> struct property *prop; >> FILE *pfile; >> >> - pfile = fopen(tmpname, "r"); >> + pfile = fopen(tmpname, "rb"); >> if (! pfile) { >> fprintf(stderr, >> "WARNING: Cannot open %s: %s\n", >> diff --git a/srcpos.c b/srcpos.c >> index 4549773..f534c22 100644 >> --- a/srcpos.c >> +++ b/srcpos.c >> @@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp) >> else >> fullname = join_path(dirname, fname); >> >> - *fp = fopen(fullname, "r"); >> + *fp = fopen(fullname, "rb"); >> if (!*fp) { >> free(fullname); >> fullname = NULL; >> diff --git a/dtc.c b/dtc.c >> index d36ccdc..e3665b6 100644 >> --- a/dtc.c >> +++ b/dtc.c >> @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) >> if (streq(outname, "-")) { >> outf = stdout; >> } else { >> - outf = fopen(outname, "w"); >> + outf = fopen(outname, "wb"); >> if (! outf) >> die("Couldn't open output file %s: %s\n", >> outname, strerror(errno)); > > The fopen() mode patch I'm happy to take once it's sent with its own > comment and signed-off-by lines. > >> diff --git a/treesource.c b/treesource.c >> index bf7a626..2386b93 100644 >> --- a/treesource.c >> +++ b/treesource.c >> @@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val) >> m = m->next; >> } >> >> - fprintf(f, "%02hhx", *bp++); >> + fprintf(f, "%02hhx", (unsigned char)(*bp++)); >> if ((const void *)bp >= propend) >> break; >> fprintf(f, " "); > > Likewise the unsigned char patch. > > -- > David Gibson | I'll have my music baroque, and my code > david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ > | _way_ _around_! > http://www.ozlabs.org/~dgibson -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 2014-06-17 17:18 ` Matthew Gerlach @ 2014-06-18 17:01 ` Andrei Errapart [not found] ` <53A1C5FC.9040105-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 2014-06-18 17:02 ` [PATCH 2/4] " Andrei Errapart ` (3 subsequent siblings) 5 siblings, 1 reply; 13+ messages in thread From: Andrei Errapart @ 2014-06-18 17:01 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1 bytes --] [-- Attachment #2: checks.patch --] [-- Type: text/plain, Size: 5740 bytes --] commit b8ad167d89d7f5ba6398ffeab6a7f9ece954f208 Author: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> Date: Wed Jun 18 18:43:17 2014 +0200 * MSVC doesn't support 0-sized arrays. * Initialize check->inprogress, too. Signed-off-by: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> diff --git a/checks.c b/checks.c index 47eda65..bc3c259 100644 --- a/checks.c +++ b/checks.c @@ -69,6 +69,7 @@ struct check { .warn = (w), \ .error = (e), \ .status = UNCHECKED, \ + .inprogress = false, \ .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ .prereq = nm##_prereqs, \ }; @@ -153,7 +154,7 @@ static bool run_check(struct check *c, struct node *dt) c->inprogress = true; - for (i = 0; i < c->num_prereqs; i++) { + for (i = 0; i < c->num_prereqs && c->prereq[i]!=NULL; i++) { struct check *prq = c->prereq[i]; error = error || run_check(prq, dt); if (prq->status != PASSED) { @@ -192,7 +193,7 @@ static inline void check_always_fail(struct check *c, struct node *dt) { FAIL(c, "always_fail check"); } -TREE_CHECK(always_fail, NULL); +TREE_CHECK(always_fail, NULL, 0); static void check_is_string(struct check *c, struct node *root, struct node *node) @@ -209,9 +210,9 @@ static void check_is_string(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_STRING(nm, propname) \ - WARNING(nm, NULL, check_is_string, NULL, (propname)) + WARNING(nm, NULL, check_is_string, NULL, (propname), 0) #define ERROR_IF_NOT_STRING(nm, propname) \ - ERROR(nm, NULL, check_is_string, NULL, (propname)) + ERROR(nm, NULL, check_is_string, NULL, (propname), 0) static void check_is_cell(struct check *c, struct node *root, struct node *node) @@ -228,9 +229,9 @@ static void check_is_cell(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_CELL(nm, propname) \ - WARNING(nm, NULL, check_is_cell, NULL, (propname)) + WARNING(nm, NULL, check_is_cell, NULL, (propname), 0) #define ERROR_IF_NOT_CELL(nm, propname) \ - ERROR(nm, NULL, check_is_cell, NULL, (propname)) + ERROR(nm, NULL, check_is_cell, NULL, (propname), 0) /* * Structural check functions @@ -249,7 +250,7 @@ static void check_duplicate_node_names(struct check *c, struct node *dt, FAIL(c, "Duplicate node name %s", child->fullpath); } -NODE_ERROR(duplicate_node_names, NULL); +NODE_ERROR(duplicate_node_names, NULL, 0); static void check_duplicate_property_names(struct check *c, struct node *dt, struct node *node) @@ -266,7 +267,7 @@ static void check_duplicate_property_names(struct check *c, struct node *dt, } } } -NODE_ERROR(duplicate_property_names, NULL); +NODE_ERROR(duplicate_property_names, NULL, 0); #define LOWERCASE "abcdefghijklmnopqrstuvwxyz" #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -282,7 +283,7 @@ static void check_node_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in node %s", node->name[n], node->fullpath); } -NODE_ERROR(node_name_chars, PROPNODECHARS "@"); +NODE_ERROR(node_name_chars, PROPNODECHARS "@", 0); static void check_node_name_format(struct check *c, struct node *dt, struct node *node) @@ -302,7 +303,7 @@ static void check_property_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in property name \"%s\", node %s", prop->name[n], prop->name, node->fullpath); } -PROP_ERROR(property_name_chars, PROPNODECHARS); +PROP_ERROR(property_name_chars, PROPNODECHARS, 0); #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ @@ -358,7 +359,7 @@ static void check_duplicate_label_prop(struct check *c, struct node *dt, check_duplicate_label(c, dt, m->ref, node, prop, m); } ERROR(duplicate_label, NULL, check_duplicate_label_node, - check_duplicate_label_prop, NULL); + check_duplicate_label_prop, NULL, 0); static void check_explicit_phandles(struct check *c, struct node *root, struct node *node, struct property *prop) @@ -417,7 +418,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, node->phandle = phandle; } -PROP_ERROR(explicit_phandles, NULL); +PROP_ERROR(explicit_phandles, NULL, 0); static void check_name_properties(struct check *c, struct node *root, struct node *node) @@ -649,7 +650,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, FAIL(c, "/chosen has obsolete \"interrupt-controller\" " "property"); } -TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); +TREE_WARNING(obsolete_chosen_interrupt_controller, NULL, 0); static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, @@ -678,8 +679,10 @@ static void enable_warning_error(struct check *c, bool warn, bool error) /* Raising level, also raise it for prereqs */ if ((warn && !c->warn) || (error && !c->error)) - for (i = 0; i < c->num_prereqs; i++) + for (i = 0; i < c->num_prereqs && c->prereq[i] != NULL; i++) enable_warning_error(c->prereq[i], warn, error); + /* check->prereq[i] might be NULL; this is because MSVC doesn't + * support 0-sized arrays. */ c->warn = c->warn || warn; c->error = c->error || error; @@ -696,9 +699,11 @@ static void disable_warning_error(struct check *c, bool warn, bool error) struct check *cc = check_table[i]; int j; - for (j = 0; j < cc->num_prereqs; j++) + for (j = 0; j < cc->num_prereqs && cc->prereq[j] != NULL; j++) if (cc->prereq[j] == c) disable_warning_error(cc, warn, error); + /* check->prereq[j] might be NULL; this is because MSVC doesn't + * support 0-sized arrays. */ } } ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <53A1C5FC.9040105-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>]
* Re: [PATCH 1/4] Microsoft Visual C patches [not found] ` <53A1C5FC.9040105-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> @ 2014-06-19 11:14 ` David Gibson [not found] ` <20140619111459.GM29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: David Gibson @ 2014-06-19 11:14 UTC (permalink / raw) To: Andrei Errapart; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1325 bytes --] On Wed, Jun 18, 2014 at 08:01:48PM +0300, Andrei Errapart wrote: > > commit b8ad167d89d7f5ba6398ffeab6a7f9ece954f208 > Author: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> > Date: Wed Jun 18 18:43:17 2014 +0200 > > * MSVC doesn't support 0-sized arrays. Ugh, this is by far the ugliest of these workarounds, and the reason for it in the code is really non-obvious. I'll have to think about this some more. > * Initialize check->inprogress, too. Why..? > Signed-off-by: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> I've applied patches 2, 3, and 4. But for future reference, please remember: * Patches should be inline, not attachments * Commit message and signed-off-by lines should not be indented * Commit messages need more details on the reason for the patch (see the changes I've made for examples). * Commit messages need a 1 line summary at the top (2, 3, and 4 have this, but 1 doesn't) * There should be a blank line between the 1-lite summary and the remainder of the commit message -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140619111459.GM29264-1s0os16eZneny3qCrzbmXA@public.gmane.org>]
* Re: [PATCH 1/4] Microsoft Visual C patches [not found] ` <20140619111459.GM29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> @ 2014-06-19 14:17 ` Andrei Errapart [not found] ` <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Andrei Errapart @ 2014-06-19 14:17 UTC (permalink / raw) To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA First, thanks for accepting 3 of the patches! 19.06.2014 14:14, David Gibson kirjutas: > Ugh, this is by far the ugliest of these workarounds, and the reason > for it in the code is really non-obvious. I'll have to think about > this some more. Good point. Kind of careless of me not to pay attention to that aspect. What about dropping the field "num_prereqs" altogether? It forces someone looping over the field "prereq" to think about the end condition and comparision with NULL (or nullptr) is an obvious answer. A diff is at the end of the letter. >> * Initialize check->inprogress, too. > > Why..? Stumbled over that one - the value of inprogress was in some cases initialized to "true" when compiled with MSVC. According to the C99 draft (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf, pages 137,138), in static storage all fields are initialized to zero, null, 0. According to MSDN (http://msdn.microsoft.com/en-us/library/81k8cwsz.aspx), initilization is required: "If initializer-list has fewer values than an aggregate type, the remaining members or elements of the aggregate type are initialized to 0. The initial value of an automatic identifier not explicitly initialized is undefined." > I've applied patches 2, 3, and 4. But for future reference, please remember: > > * Patches should be inline, not attachments > * Commit message and signed-off-by lines should not be indented > * Commit messages need more details on the reason for the patch (see > the changes I've made for examples). > * Commit messages need a 1 line summary at the top (2, 3, and 4 have > this, but 1 doesn't) > * There should be a blank line between the 1-lite summary and the > remainder of the commit message Thanks again. Is there an automated command to format the commit message per the requirements? best regards, Andrei -------------------------------------------------------- diff --git a/checks.c b/checks.c index 47eda65..fe90dfc 100644 --- a/checks.c +++ b/checks.c @@ -54,12 +54,11 @@ struct check { bool warn, error; enum checkstatus status; bool inprogress; - int num_prereqs; struct check **prereq; }; #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ - static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ + static struct check *nm##_prereqs[] = { __VA_ARGS__, NULL }; \ static struct check nm = { \ .name = #nm, \ .tree_fn = (tfn), \ @@ -69,7 +68,6 @@ struct check { .warn = (w), \ .error = (e), \ .status = UNCHECKED, \ - .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ .prereq = nm##_prereqs, \ }; #define WARNING(nm, tfn, nfn, pfn, d, ...) \ @@ -153,7 +151,7 @@ static bool run_check(struct check *c, struct node *dt) c->inprogress = true; - for (i = 0; i < c->num_prereqs; i++) { + for (i = 0; c->prereq[i] != NULL; i++) { struct check *prq = c->prereq[i]; error = error || run_check(prq, dt); if (prq->status != PASSED) { @@ -192,7 +190,7 @@ static inline void check_always_fail(struct check *c, struct node *dt) { FAIL(c, "always_fail check"); } -TREE_CHECK(always_fail, NULL); +TREE_CHECK(always_fail, NULL, NULL); static void check_is_string(struct check *c, struct node *root, struct node *node) @@ -209,9 +207,9 @@ static void check_is_string(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_STRING(nm, propname) \ - WARNING(nm, NULL, check_is_string, NULL, (propname)) + WARNING(nm, NULL, check_is_string, NULL, (propname), NULL) #define ERROR_IF_NOT_STRING(nm, propname) \ - ERROR(nm, NULL, check_is_string, NULL, (propname)) + ERROR(nm, NULL, check_is_string, NULL, (propname), NULL) static void check_is_cell(struct check *c, struct node *root, struct node *node) @@ -228,9 +226,9 @@ static void check_is_cell(struct check *c, struct node *root, propname, node->fullpath); } #define WARNING_IF_NOT_CELL(nm, propname) \ - WARNING(nm, NULL, check_is_cell, NULL, (propname)) + WARNING(nm, NULL, check_is_cell, NULL, (propname), NULL) #define ERROR_IF_NOT_CELL(nm, propname) \ - ERROR(nm, NULL, check_is_cell, NULL, (propname)) + ERROR(nm, NULL, check_is_cell, NULL, (propname), NULL) /* * Structural check functions @@ -249,7 +247,7 @@ static void check_duplicate_node_names(struct check *c, struct node *dt, FAIL(c, "Duplicate node name %s", child->fullpath); } -NODE_ERROR(duplicate_node_names, NULL); +NODE_ERROR(duplicate_node_names, NULL, NULL); static void check_duplicate_property_names(struct check *c, struct node *dt, struct node *node) @@ -266,7 +264,7 @@ static void check_duplicate_property_names(struct check *c, struct node *dt, } } } -NODE_ERROR(duplicate_property_names, NULL); +NODE_ERROR(duplicate_property_names, NULL, NULL); #define LOWERCASE "abcdefghijklmnopqrstuvwxyz" #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -282,7 +280,7 @@ static void check_node_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in node %s", node->name[n], node->fullpath); } -NODE_ERROR(node_name_chars, PROPNODECHARS "@"); +NODE_ERROR(node_name_chars, PROPNODECHARS "@", NULL); static void check_node_name_format(struct check *c, struct node *dt, struct node *node) @@ -302,7 +300,7 @@ static void check_property_name_chars(struct check *c, struct node *dt, FAIL(c, "Bad character '%c' in property name \"%s\", node %s", prop->name[n], prop->name, node->fullpath); } -PROP_ERROR(property_name_chars, PROPNODECHARS); +PROP_ERROR(property_name_chars, PROPNODECHARS, NULL); #define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_ARGS(node,prop,mark) \ @@ -358,7 +356,7 @@ static void check_duplicate_label_prop(struct check *c, struct node *dt, check_duplicate_label(c, dt, m->ref, node, prop, m); } ERROR(duplicate_label, NULL, check_duplicate_label_node, - check_duplicate_label_prop, NULL); + check_duplicate_label_prop, NULL, NULL); static void check_explicit_phandles(struct check *c, struct node *root, struct node *node, struct property *prop) @@ -417,7 +415,7 @@ static void check_explicit_phandles(struct check *c, struct node *root, node->phandle = phandle; } -PROP_ERROR(explicit_phandles, NULL); +PROP_ERROR(explicit_phandles, NULL, NULL); static void check_name_properties(struct check *c, struct node *root, struct node *node) @@ -649,7 +647,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, FAIL(c, "/chosen has obsolete \"interrupt-controller\" " "property"); } -TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); +TREE_WARNING(obsolete_chosen_interrupt_controller, NULL, NULL); static struct check *check_table[] = { &duplicate_node_names, &duplicate_property_names, @@ -678,7 +676,7 @@ static void enable_warning_error(struct check *c, bool warn, bool error) /* Raising level, also raise it for prereqs */ if ((warn && !c->warn) || (error && !c->error)) - for (i = 0; i < c->num_prereqs; i++) + for (i = 0; c->prereq[i] != NULL; i++) enable_warning_error(c->prereq[i], warn, error); c->warn = c->warn || warn; @@ -696,7 +694,7 @@ static void disable_warning_error(struct check *c, bool warn, bool error) struct check *cc = check_table[i]; int j; - for (j = 0; j < cc->num_prereqs; j++) + for (j = 0; cc->prereq[j] != NULL; j++) if (cc->prereq[j] == c) disable_warning_error(cc, warn, error); } -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>]
* Re: [PATCH 1/4] Microsoft Visual C patches [not found] ` <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> @ 2014-06-19 15:06 ` Andrei Errapart 2014-06-20 12:55 ` David Gibson 1 sibling, 0 replies; 13+ messages in thread From: Andrei Errapart @ 2014-06-19 15:06 UTC (permalink / raw) To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA 19.06.2014 17:17, Andrei Errapart kirjutas: >>> * Initialize check->inprogress, too. >> >> Why..? Another option: move the field "inprogress" to the end of the struct. Works, too. best regards, Andrei -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] Microsoft Visual C patches [not found] ` <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 2014-06-19 15:06 ` Andrei Errapart @ 2014-06-20 12:55 ` David Gibson [not found] ` <20140620125528.GB16801-1s0os16eZneny3qCrzbmXA@public.gmane.org> 1 sibling, 1 reply; 13+ messages in thread From: David Gibson @ 2014-06-20 12:55 UTC (permalink / raw) To: Andrei Errapart; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 3903 bytes --] On Thu, Jun 19, 2014 at 05:17:40PM +0300, Andrei Errapart wrote: > First, thanks for accepting 3 of the patches! > > 19.06.2014 14:14, David Gibson kirjutas: > >Ugh, this is by far the ugliest of these workarounds, and the reason > >for it in the code is really non-obvious. I'll have to think about > >this some more. > > Good point. Kind of careless of me not to pay attention to that aspect. > > What about dropping the field "num_prereqs" altogether? It forces someone > looping over the field "prereq" to think about the end condition and > comparision with NULL (or nullptr) is an obvious answer. A diff is at the > end of the letter. Hm, that might work. I'll think on it. > >> * Initialize check->inprogress, too. > > > >Why..? > > Stumbled over that one - the value of inprogress was in some cases > initialized to "true" when compiled with MSVC. > > According to the C99 draft > (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf, pages 137,138), > in static storage all fields are initialized to zero, null, 0. Exactly.. > According to MSDN (http://msdn.microsoft.com/en-us/library/81k8cwsz.aspx), > initilization is required: "If initializer-list has fewer values than an > aggregate type, the remaining members or elements of the aggregate type are > initialized to 0. The initial value of an automatic identifier not > explicitly initialized is undefined." Right, an automatic identifier, which is to say a local variable, not a global variable like this, > >I've applied patches 2, 3, and 4. But for future reference, please remember: > > > > * Patches should be inline, not attachments > > * Commit message and signed-off-by lines should not be indented > > * Commit messages need more details on the reason for the patch (see > > the changes I've made for examples). > > * Commit messages need a 1 line summary at the top (2, 3, and 4 have > > this, but 1 doesn't) > > * There should be a blank line between the 1-lite summary and the > > remainder of the commit message > > Thanks again. > > Is there an automated command to format the commit message per the > requirements? git format-patch should do it, or git send-email will format and send out the emails for you too. > diff --git a/checks.c b/checks.c > index 47eda65..fe90dfc 100644 > --- a/checks.c > +++ b/checks.c > @@ -54,12 +54,11 @@ struct check { > bool warn, error; > enum checkstatus status; > bool inprogress; > - int num_prereqs; > struct check **prereq; > }; > > #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ > - static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ > + static struct check *nm##_prereqs[] = { __VA_ARGS__, NULL }; \ > static struct check nm = { \ > .name = #nm, \ > .tree_fn = (tfn), \ > @@ -69,7 +68,6 @@ struct check { > .warn = (w), \ > .error = (e), \ > .status = UNCHECKED, \ > - .num_prereqs = ARRAY_SIZE(nm##_prereqs), \ > .prereq = nm##_prereqs, \ > }; > #define WARNING(nm, tfn, nfn, pfn, d, ...) \ > @@ -153,7 +151,7 @@ static bool run_check(struct check *c, struct node *dt) > > c->inprogress = true; > > - for (i = 0; i < c->num_prereqs; i++) { > + for (i = 0; c->prereq[i] != NULL; i++) { > struct check *prq = c->prereq[i]; > error = error || run_check(prq, dt); > if (prq->status != PASSED) { > @@ -192,7 +190,7 @@ static inline void check_always_fail(struct check *c, > struct node *dt) > { > FAIL(c, "always_fail check"); > } > -TREE_CHECK(always_fail, NULL); > +TREE_CHECK(always_fail, NULL, NULL); Why is the extra NULL necessary here (and similar places)? -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20140620125528.GB16801-1s0os16eZneny3qCrzbmXA@public.gmane.org>]
* Re: [PATCH 1/4] Microsoft Visual C patches [not found] ` <20140620125528.GB16801-1s0os16eZneny3qCrzbmXA@public.gmane.org> @ 2014-06-20 13:32 ` Simon Glass 0 siblings, 0 replies; 13+ messages in thread From: Simon Glass @ 2014-06-20 13:32 UTC (permalink / raw) To: David Gibson; +Cc: Andrei Errapart, Devicetree Compiler Hi, On 20 June 2014 06:55, David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote: > On Thu, Jun 19, 2014 at 05:17:40PM +0300, Andrei Errapart wrote: >> Is there an automated command to format the commit message per the >> requirements? > > git format-patch should do it, or git send-email will format and send > out the emails for you too. > Try patman: http://code.metager.de/source/xref/denx/u-boot/tools/patman/README Regards, Simon -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/4] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 2014-06-17 17:18 ` Matthew Gerlach 2014-06-18 17:01 ` [PATCH 1/4] " Andrei Errapart @ 2014-06-18 17:02 ` Andrei Errapart 2014-06-18 17:03 ` [PATCH 3/4] " Andrei Errapart ` (2 subsequent siblings) 5 siblings, 0 replies; 13+ messages in thread From: Andrei Errapart @ 2014-06-18 17:02 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1 bytes --] [-- Attachment #2: dtc-header.patch --] [-- Type: text/plain, Size: 1002 bytes --] commit 8216d97ee62aadac330c9ff85f3775fcd3c760d3 Author: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> Date: Wed Jun 18 18:07:04 2014 +0200 Work around MSVC limitations: 1) No variadic macros in the form "args..."; this is a GCC extension. 2) No empty struct initializers. In any case, there is very little to win: { } vs. { 0 }. Signed-off-by: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> diff --git a/dtc.h b/dtc.h index 20de073..56212c8 100644 --- a/dtc.h +++ b/dtc.h @@ -38,9 +38,9 @@ #include "util.h" #ifdef DEBUG -#define debug(fmt,args...) printf(fmt, ##args) +#define debug(...) printf(__VA_ARGS__) #else -#define debug(fmt,args...) +#define debug(...) #endif @@ -88,7 +88,7 @@ struct data { }; -#define empty_data ((struct data){ /* all .members = 0 or NULL */ }) +#define empty_data ((struct data){ 0 /* all .members = 0 or NULL */ }) #define for_each_marker(m) \ for (; (m); (m) = (m)->next) ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/4] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> ` (2 preceding siblings ...) 2014-06-18 17:02 ` [PATCH 2/4] " Andrei Errapart @ 2014-06-18 17:03 ` Andrei Errapart 2014-06-18 17:04 ` [PATCH 4/4] " Andrei Errapart 2014-06-18 17:27 ` [PATCH] " Andrei Errapart 5 siblings, 0 replies; 13+ messages in thread From: Andrei Errapart @ 2014-06-18 17:03 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1 bytes --] [-- Attachment #2: fopen.patch --] [-- Type: text/plain, Size: 1359 bytes --] commit 446c8c45fffdb46a53a6ff9fdfe85311d1209747 Author: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> Date: Wed Jun 18 17:58:22 2014 +0200 Open binary files in binary mode. Signed-off-by: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> diff --git a/dtc.c b/dtc.c index d36ccdc..e3665b6 100644 --- a/dtc.c +++ b/dtc.c @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) if (streq(outname, "-")) { outf = stdout; } else { - outf = fopen(outname, "w"); + outf = fopen(outname, "wb"); if (! outf) die("Couldn't open output file %s: %s\n", outname, strerror(errno)); diff --git a/fstree.c b/fstree.c index 4d2791c..6d1beec 100644 --- a/fstree.c +++ b/fstree.c @@ -52,7 +52,7 @@ static struct node *read_fstree(const char *dirname) struct property *prop; FILE *pfile; - pfile = fopen(tmpname, "r"); + pfile = fopen(tmpname, "rb"); if (! pfile) { fprintf(stderr, "WARNING: Cannot open %s: %s\n", diff --git a/srcpos.c b/srcpos.c index 4549773..f534c22 100644 --- a/srcpos.c +++ b/srcpos.c @@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp) else fullname = join_path(dirname, fname); - *fp = fopen(fullname, "r"); + *fp = fopen(fullname, "rb"); if (!*fp) { free(fullname); fullname = NULL; ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/4] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> ` (3 preceding siblings ...) 2014-06-18 17:03 ` [PATCH 3/4] " Andrei Errapart @ 2014-06-18 17:04 ` Andrei Errapart 2014-06-18 17:27 ` [PATCH] " Andrei Errapart 5 siblings, 0 replies; 13+ messages in thread From: Andrei Errapart @ 2014-06-18 17:04 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1 bytes --] [-- Attachment #2: signed-char.patch --] [-- Type: text/plain, Size: 685 bytes --] commit 50023c6f8717ee1939ebba885feb9f43fdb7dd33 Author: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> Date: Wed Jun 18 08:21:01 2014 +0200 For Microsoft C compiler, char defaults to signed char. Signed-off-by: Andrei Errapart <andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> diff --git a/treesource.c b/treesource.c index bf7a626..2386b93 100644 --- a/treesource.c +++ b/treesource.c @@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val) m = m->next; } - fprintf(f, "%02hhx", *bp++); + fprintf(f, "%02hhx", (unsigned char)(*bp++)); if ((const void *)bp >= propend) break; fprintf(f, " "); ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Microsoft Visual C patches [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> ` (4 preceding siblings ...) 2014-06-18 17:04 ` [PATCH 4/4] " Andrei Errapart @ 2014-06-18 17:27 ` Andrei Errapart 5 siblings, 0 replies; 13+ messages in thread From: Andrei Errapart @ 2014-06-18 17:27 UTC (permalink / raw) To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA Hi David, 16.06.2014 13:46, David Gibson kirjutas: > Um.. I don't see what removing the C99 initializers has to do with > MSVC not supporting 0 size arrays Thanks for noticing! Somehow I missed it the last year when MS finally added C99 initializer support to MSVS 2013. I will clean up the supporting portability shim some later day; it's very small. best regards, Andrei Errapart -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-06-20 13:32 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-15 15:46 [PATCH] Microsoft Visual C patches Andrei Errapart [not found] ` <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 2014-06-16 10:46 ` David Gibson [not found] ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 2014-06-17 17:18 ` Matthew Gerlach 2014-06-18 17:01 ` [PATCH 1/4] " Andrei Errapart [not found] ` <53A1C5FC.9040105-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 2014-06-19 11:14 ` David Gibson [not found] ` <20140619111459.GM29264-1s0os16eZneny3qCrzbmXA@public.gmane.org> 2014-06-19 14:17 ` Andrei Errapart [not found] ` <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org> 2014-06-19 15:06 ` Andrei Errapart 2014-06-20 12:55 ` David Gibson [not found] ` <20140620125528.GB16801-1s0os16eZneny3qCrzbmXA@public.gmane.org> 2014-06-20 13:32 ` Simon Glass 2014-06-18 17:02 ` [PATCH 2/4] " Andrei Errapart 2014-06-18 17:03 ` [PATCH 3/4] " Andrei Errapart 2014-06-18 17:04 ` [PATCH 4/4] " Andrei Errapart 2014-06-18 17:27 ` [PATCH] " Andrei Errapart
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).