From: Frank Mehnert <frank.mehnert-2ptZNfhJYoRaodhZ+FW2PA@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: libfdt / fdt_check_node_offset_ with VALID_INPUT
Date: Wed, 12 Aug 2020 17:48:56 +0200 [thread overview]
Message-ID: <34725235.0rVAnNm8GT@noys4> (raw)
Hi all,
I'm not sure if I found a bug or if I mis-use libfdt.
I have a valid Linux device tree in memory and want to recursively scan
thru it. The device tree contains a root node and several subnodes.
First, I start with the root node:
int root = fdt_next_node(fdt, -1, NULL);
Here, root is set to 0. Now I determine the offset of the first sub node:
int subnode = fdt_first_subnode(fdt, root);
Here, subnode is either 0 if FDT_ASSUME_MASK contains ASSUME_VALID_INPUT
or 164 (in my case) if FDT_ASSUME_MASK does not contain ASSUME_VALID_INPUT.
As far as I understand, fdt_first_subnode() should not return the node
offset of the current node if there are subnodes available.
I think the problem origins at fdt_check_node_offset_() in fdt.c: If
VALID_INPUT is set, the whole code in that function is skipped. If that
flag is not set then fdt_next_tag(fdt, offset, &offset) is called and
the resulting 'offset' is returned.
In other words, fdt_check_node_offset_() has a side effect which depends
on the VALID_INPUT flag.
Thanks!
Frank
next reply other threads:[~2020-08-12 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 15:48 Frank Mehnert [this message]
2020-08-13 7:09 ` libfdt / fdt_check_node_offset_ with VALID_INPUT David Gibson
[not found] ` <20200813070945.GD17532-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-08-13 8:06 ` Frank Mehnert
2020-08-18 16:19 ` Rob Herring
[not found] ` <CAL_JsqLAWa-wMMiD=VffemMiqAv-3=GNehNojWrFQqED_+QDow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-08-20 10:18 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34725235.0rVAnNm8GT@noys4 \
--to=frank.mehnert-2ptznfhjyoraodhz+fw2pa@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).