-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* add comment "/* __[|>*DELETED*<|]__ */" for deteled nodes, labels and properties * comment deleted nodes, labels and properties
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,7 @@ devicetree: | |
struct node *target = get_node_by_ref($1, $3); | ||
|
||
if (target) | ||
delete_node(target); | ||
delete_node_by_name(target->parent, target->name, &@$); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bmx666
Author
Owner
|
||
else | ||
ERROR(&@3, "Label or path %s not found", $3); | ||
|
||
|
@@ -278,7 +278,7 @@ propdef: | |
} | ||
| DT_DEL_PROP DT_PROPNODENAME ';' | ||
{ | ||
$$ = build_property_delete($2); | ||
$$ = build_property_delete($2, &@$); | ||
} | ||
| DT_LABEL propdef | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,10 @@ static const char * const usage_opts_help[] = { | |
"\n\tEnable/disable errors (prefix with \"no-\")", | ||
"\n\tEnable generation of symbols", | ||
"\n\tEnable auto-alias of labels", | ||
"\n\tAnnotate output .dts with input source file and line (-T -T for more details)", | ||
"\n\tAnnotate output .dts with input source file and line (-T -T for more details)\n" | ||
This comment has been minimized.
Sorry, something went wrong.
dgibson
|
||
"\t-T -T -T - annotate property with all sources\n" | ||
This comment has been minimized.
Sorry, something went wrong.
dgibson
|
||
"\t-T -T -T -T - annotate deleted nodes and properties\n" | ||
"\t-T -T -T -T -T - annotate childs of deleted nodes", | ||
"\n\tPrint this help and exit", | ||
"\n\tPrint version and exit", | ||
NULL, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
#include "dtc.h" | ||
#include "srcpos.h" | ||
|
||
static struct node *build_and_name_child_node(struct node *parent, char *name); | ||
|
||
/* | ||
* Tree building functions | ||
*/ | ||
|
@@ -50,14 +52,19 @@ struct property *build_property(char *name, struct data val, | |
return new; | ||
} | ||
|
||
struct property *build_property_delete(char *name) | ||
struct property *build_property_delete(char *name, | ||
struct srcpos *srcpos) | ||
{ | ||
struct property *new = xmalloc(sizeof(*new)); | ||
|
||
memset(new, 0, sizeof(*new)); | ||
|
||
new->name = name; | ||
new->deleted = 1; | ||
if (annotate > 3) { | ||
This comment has been minimized.
Sorry, something went wrong.
dgibson
|
||
new->was_deleted = 1; | ||
new->srcpos = srcpos_copy(srcpos); | ||
} | ||
|
||
return new; | ||
} | ||
|
@@ -112,6 +119,9 @@ struct node *build_node_delete(struct srcpos *srcpos) | |
|
||
new->deleted = 1; | ||
new->srcpos = srcpos_copy(srcpos); | ||
if (annotate > 3) { | ||
new->was_deleted = 1; | ||
} | ||
|
||
return new; | ||
} | ||
|
@@ -159,7 +169,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |
new_node->proplist = new_prop->next; | ||
new_prop->next = NULL; | ||
|
||
if (new_prop->deleted) { | ||
if (new_prop->deleted && annotate <= 3) { | ||
delete_property_by_name(old_node, new_prop->name); | ||
free(new_prop); | ||
continue; | ||
|
@@ -173,9 +183,19 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |
add_label(&old_prop->labels, l->label); | ||
|
||
old_prop->val = new_prop->val; | ||
old_prop->deleted = 0; | ||
free(old_prop->srcpos); | ||
old_prop->srcpos = new_prop->srcpos; | ||
|
||
if (annotate > 3) | ||
old_prop->was_deleted = new_prop->deleted; | ||
else | ||
old_prop->deleted = 0; | ||
|
||
if (annotate > 2) { | ||
old_prop->srcpos = srcpos_extend(old_prop->srcpos, new_prop->srcpos); | ||
} else { | ||
free(old_prop->srcpos); | ||
old_prop->srcpos = new_prop->srcpos; | ||
} | ||
|
||
free(new_prop); | ||
new_prop = NULL; | ||
break; | ||
|
@@ -197,7 +217,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |
new_child->next_sibling = NULL; | ||
|
||
if (new_child->deleted) { | ||
delete_node_by_name(old_node, new_child->name); | ||
delete_node_by_name(old_node, new_child->name, new_child->srcpos); | ||
free(new_child); | ||
continue; | ||
} | ||
|
@@ -217,6 +237,8 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node) | |
} | ||
|
||
old_node->srcpos = srcpos_extend(old_node->srcpos, new_node->srcpos); | ||
if (old_node->was_deleted && !new_node->was_deleted) | ||
old_node->was_deleted = 0; | ||
|
||
/* The new node contents are now merged into the old node. Free | ||
* the new node. */ | ||
|
@@ -293,6 +315,11 @@ void delete_property(struct property *prop) | |
{ | ||
prop->deleted = 1; | ||
delete_labels(&prop->labels); | ||
if (annotate > 3) { | ||
prop->was_deleted = 1; | ||
if (annotate > 4) | ||
prop->deleted = 0; | ||
} | ||
} | ||
|
||
void add_child(struct node *parent, struct node *child) | ||
|
@@ -309,13 +336,28 @@ void add_child(struct node *parent, struct node *child) | |
*p = child; | ||
} | ||
|
||
void delete_node_by_name(struct node *parent, char *name) | ||
void delete_node_by_name(struct node *parent, char *name, struct srcpos *srcpos) | ||
{ | ||
struct node *node = parent->children; | ||
struct srcpos *pos = NULL; | ||
|
||
while (node) { | ||
if (streq(node->name, name)) { | ||
|
||
if (annotate > 3) { | ||
srcpos->first_line = srcpos->last_line; | ||
pos = srcpos_copy(srcpos); | ||
pos = srcpos_extend(node->srcpos, pos); | ||
} | ||
|
||
delete_node(node); | ||
|
||
if (annotate == 4) { | ||
node = build_and_name_child_node(parent, name); | ||
node->srcpos = pos; | ||
node->was_deleted = 1; | ||
} | ||
|
||
return; | ||
} | ||
node = node->next_sibling; | ||
|
@@ -328,6 +370,11 @@ void delete_node(struct node *node) | |
struct node *child; | ||
|
||
node->deleted = 1; | ||
if (annotate > 3) { | ||
node->was_deleted = 1; | ||
if (annotate > 4) | ||
node->deleted = 0; | ||
} | ||
for_each_child(node, child) | ||
delete_node(child); | ||
for_each_property(node, prop) | ||
|
@@ -605,11 +652,11 @@ cell_t get_node_phandle(struct node *root, struct node *node) | |
d = data_add_marker(d, TYPE_UINT32, NULL); | ||
d = data_append_cell(d, phandle); | ||
|
||
if (!get_property(node, "linux,phandle") | ||
if (!get_property(node, "linux,phandle") && !node->was_deleted | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bmx666
Author
Owner
|
||
&& (phandle_format & PHANDLE_LEGACY)) | ||
add_property(node, build_property("linux,phandle", d, NULL)); | ||
|
||
if (!get_property(node, "phandle") | ||
if (!get_property(node, "phandle") && !node->was_deleted | ||
&& (phandle_format & PHANDLE_EPAPR)) | ||
add_property(node, build_property("phandle", d, NULL)); | ||
|
||
|
@@ -849,6 +896,10 @@ static void generate_label_tree_internal(struct dt_info *dti, | |
data_copy_escape_string(node->fullpath, | ||
strlen(node->fullpath)), | ||
NULL); | ||
|
||
if (annotate > 4) | ||
p->was_deleted = l->was_deleted; | ||
|
||
add_property(an, p); | ||
} | ||
|
||
|
It's not obvious to me why this has to change to a
delete_node_by_name
as well as adding the srcpos argument.