subsys/testsuite: Don't add empty z_malloc_partition to mem domain

The malloc partition may actually be empty, if so, don't try to add it to
the domain as that will generate an error.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2022-06-27 15:49:03 -07:00 committed by Carles Cufí
commit 34473f6821

View file

@ -538,12 +538,15 @@ void main(void)
}
#ifdef Z_MALLOC_PARTITION_EXISTS
/* Allow access to malloc() memory */
ret = k_mem_domain_add_partition(&k_mem_domain_default,
&z_malloc_partition);
if (ret != 0) {
PRINT("ERROR: failed to add z_malloc_partition to mem domain (%d)\n",
ret);
k_oops();
if (z_malloc_partition.size != 0) {
ret = k_mem_domain_add_partition(&k_mem_domain_default,
&z_malloc_partition);
if (ret != 0) {
PRINT("ERROR: failed to add z_malloc_partition"
" to mem domain (%d)\n",
ret);
k_oops();
}
}
#endif
#endif /* CONFIG_USERSPACE */