| Summary: | [patch] Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Stanislav Galabov <sgalabov> | ||||
| Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | CC: | sgalabov, sgalabov | ||||
| Priority: | --- | Keywords: | patch | ||||
| Version: | CURRENT | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
This bug is now followed at: https://reviews.freebsd.org/D5043 Will continue work there. |
Created attachment 165990 [details] Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list Currently, there is no easy way to know in advance how many entries a list parsed by ofw_bus_parse_xref_list_alloc() in sys/dev/ofw/ofw_bus_subr.c has. The attached patch allows us to pass an idx of -1 to ofw_bus_parse_xref_list_alloc(), in which case it would either return an error (negative) or the number of entries in the parsed list (non-negative). This would be useful if we don't know in advance how many entries such a list has, but we need to get them (and store them) all - we can call ofw_bus_parse_xref_list_alloc with idx = -1, see how many entries to allocate memory for, and then loop through the entries to get each one of them.