summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2022-11-18 09:43:51 -0600
committerJoel Sherrill <joel@rtems.org>2022-11-18 16:02:46 -0600
commit5b7eea631de68267ba73a5a454576e5816e6eb9f (patch)
treec3efe3f6d5f3185dcbb202777ba143d8300f5a3c
parentbsps/zynqmp: Use direct fdt_* calls (diff)
downloadrtems-5b7eea631de68267ba73a5a454576e5816e6eb9f.tar.bz2
cpukit/rtems-fdt: Avoid use of malloc/errno
Use of malloc implies errno which adds TLS dependencies and prevents use of this FDT wrapper library in BSP initialization code. This change makes use of rtems_malloc and rtems_calloc which avoid TLS dependencies.
-rw-r--r--cpukit/libmisc/rtems-fdt/rtems-fdt.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
index 1e382ca108..e5bab21664 100644
--- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c
+++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c
@@ -25,9 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <errno.h>
#include <fcntl.h>
-#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -35,6 +33,7 @@
#include <libfdt.h>
#include <zlib.h>
+#include <rtems/malloc.h>
#include <rtems/rtems-fdt.h>
#include <rtems/thread.h>
@@ -175,13 +174,13 @@ rtems_fdt_init_index (rtems_fdt_handle* fdt, rtems_fdt_blob* blob)
/*
* Create the index.
*/
- entries = calloc(num_entries, sizeof(rtems_fdt_index_entry));
+ entries = rtems_calloc(num_entries, sizeof(rtems_fdt_index_entry));
if (!entries)
{
return -RTEMS_FDT_ERR_NO_MEMORY;
}
- names = calloc(1, total_name_memory);
+ names = rtems_calloc(1, total_name_memory);
if (!names)
{
free(entries);
@@ -505,7 +504,7 @@ rtems_fdt_load (const char* filename, rtems_fdt_handle* handle)
{
size_t offset;
- cdata = malloc(sb.st_size);
+ cdata = rtems_malloc(sb.st_size);
if (!cdata)
{
close (bf);
@@ -546,7 +545,7 @@ rtems_fdt_load (const char* filename, rtems_fdt_handle* handle)
name_len = strlen (filename) + 1;
- blob = malloc(sizeof (rtems_fdt_blob) + name_len + bsize);
+ blob = rtems_malloc(sizeof (rtems_fdt_blob) + name_len + bsize);
if (!blob)
{
free(cdata);
@@ -649,7 +648,7 @@ rtems_fdt_register (const void* dtb, rtems_fdt_handle* handle)
return fe;
}
- blob = malloc(sizeof (rtems_fdt_blob));
+ blob = rtems_malloc(sizeof (rtems_fdt_blob));
if (!blob)
{
return -RTEMS_FDT_ERR_NO_MEMORY;