Deleted Added
full compact
checks.c (204431) checks.c (204433)
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 265 unchanged lines hidden (view full) ---

274
275 if (n < strlen(prop->name))
276 FAIL(c, "Bad character '%c' in property name \"%s\", node %s",
277 prop->name[n], prop->name, node->fullpath);
278}
279PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
280
281static void check_explicit_phandles(struct check *c, struct node *root,
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 265 unchanged lines hidden (view full) ---

274
275 if (n < strlen(prop->name))
276 FAIL(c, "Bad character '%c' in property name \"%s\", node %s",
277 prop->name[n], prop->name, node->fullpath);
278}
279PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
280
281static void check_explicit_phandles(struct check *c, struct node *root,
282 struct node *node)
282 struct node *node, struct property *prop)
283{
283{
284 struct property *prop;
284 struct marker *m;
285 struct node *other;
286 cell_t phandle;
287
285 struct node *other;
286 cell_t phandle;
287
288 prop = get_property(node, "linux,phandle");
289 if (! prop)
290 return; /* No phandle, that's fine */
288 if (!streq(prop->name, "phandle")
289 && !streq(prop->name, "linux,phandle"))
290 return;
291
292 if (prop->val.len != sizeof(cell_t)) {
291
292 if (prop->val.len != sizeof(cell_t)) {
293 FAIL(c, "%s has bad length (%d) linux,phandle property",
294 node->fullpath, prop->val.len);
293 FAIL(c, "%s has bad length (%d) %s property",
294 node->fullpath, prop->val.len, prop->name);
295 return;
296 }
297
295 return;
296 }
297
298 m = prop->val.markers;
299 for_each_marker_of_type(m, REF_PHANDLE) {
300 assert(m->offset == 0);
301 if (node != get_node_by_ref(root, m->ref))
302 /* "Set this node's phandle equal to some
303 * other node's phandle". That's nonsensical
304 * by construction. */ {
305 FAIL(c, "%s in %s is a reference to another node",
306 prop->name, node->fullpath);
307 return;
308 }
309 /* But setting this node's phandle equal to its own
310 * phandle is allowed - that means allocate a unique
311 * phandle for this node, even if it's not otherwise
312 * referenced. The value will be filled in later, so
313 * no further checking for now. */
314 return;
315 }
316
298 phandle = propval_cell(prop);
317 phandle = propval_cell(prop);
318
299 if ((phandle == 0) || (phandle == -1)) {
319 if ((phandle == 0) || (phandle == -1)) {
300 FAIL(c, "%s has invalid linux,phandle value 0x%x",
301 node->fullpath, phandle);
320 FAIL(c, "%s has bad value (0x%x) in %s property",
321 node->fullpath, phandle, prop->name);
302 return;
303 }
304
322 return;
323 }
324
325 if (node->phandle && (node->phandle != phandle))
326 FAIL(c, "%s has %s property which replaces existing phandle information",
327 node->fullpath, prop->name);
328
305 other = get_node_by_phandle(root, phandle);
329 other = get_node_by_phandle(root, phandle);
306 if (other) {
330 if (other && (other != node)) {
307 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
308 node->fullpath, phandle, other->fullpath);
309 return;
310 }
311
312 node->phandle = phandle;
313}
331 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
332 node->fullpath, phandle, other->fullpath);
333 return;
334 }
335
336 node->phandle = phandle;
337}
314NODE_CHECK(explicit_phandles, NULL, ERROR);
338PROP_CHECK(explicit_phandles, NULL, ERROR);
315
316static void check_name_properties(struct check *c, struct node *root,
317 struct node *node)
318{
319 struct property **pp, *prop = NULL;
320
321 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
322 if (streq((*pp)->name, "name")) {

--- 265 unchanged lines hidden ---
339
340static void check_name_properties(struct check *c, struct node *root,
341 struct node *node)
342{
343 struct property **pp, *prop = NULL;
344
345 for (pp = &node->proplist; *pp; pp = &((*pp)->next))
346 if (streq((*pp)->name, "name")) {

--- 265 unchanged lines hidden ---