Rev 1895 | Rev 1907 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1895 | Rev 1896 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | return balloc(count * sizeof(ofw_tree_property_t), sizeof(ofw_tree_property_t)); |
45 | return balloc(count * sizeof(ofw_tree_property_t), sizeof(ofw_tree_property_t)); |
46 | } |
46 | } |
47 | 47 | ||
48 | static void * ofw_tree_space_alloc(size_t size) |
48 | static void * ofw_tree_space_alloc(size_t size) |
49 | { |
49 | { |
- | 50 | char *addr; |
|
- | 51 | ||
- | 52 | /* |
|
- | 53 | * What we do here is a nasty hack :-) |
|
- | 54 | * Problem: string property values that are allocated via this |
|
- | 55 | * function typically do not contain the trailing '\0'. This |
|
- | 56 | * is very uncomfortable for kernel, which is supposed to deal |
|
- | 57 | * with the properties. |
|
- | 58 | * Solution: when allocating space via this function, we always |
|
- | 59 | * allocate space for the extra '\0' character that we store |
|
- | 60 | * behind the requested memory. |
|
- | 61 | */ |
|
50 | return balloc(size, size); |
62 | addr = balloc(size + 1, size); |
- | 63 | if (addr) |
|
- | 64 | addr[size] = '\0'; |
|
- | 65 | return addr; |
|
51 | } |
66 | } |
52 | 67 | ||
53 | /** Transfer information from one OpenFirmware node into its memory representation. |
68 | /** Transfer information from one OpenFirmware node into its memory representation. |
54 | * |
69 | * |
55 | * Transfer entire information from the OpenFirmware device tree 'current' node to |
70 | * Transfer entire information from the OpenFirmware device tree 'current' node to |
Line 151... | Line 166... | ||
151 | size_t size; |
166 | size_t size; |
152 | 167 | ||
153 | if (i == current_node->properties) |
168 | if (i == current_node->properties) |
154 | break; |
169 | break; |
155 | 170 | ||
156 | strncpy(current_node->property[i].name, name, sizeof(name)); |
171 | memcpy(current_node->property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN); |
- | 172 | current_node->property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN] = '\0'; |
|
157 | 173 | ||
158 | size = ofw_get_proplen(current, name); |
174 | size = ofw_get_proplen(current, name); |
159 | current_node->property[i].size = size; |
175 | current_node->property[i].size = size; |
160 | if (size) { |
176 | if (size) { |
161 | void *buf; |
177 | void *buf; |