* RFC: option to toggle dtc checks on and off
@ 2011-10-28 5:15 David Gibson
[not found] ` <20111028051525.GA7215-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2011-10-28 5:15 UTC (permalink / raw)
To: jdl-CYoMK+44s/E; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Here is a draft patch which adds a -C option to dtc, allowing
individual semantic checks to be turned on and off. It also allows
indivudual checks to be set as triggering either warnings or errors.
I have a couple of concerns about it in its present form. First, the
current syntax is that "-C -checkname" disables a check, "-C
checkname" turns a check on as a warning and "-C +checkname" turns it
on as an error. I'm not convinced this is a great syntax.
Second, turning on a check will force on all prerequisite checks for
it. Turning a check off will disable all checks for which it is a
prerequisite. This seems necessary, since a check can't safely be
executed without having first checked its prereqs, but this could have
some very non-obvious effects from the command line.
Index: dtc/checks.c
===================================================================
--- dtc.orig/checks.c 2011-04-11 13:47:41.000000000 +1000
+++ dtc/checks.c 2011-10-28 14:42:31.846917479 +1100
@@ -644,6 +644,69 @@ static struct check *check_table[] = {
&obsolete_chosen_interrupt_controller,
};
+static void set_check_level(struct check *c, int level)
+{
+ int i;
+
+ fprintf(stderr, "Setting '%s' check level to %d\n",
+ c->name, level);
+
+ if (level > c->level) {
+ /* Raising level, also raise it for prereqs */
+ for (i = 0; i < c->num_prereqs; i++)
+ set_check_level(c->prereq[i], level);
+ }
+
+ if (level < c->level) {
+ /* Lowering level, also lower it for things this is
+ * the prereq for */
+ for (i = 0; i < ARRAY_SIZE(check_table); i++) {
+ struct check *cc = check_table[i];
+ int j;
+
+ for (j = 0; j < cc->num_prereqs; j++)
+ if (cc->prereq[j] == c)
+ set_check_level(cc, level);
+ }
+ }
+
+ c->level = level;
+}
+
+void parse_checks_option(const char *optarg)
+{
+ int i;
+ const char *name;
+ int level;
+
+ switch (optarg[0]) {
+ case '-':
+ level = IGNORE;
+ name = optarg + 1;
+ break;
+
+ case '+':
+ level = ERROR;
+ name = optarg + 1;
+ break;
+
+ default:
+ level = WARN;
+ name = optarg;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(check_table); i++) {
+ struct check *c = check_table[i];
+
+ if (streq(c->name, name)) {
+ set_check_level(c, level);
+ return;
+ }
+ }
+
+ die("Unrecognized check name \"%s\"\n", name);
+}
+
void process_checks(int force, struct boot_info *bi)
{
struct node *dt = bi->dt;
Index: dtc/dtc.c
===================================================================
--- dtc.orig/dtc.c 2011-07-18 09:20:15.000000000 +1000
+++ dtc/dtc.c 2011-10-28 14:43:34.743229363 +1100
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
minsize = 0;
padsize = 0;
- while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:s")) != EOF) {
+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:sC:")) != EOF) {
switch (opt) {
case 'I':
inform = optarg;
@@ -162,6 +162,10 @@ int main(int argc, char *argv[])
sort = 1;
break;
+ case 'C':
+ parse_checks_option(optarg);
+ break;
+
case 'h':
default:
usage();
Index: dtc/dtc.h
===================================================================
--- dtc.orig/dtc.h 2011-10-12 09:56:55.000000000 +1100
+++ dtc/dtc.h 2011-10-28 14:42:31.846917479 +1100
@@ -225,6 +225,7 @@ void sort_tree(struct boot_info *bi);
/* Checks */
+void parse_checks_option(const char *optarg);
void process_checks(int force, struct boot_info *bi);
/* Flattened trees */
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
[not found] ` <20111028051525.GA7215-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
@ 2012-01-09 2:41 ` David Gibson
[not found] ` <20120109024129.GH5628-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2012-01-09 2:41 UTC (permalink / raw)
To: jdl-CYoMK+44s/E; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Jon, I was hoping I'd get some comment on this patch eventually.
On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> Here is a draft patch which adds a -C option to dtc, allowing
> individual semantic checks to be turned on and off. It also allows
> indivudual checks to be set as triggering either warnings or errors.
>
> I have a couple of concerns about it in its present form. First, the
> current syntax is that "-C -checkname" disables a check, "-C
> checkname" turns a check on as a warning and "-C +checkname" turns it
> on as an error. I'm not convinced this is a great syntax.
>
> Second, turning on a check will force on all prerequisite checks for
> it. Turning a check off will disable all checks for which it is a
> prerequisite. This seems necessary, since a check can't safely be
> executed without having first checked its prereqs, but this could have
> some very non-obvious effects from the command line.
>
> Index: dtc/checks.c
> ===================================================================
> --- dtc.orig/checks.c 2011-04-11 13:47:41.000000000 +1000
> +++ dtc/checks.c 2011-10-28 14:42:31.846917479 +1100
> @@ -644,6 +644,69 @@ static struct check *check_table[] = {
> &obsolete_chosen_interrupt_controller,
> };
>
> +static void set_check_level(struct check *c, int level)
> +{
> + int i;
> +
> + fprintf(stderr, "Setting '%s' check level to %d\n",
> + c->name, level);
> +
> + if (level > c->level) {
> + /* Raising level, also raise it for prereqs */
> + for (i = 0; i < c->num_prereqs; i++)
> + set_check_level(c->prereq[i], level);
> + }
> +
> + if (level < c->level) {
> + /* Lowering level, also lower it for things this is
> + * the prereq for */
> + for (i = 0; i < ARRAY_SIZE(check_table); i++) {
> + struct check *cc = check_table[i];
> + int j;
> +
> + for (j = 0; j < cc->num_prereqs; j++)
> + if (cc->prereq[j] == c)
> + set_check_level(cc, level);
> + }
> + }
> +
> + c->level = level;
> +}
> +
> +void parse_checks_option(const char *optarg)
> +{
> + int i;
> + const char *name;
> + int level;
> +
> + switch (optarg[0]) {
> + case '-':
> + level = IGNORE;
> + name = optarg + 1;
> + break;
> +
> + case '+':
> + level = ERROR;
> + name = optarg + 1;
> + break;
> +
> + default:
> + level = WARN;
> + name = optarg;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(check_table); i++) {
> + struct check *c = check_table[i];
> +
> + if (streq(c->name, name)) {
> + set_check_level(c, level);
> + return;
> + }
> + }
> +
> + die("Unrecognized check name \"%s\"\n", name);
> +}
> +
> void process_checks(int force, struct boot_info *bi)
> {
> struct node *dt = bi->dt;
> Index: dtc/dtc.c
> ===================================================================
> --- dtc.orig/dtc.c 2011-07-18 09:20:15.000000000 +1000
> +++ dtc/dtc.c 2011-10-28 14:43:34.743229363 +1100
> @@ -111,7 +111,7 @@ int main(int argc, char *argv[])
> minsize = 0;
> padsize = 0;
>
> - while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:s")) != EOF) {
> + while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fqb:vH:sC:")) != EOF) {
> switch (opt) {
> case 'I':
> inform = optarg;
> @@ -162,6 +162,10 @@ int main(int argc, char *argv[])
> sort = 1;
> break;
>
> + case 'C':
> + parse_checks_option(optarg);
> + break;
> +
> case 'h':
> default:
> usage();
> Index: dtc/dtc.h
> ===================================================================
> --- dtc.orig/dtc.h 2011-10-12 09:56:55.000000000 +1100
> +++ dtc/dtc.h 2011-10-28 14:42:31.846917479 +1100
> @@ -225,6 +225,7 @@ void sort_tree(struct boot_info *bi);
>
> /* Checks */
>
> +void parse_checks_option(const char *optarg);
> void process_checks(int force, struct boot_info *bi);
>
> /* Flattened trees */
>
>
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
[not found] ` <20120109024129.GH5628-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
@ 2012-01-09 14:07 ` Jon Loeliger
[not found] ` <E1RkFso-00007g-Ue-CYoMK+44s/E@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Jon Loeliger @ 2012-01-09 14:07 UTC (permalink / raw)
To: David Gibson; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
> Jon, I was hoping I'd get some comment on this patch eventually.
Sorry/ .
> On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> > Here is a draft patch which adds a -C option to dtc, allowing
> > individual semantic checks to be turned on and off. It also allows
> > indivudual checks to be set as triggering either warnings or errors.
Turning checks on and off: good.
> > I have a couple of concerns about it in its present form. First, the
> > current syntax is that "-C -checkname" disables a check, "-C
> > checkname" turns a check on as a warning and "-C +checkname" turns it
> > on as an error. I'm not convinced this is a great syntax.
Yeah, that's sub-obtimal.
What about using something like "-E checkname" and "-W checkname"?
> > Second, turning on a check will force on all prerequisite checks for
> > it. Turning a check off will disable all checks for which it is a
> > prerequisite. This seems necessary, since a check can't safely be
> > executed without having first checked its prereqs, but this could have
> > some very non-obvious effects from the command line.
Hmm... That seems like maybe a small matter of documentation...?
And in which order do you apply the cmd line options for their implications?
Last one takes precedence?
HTH,
jdl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
[not found] ` <E1RkFso-00007g-Ue-CYoMK+44s/E@public.gmane.org>
@ 2012-01-11 12:19 ` David Gibson
[not found] ` <20120111121941.GI4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2012-01-11 12:19 UTC (permalink / raw)
To: Jon Loeliger; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Mon, Jan 09, 2012 at 08:07:30AM -0600, Jon Loeliger wrote:
> > Jon, I was hoping I'd get some comment on this patch eventually.
>
> Sorry/ .
>
> > On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> > > Here is a draft patch which adds a -C option to dtc, allowing
> > > individual semantic checks to be turned on and off. It also allows
> > > indivudual checks to be set as triggering either warnings or errors.
>
> Turning checks on and off: good.
>
> > > I have a couple of concerns about it in its present form. First, the
> > > current syntax is that "-C -checkname" disables a check, "-C
> > > checkname" turns a check on as a warning and "-C +checkname" turns it
> > > on as an error. I'm not convinced this is a great syntax.
>
> Yeah, that's sub-obtimal.
> What about using something like "-E checkname" and "-W checkname"?
Yeah, I though of that too. Can't remeber why I didn't go that way.
Gets a bit weird if you specify both -E foo and -W foo, but "last one
wins" is probably still a reasonable way of deciding that. Any
thoughts for an option to turn a check off completely?
> > > Second, turning on a check will force on all prerequisite checks for
> > > it. Turning a check off will disable all checks for which it is a
> > > prerequisite. This seems necessary, since a check can't safely be
> > > executed without having first checked its prereqs, but this could have
> > > some very non-obvious effects from the command line.
>
> Hmm... That seems like maybe a small matter of documentation...?
I guess. Might be worth printing a message for each check implicitly
enabled or disabled, too.
> And in which order do you apply the cmd line options for their implications?
> Last one takes precedence?
That was what I had in mind.
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
[not found] ` <20120111121941.GI4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
@ 2012-01-11 13:38 ` Jamie Iles
2012-01-12 3:17 ` David Gibson
0 siblings, 1 reply; 7+ messages in thread
From: Jamie Iles @ 2012-01-11 13:38 UTC (permalink / raw)
To: David Gibson; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Wed, Jan 11, 2012 at 11:19:41PM +1100, David Gibson wrote:
> On Mon, Jan 09, 2012 at 08:07:30AM -0600, Jon Loeliger wrote:
> > > Jon, I was hoping I'd get some comment on this patch eventually.
> >
> > Sorry/ .
> >
> > > On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> > > > Here is a draft patch which adds a -C option to dtc, allowing
> > > > individual semantic checks to be turned on and off. It also allows
> > > > indivudual checks to be set as triggering either warnings or errors.
> >
> > Turning checks on and off: good.
> >
> > > > I have a couple of concerns about it in its present form. First, the
> > > > current syntax is that "-C -checkname" disables a check, "-C
> > > > checkname" turns a check on as a warning and "-C +checkname" turns it
> > > > on as an error. I'm not convinced this is a great syntax.
> >
> > Yeah, that's sub-obtimal.
> > What about using something like "-E checkname" and "-W checkname"?
>
> Yeah, I though of that too. Can't remeber why I didn't go that way.
> Gets a bit weird if you specify both -E foo and -W foo, but "last one
> wins" is probably still a reasonable way of deciding that. Any
> thoughts for an option to turn a check off completely?
How about the way that GCC handles warnings: -Wcheckname to enable,
-Wno-checkname to disable?
Jamie
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
2012-01-11 13:38 ` Jamie Iles
@ 2012-01-12 3:17 ` David Gibson
[not found] ` <20120112031714.GQ4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: David Gibson @ 2012-01-12 3:17 UTC (permalink / raw)
To: Jamie Iles; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Wed, Jan 11, 2012 at 01:38:12PM +0000, Jamie Iles wrote:
> On Wed, Jan 11, 2012 at 11:19:41PM +1100, David Gibson wrote:
> > On Mon, Jan 09, 2012 at 08:07:30AM -0600, Jon Loeliger wrote:
> > > > Jon, I was hoping I'd get some comment on this patch eventually.
> > >
> > > Sorry/ .
> > >
> > > > On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> > > > > Here is a draft patch which adds a -C option to dtc, allowing
> > > > > individual semantic checks to be turned on and off. It also allows
> > > > > indivudual checks to be set as triggering either warnings or errors.
> > >
> > > Turning checks on and off: good.
> > >
> > > > > I have a couple of concerns about it in its present form. First, the
> > > > > current syntax is that "-C -checkname" disables a check, "-C
> > > > > checkname" turns a check on as a warning and "-C +checkname" turns it
> > > > > on as an error. I'm not convinced this is a great syntax.
> > >
> > > Yeah, that's sub-obtimal.
> > > What about using something like "-E checkname" and "-W checkname"?
> >
> > Yeah, I though of that too. Can't remeber why I didn't go that way.
> > Gets a bit weird if you specify both -E foo and -W foo, but "last one
> > wins" is probably still a reasonable way of deciding that. Any
> > thoughts for an option to turn a check off completely?
>
> How about the way that GCC handles warnings: -Wcheckname to enable,
> -Wno-checkname to disable?
Perhaps. What should the semantics of -Wno-foo be when "foo" is an
error level check by default?
--
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: RFC: option to toggle dtc checks on and off
[not found] ` <20120112031714.GQ4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
@ 2012-01-12 10:14 ` Jamie Iles
0 siblings, 0 replies; 7+ messages in thread
From: Jamie Iles @ 2012-01-12 10:14 UTC (permalink / raw)
To: David Gibson; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
On Thu, Jan 12, 2012 at 02:17:14PM +1100, David Gibson wrote:
> On Wed, Jan 11, 2012 at 01:38:12PM +0000, Jamie Iles wrote:
> > On Wed, Jan 11, 2012 at 11:19:41PM +1100, David Gibson wrote:
> > > On Mon, Jan 09, 2012 at 08:07:30AM -0600, Jon Loeliger wrote:
> > > > > Jon, I was hoping I'd get some comment on this patch eventually.
> > > >
> > > > Sorry/ .
> > > >
> > > > > On Fri, Oct 28, 2011 at 04:15:25PM +1100, David Gibson wrote:
> > > > > > Here is a draft patch which adds a -C option to dtc, allowing
> > > > > > individual semantic checks to be turned on and off. It also allows
> > > > > > indivudual checks to be set as triggering either warnings or errors.
> > > >
> > > > Turning checks on and off: good.
> > > >
> > > > > > I have a couple of concerns about it in its present form. First, the
> > > > > > current syntax is that "-C -checkname" disables a check, "-C
> > > > > > checkname" turns a check on as a warning and "-C +checkname" turns it
> > > > > > on as an error. I'm not convinced this is a great syntax.
> > > >
> > > > Yeah, that's sub-obtimal.
> > > > What about using something like "-E checkname" and "-W checkname"?
> > >
> > > Yeah, I though of that too. Can't remeber why I didn't go that way.
> > > Gets a bit weird if you specify both -E foo and -W foo, but "last one
> > > wins" is probably still a reasonable way of deciding that. Any
> > > thoughts for an option to turn a check off completely?
> >
> > How about the way that GCC handles warnings: -Wcheckname to enable,
> > -Wno-checkname to disable?
>
> Perhaps. What should the semantics of -Wno-foo be when "foo" is an
> error level check by default?
Yes, that does get a little messy, but we could just adopt the GCC
convention in that certain things are errors and always will be. For
everything else, enable with -Wfoo, disable with -Wno-foo and add a
-Werror that turns warnings into errors?
Jamie
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-12 10:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-28 5:15 RFC: option to toggle dtc checks on and off David Gibson
[not found] ` <20111028051525.GA7215-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2012-01-09 2:41 ` David Gibson
[not found] ` <20120109024129.GH5628-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2012-01-09 14:07 ` Jon Loeliger
[not found] ` <E1RkFso-00007g-Ue-CYoMK+44s/E@public.gmane.org>
2012-01-11 12:19 ` David Gibson
[not found] ` <20120111121941.GI4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2012-01-11 13:38 ` Jamie Iles
2012-01-12 3:17 ` David Gibson
[not found] ` <20120112031714.GQ4935-MK4v0fQdeXQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2012-01-12 10:14 ` Jamie Iles
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).