base: remove internal use of format strings

Issue #2064
This commit is contained in:
Norman Feske 2023-03-06 10:57:13 +01:00 committed by Christian Helmuth
parent 9debad4e91
commit 915adcd0dd
20 changed files with 101 additions and 144 deletions

View File

@ -117,8 +117,7 @@ inline int lx_ioctl_irq(int fd, int irq)
** Process creation and destruction ** ** Process creation and destruction **
**************************************/ **************************************/
inline int lx_execve(const char *filename, char *const argv[], inline int lx_execve(char const *filename, char const *argv[], char const *envp[])
char *const envp[])
{ {
return (int)lx_syscall(SYS_execve, filename, argv, envp); return (int)lx_syscall(SYS_execve, filename, argv, envp);
} }

View File

@ -18,7 +18,7 @@
#include <linux_syscalls.h> #include <linux_syscalls.h>
/* Genode includes */ /* Genode includes */
#include <base/snprintf.h> #include <util/string.h>
/** /**
* Return resource path for Genode * Return resource path for Genode
@ -27,18 +27,8 @@
*/ */
static inline char const *resource_path() static inline char const *resource_path()
{ {
struct Resource_path static Genode::String<32> path("/tmp/genode-", lx_getuid());
{ return path.string();
char string[32];
Resource_path()
{
Genode::snprintf(string, sizeof(string), "/tmp/genode-%d", lx_getuid());
}
};
static Resource_path path;
return path.string;
} }
#endif /* _CORE__INCLUDE__RESOURCE_PATH_H_ */ #endif /* _CORE__INCLUDE__RESOURCE_PATH_H_ */

View File

@ -13,7 +13,6 @@
/* Genode includes */ /* Genode includes */
#include <util/arg_string.h> #include <util/arg_string.h>
#include <base/snprintf.h>
#include <cpu/consts.h> #include <cpu/consts.h>
/* core includes */ /* core includes */
@ -42,8 +41,8 @@ struct Execve_args_and_stack
struct Args struct Args
{ {
char const *filename; char const *filename;
char **argv; char const **argv;
char **envp; char const **envp;
Lx_sd parent_sd; Lx_sd parent_sd;
}; };
@ -111,8 +110,7 @@ void Native_pd_component::_start(Dataspace_component &ds)
const char *tmp_filename = "temporary_executable_elf_dataspace_file_for_execve"; const char *tmp_filename = "temporary_executable_elf_dataspace_file_for_execve";
/* we need 's' on stack to make it an lvalue with an lvalue member we use the pointer to */ /* we need 's' on stack to make it an lvalue with an lvalue member we use the pointer to */
Linux_dataspace::Filename s = ds.fname(); Linux_dataspace::Filename filename = ds.fname();
const char *filename = s.buf;
/* /*
* In order to be executable via 'execve', a program must be represented as * In order to be executable via 'execve', a program must be represented as
@ -121,11 +119,11 @@ void Native_pd_component::_start(Dataspace_component &ds)
* the dataspace content into a temporary file whose path is passed to * the dataspace content into a temporary file whose path is passed to
* 'execve()'. * 'execve()'.
*/ */
if (Genode::strcmp(filename, "") == 0) { if (filename == "") {
filename = tmp_filename; filename = tmp_filename;
int tmp_binary_fd = lx_open(filename, O_CREAT | O_EXCL | O_WRONLY, S_IRWXU); int tmp_binary_fd = lx_open(filename.string(), O_CREAT | O_EXCL | O_WRONLY, S_IRWXU);
if (tmp_binary_fd < 0) { if (tmp_binary_fd < 0) {
error("Could not create file '", filename, "'"); error("Could not create file '", filename, "'");
return; /* XXX reflect error to client */ return; /* XXX reflect error to client */
@ -141,30 +139,24 @@ void Native_pd_component::_start(Dataspace_component &ds)
} }
/* pass parent capability as environment variable to the child */ /* pass parent capability as environment variable to the child */
enum { ENV_STR_LEN = 256 }; using Env_string = String<256>;
static char envbuf[5][ENV_STR_LEN]; static Env_string env_strings[] {
Genode::snprintf(envbuf[1], ENV_STR_LEN, "parent_local_name=%lu", { "parent_local_name=", _pd_session._parent.local_name() },
_pd_session._parent.local_name()); { "DISPLAY=", get_env("DISPLAY") },
Genode::snprintf(envbuf[2], ENV_STR_LEN, "DISPLAY=%s", { "HOME=", get_env("HOME") },
get_env("DISPLAY")); { "LD_LIBRARY_PATH=", get_env("LD_LIBRARY_PATH") },
Genode::snprintf(envbuf[3], ENV_STR_LEN, "HOME=%s", };
get_env("HOME")); char const *env[] = { env_strings[0].string(), env_strings[1].string(),
Genode::snprintf(envbuf[4], ENV_STR_LEN, "LD_LIBRARY_PATH=%s", env_strings[2].string(), env_strings[3].string(),
get_env("LD_LIBRARY_PATH")); nullptr };
char *env[] = { &envbuf[0][0], &envbuf[1][0], &envbuf[2][0],
&envbuf[3][0], &envbuf[4][0], 0 };
/* prefix name of Linux program (helps killing some zombies) */ /* prefix name of Linux program (helps killing some zombies) */
char const *prefix = "[Genode] "; using Pname = String<Session::Label::capacity() + 9>;
char pname_buf[sizeof(_pd_session._label) + sizeof(prefix)]; Pname const pname("[Genode] ", _pd_session._label);
snprintf(pname_buf, sizeof(pname_buf), "%s%s", prefix, _pd_session._label.string()); char const *argv_buf[] { pname.string(), nullptr };
char *argv_buf[2];
argv_buf[0] = pname_buf;
argv_buf[1] = 0;
_execve_args_and_stack().args = Execve_args_and_stack::Args { _execve_args_and_stack().args = Execve_args_and_stack::Args {
.filename = filename, .filename = filename.string(),
.argv = argv_buf, .argv = argv_buf,
.envp = env, .envp = env,
.parent_sd = Capability_space::ipc_cap_data(_pd_session._parent).dst.socket .parent_sd = Capability_space::ipc_cap_data(_pd_session._parent).dst.socket
@ -173,8 +165,8 @@ void Native_pd_component::_start(Dataspace_component &ds)
_pid = lx_create_process((int (*)())_exec_child, _pid = lx_create_process((int (*)())_exec_child,
_execve_args_and_stack().initial_sp()); _execve_args_and_stack().initial_sp());
if (Genode::strcmp(filename, tmp_filename) == 0) if (filename == tmp_filename)
lx_unlink(filename); lx_unlink(filename.string());
} }

View File

@ -14,9 +14,6 @@
/* glibc includes */ /* glibc includes */
#include <fcntl.h> #include <fcntl.h>
/* Genode includes */
#include <base/snprintf.h>
/* local includes */ /* local includes */
#include <ram_dataspace_factory.h> #include <ram_dataspace_factory.h>
#include <resource_path.h> #include <resource_path.h>
@ -35,12 +32,11 @@ static int ram_ds_cnt = 0; /* counter for creating unique dataspace IDs */
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &ds) void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &ds)
{ {
char fname[Linux_dataspace::FNAME_LEN]; Linux_dataspace::Filename const fname(resource_path(), "/ds-", ram_ds_cnt++);
/* create file using a unique file name in the resource path */ /* create file using a unique file name in the resource path */
snprintf(fname, sizeof(fname), "%s/ds-%d", resource_path(), ram_ds_cnt++); lx_unlink(fname.string());
lx_unlink(fname); int const fd = lx_open(fname.string(), O_CREAT|O_RDWR|O_TRUNC|LX_O_CLOEXEC, S_IRWXU);
int const fd = lx_open(fname, O_CREAT|O_RDWR|O_TRUNC|LX_O_CLOEXEC, S_IRWXU);
lx_ftruncate(fd, ds.size()); lx_ftruncate(fd, ds.size());
/* remember file descriptor in dataspace component object */ /* remember file descriptor in dataspace component object */
@ -52,7 +48,7 @@ void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &ds)
* gone (i.e., an open file descriptor referring to the file). A process * gone (i.e., an open file descriptor referring to the file). A process
* w/o the right file descriptor won't be able to open and access the file. * w/o the right file descriptor won't be able to open and access the file.
*/ */
lx_unlink(fname); lx_unlink(fname.string());
} }

View File

@ -21,13 +21,10 @@
/* Genode includes */ /* Genode includes */
#include <linux_dataspace/linux_dataspace.h> #include <linux_dataspace/linux_dataspace.h>
#include <util/arg_string.h>
#include <util/misc_math.h>
#include <root/root.h>
#include <base/session_label.h> #include <base/session_label.h>
/* local includes */ /* local includes */
#include "dataspace_component.h" #include <dataspace_component.h>
using namespace Core; using namespace Core;
@ -35,17 +32,15 @@ using namespace Core;
Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
{ {
Session_label const label = label_from_args(args); Session_label const label = label_from_args(args);
Linux_dataspace::Filename fname; if (label.last_element().length() > Linux_dataspace::Filename::capacity()) {
if (label.last_element().length() > sizeof(fname.buf)) {
error("file name too long: ", label.last_element()); error("file name too long: ", label.last_element());
throw Service_denied(); throw Service_denied();
} }
copy_cstring(fname.buf, label.last_element().string(), sizeof(fname.buf)); Linux_dataspace::Filename const fname = label.last_element();
/* only files inside the current working directory are allowed */ /* only files inside the current working directory are allowed */
for (const char *c = fname.buf; *c; ++c) for (const char *c = fname.string(); *c; ++c)
if (*c == '/') throw Service_denied(); if (*c == '/') throw Service_denied();
return fname; return fname;
@ -55,7 +50,7 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
size_t Dataspace_component::_file_size() size_t Dataspace_component::_file_size()
{ {
Genode::uint64_t size = 0; Genode::uint64_t size = 0;
if (lx_stat_size(_fname.buf, size) < 0) if (lx_stat_size(_fname.string(), size) < 0)
throw Service_denied(); throw Service_denied();
return align_addr((size_t)size, 12); return align_addr((size_t)size, 12);
@ -67,7 +62,7 @@ Dataspace_component::Dataspace_component(const char *args)
_fname(_file_name(args)), _fname(_file_name(args)),
_size(_file_size()), _size(_file_size()),
_addr(0), _addr(0),
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))), _cap(_fd_to_cap(lx_open(_fname.string(), O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
_writeable(false), _writeable(false),
_owner(0) _owner(0)
{ } { }
@ -79,5 +74,4 @@ Dataspace_component::Dataspace_component(size_t size, addr_t, addr_t phys_addr,
_size(size), _addr(phys_addr), _cap(), _writeable(false), _owner(_owner) _size(size), _addr(phys_addr), _cap(), _writeable(false), _owner(_owner)
{ {
warning("Should only be used for IOMEM and not within Linux."); warning("Should only be used for IOMEM and not within Linux.");
_fname.buf[0] = 0;
} }

View File

@ -16,16 +16,15 @@
#include <dataspace/dataspace.h> #include <dataspace/dataspace.h>
#include <base/stdint.h> #include <base/stdint.h>
#include <base/ipc.h>
#include <base/rpc.h> #include <base/rpc.h>
#include <base/ipc.h>
namespace Genode { struct Linux_dataspace; } namespace Genode { struct Linux_dataspace; }
struct Genode::Linux_dataspace : Dataspace struct Genode::Linux_dataspace : Dataspace
{ {
enum { FNAME_LEN = 64 }; using Filename = String<64>;
struct Filename { char buf[FNAME_LEN]; };
virtual ~Linux_dataspace() { } virtual ~Linux_dataspace() { }
@ -42,11 +41,11 @@ struct Genode::Linux_dataspace : Dataspace
*/ */
virtual Untyped_capability fd() = 0; virtual Untyped_capability fd() = 0;
/********************* /*********************
** RPC declaration ** ** RPC declaration **
*********************/ *********************/
GENODE_RPC(Rpc_fname, Filename, fname); GENODE_RPC(Rpc_fname, Filename, fname);
GENODE_RPC(Rpc_fd, Untyped_capability, fd); GENODE_RPC(Rpc_fd, Untyped_capability, fd);
GENODE_RPC_INTERFACE_INHERIT(Dataspace, Rpc_fname, Rpc_fd); GENODE_RPC_INTERFACE_INHERIT(Dataspace, Rpc_fname, Rpc_fd);

View File

@ -15,7 +15,6 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/thread.h> #include <base/thread.h>
#include <base/snprintf.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/log.h> #include <base/log.h>
#include <linux_native_cpu/client.h> #include <linux_native_cpu/client.h>

View File

@ -36,7 +36,6 @@
/* Genode includes */ /* Genode includes */
#include <util/string.h> #include <util/string.h>
#include <base/snprintf.h>
#include <base/log.h> #include <base/log.h>
#include <base/sleep.h> #include <base/sleep.h>
@ -77,14 +76,6 @@
extern "C" void wait_for_continue(void); extern "C" void wait_for_continue(void);
#define PRAW(fmt, ...) \
do { \
char str[128]; \
Genode::snprintf(str, sizeof(str), \
ESC_ERR fmt ESC_END "\n", ##__VA_ARGS__); \
Genode::raw(Genode::Cstring(str)); \
} while (0)
/********************************************************* /*********************************************************
** System-call bindings implemented in syscall library ** ** System-call bindings implemented in syscall library **

View File

@ -15,9 +15,7 @@
#include <base/heap.h> #include <base/heap.h>
#include <base/thread.h> #include <base/thread.h>
#include <base/log.h> #include <base/log.h>
#include <base/snprintf.h>
#include <base/component.h> #include <base/component.h>
#include <util/touch.h> #include <util/touch.h>
#include <util/retry.h> #include <util/retry.h>
#include <rm_session/connection.h> #include <rm_session/connection.h>
@ -625,24 +623,18 @@ class Greedy : public Genode::Thread {
} }
}; };
void check(uint8_t res, const char *format, ...)
template <typename... ARGS>
void check(uint8_t res, ARGS &&... args)
{ {
static char buf[128]; String<128> msg(args...);
va_list list;
va_start(list, format);
String_console sc(buf, sizeof(buf));
sc.vprintf(format, list);
va_end(list);
if (res == Nova::NOVA_OK) { if (res == Nova::NOVA_OK) {
error("res=", res, " ", Cstring(buf), " - TEST FAILED"); error("res=", res, " ", msg, " - TEST FAILED");
failed++; failed++;
} }
else else
log("res=", res, " ", Cstring(buf)); log("res=", res, " ", msg);
} }
struct Main struct Main
@ -708,7 +700,7 @@ Main::Main(Env &env) : env(env)
for (unsigned i = 0; i < (1U << Nova::NUM_INITIAL_PT_LOG2); i++) { for (unsigned i = 0; i < (1U << Nova::NUM_INITIAL_PT_LOG2); i++) {
addr_t sel_exc = myself->native_thread().exc_pt_sel + i; addr_t sel_exc = myself->native_thread().exc_pt_sel + i;
res = Nova::pt_ctrl(sel_exc, 0xbadbad); res = Nova::pt_ctrl(sel_exc, 0xbadbad);
check(res, "pt_ctrl %2u", i); check(res, "pt_ctrl ", i);
} }
/* test PAT kernel feature */ /* test PAT kernel feature */

View File

@ -18,18 +18,16 @@
#define _INCLUDE__BASE__INTERNAL__ASSERT_H_ #define _INCLUDE__BASE__INTERNAL__ASSERT_H_
/* Genode includes */ /* Genode includes */
#include <base/snprintf.h> #include <util/string.h>
/* base-internal includes */ /* base-internal includes */
#include <base/internal/kernel_debugger.h> #include <base/internal/kernel_debugger.h>
#define ASSERT(e) \ #define ASSERT(e) \
do { if (!(e)) { \ do { if (!(e)) { \
char line_buf[32]; \
Genode::snprintf(line_buf, sizeof(line_buf), "%d", __LINE__); \
kernel_debugger_outstring("Assertion failed: " #e "\n"); \ kernel_debugger_outstring("Assertion failed: " #e "\n"); \
kernel_debugger_outstring(__FILE__ ":"); \ kernel_debugger_outstring(__FILE__ ":"); \
kernel_debugger_outstring(line_buf); \ kernel_debugger_outstring(Genode::String<32>(__LINE__).string()); \
kernel_debugger_panic("\n"); \ kernel_debugger_panic("\n"); \
} \ } \
} while(0) } while(0)

View File

@ -18,6 +18,7 @@
#include <base/env.h> #include <base/env.h>
#include <base/capability.h> #include <base/capability.h>
#include <base/log.h> #include <base/log.h>
#include <base/snprintf.h> /* deprecated */
namespace Genode { namespace Genode {

View File

@ -15,7 +15,6 @@
#ifndef _INCLUDE__BASE__SESSION_LABEL_H_ #ifndef _INCLUDE__BASE__SESSION_LABEL_H_
#define _INCLUDE__BASE__SESSION_LABEL_H_ #define _INCLUDE__BASE__SESSION_LABEL_H_
#include <base/snprintf.h>
#include <util/arg_string.h> #include <util/arg_string.h>
#include <util/string.h> #include <util/string.h>
@ -40,8 +39,7 @@ struct Genode::Session_label : String<160>
* copy constructors as candidate. * copy constructors as candidate.
*/ */
template <size_t N> template <size_t N>
Session_label(Genode::String<N> const &other) Session_label(Genode::String<N> const &other) : Genode::String<160>(other) { }
: Genode::String<160>(other) { }
Session_label last_element() const Session_label last_element() const
{ {

View File

@ -24,7 +24,6 @@
#include <cpu_session/capability.h> #include <cpu_session/capability.h>
#include <pd_session/capability.h> #include <pd_session/capability.h>
#include <base/allocator.h> #include <base/allocator.h>
#include <base/snprintf.h>
namespace Genode { namespace Genode {

View File

@ -29,7 +29,6 @@
#include <util/token.h> #include <util/token.h>
#include <util/string.h> #include <util/string.h>
#include <base/snprintf.h>
namespace Genode { namespace Genode {
@ -329,10 +328,8 @@ class Genode::Arg_string
static bool set_arg(char *args, size_t args_len, static bool set_arg(char *args, size_t args_len,
const char *key, int value) const char *key, int value)
{ {
enum { STRING_LONG_MAX = 32 }; return remove_arg(args, key)
char buf[STRING_LONG_MAX]; && add_arg(args, args_len, key, String<16>(value).string());
snprintf(buf, sizeof(buf), "%d", value);
return remove_arg(args, key) && add_arg(args, args_len, key, buf);
} }
/** /**

View File

@ -16,7 +16,6 @@
#include <util/string.h> #include <util/string.h>
#include <util/print_lines.h> #include <util/print_lines.h>
#include <base/snprintf.h>
namespace Genode { class Xml_generator; } namespace Genode { class Xml_generator; }
@ -336,9 +335,7 @@ class Genode::Xml_generator
void attribute(char const *name, long long value) void attribute(char const *name, long long value)
{ {
char buf[64]; _curr_node->insert_attribute(name, String<64>(value).string());
Genode::snprintf(buf, sizeof(buf), "%lld", value);
_curr_node->insert_attribute(name, buf);
} }
void attribute(char const *name, long value) void attribute(char const *name, long value)
@ -353,9 +350,7 @@ class Genode::Xml_generator
void attribute(char const *name, unsigned long long value) void attribute(char const *name, unsigned long long value)
{ {
char buf[64]; _curr_node->insert_attribute(name, String<64>(value).string());
Genode::snprintf(buf, sizeof(buf), "%llu", value);
_curr_node->insert_attribute(name, buf);
} }
void attribute(char const *name, unsigned long value) void attribute(char const *name, unsigned long value)

View File

@ -100,8 +100,8 @@ grep_output {\[init -\> test-smp\] Affinity: Round}
set rounds "10" set rounds "10"
set good_string {} set good_string {}
for {set r 0} {$r <= $rounds} {incr r} { for {set r 0} {$r <= $rounds} {incr r} {
append good_string {[init -> test-smp] Affinity: Round } append good_string {[init -> test-smp] Affinity: Round }
append good_string [format "%02d" $r] append good_string [format "%2d" $r]
append good_string ":" append good_string ":"
for {set i 0} {$i < $cpus} {incr i} { for {set i 0} {$i < $cpus} {incr i} {
append good_string " A" append good_string " A"

View File

@ -12,7 +12,6 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/snprintf.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/service.h> #include <base/service.h>
#include <base/child.h> #include <base/child.h>

View File

@ -18,7 +18,6 @@
#include <base/thread.h> #include <base/thread.h>
#include <base/env.h> #include <base/env.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/snprintf.h>
#include <deprecated/env.h> #include <deprecated/env.h>
/* base-internal includes */ /* base-internal includes */
@ -133,7 +132,7 @@ void Thread::_free_stack(Stack *stack)
void Thread::name(char *dst, size_t dst_len) void Thread::name(char *dst, size_t dst_len)
{ {
snprintf(dst, dst_len, "%s", _stack->name().string()); copy_cstring(dst, name().string(), dst_len);
} }

View File

@ -19,6 +19,7 @@
#include <base/log.h> #include <base/log.h>
#include <base/rpc_server.h> #include <base/rpc_server.h>
#include <base/rpc_client.h> #include <base/rpc_client.h>
#include <util/formatted_output.h>
#include <trace/timestamp.h> #include <trace/timestamp.h>
@ -203,42 +204,59 @@ namespace Affinity_test {
volatile uint64_t cnt = 0; volatile uint64_t cnt = 0;
unsigned round = 0; unsigned round = 0;
char const text_cpu[] = "Affinity: CPU: "; static char const text_cpu[] = "Affinity: CPU: ";
char const text_round[] = "Affinity: Round %2u: ";
char * output_buffer = new (heap) char [sizeof(text_cpu) + 3 * cpus.total()];
for (; round < 11;) { for (; round < 11;) {
cnt++; cnt++;
/* try to get a life sign by the main thread from the remote threads */ /* try to get a life sign by the main thread from the remote threads */
if (cnt % COUNT_VALUE == 0) { if (cnt % COUNT_VALUE == 0) {
char * output = output_buffer;
snprintf(output, sizeof(text_cpu), text_cpu);
output += sizeof(text_cpu) - 1;
for (unsigned i = 0; i < cpus.total(); i++) {
snprintf(output, 4, "%2u ", i);
output += 3;
}
log(Cstring(output_buffer));
output = output_buffer; struct Table_header
snprintf(output, sizeof(text_round), text_round, round); {
output += sizeof(text_round) - 2; unsigned num_cpus;
for (unsigned i = 0; i < cpus.total(); i++) { void print(Output &out) const
snprintf(output, 4, "%s ", {
thread_cnt[i] == threads[i]->cnt ? " D" : " A"); using Genode::print;
output += 3;
print(out, text_cpu);
for (unsigned i = 0; i < num_cpus; i++)
print(out, Right_aligned(2, i), " ");
}
};
struct Table_entries
{
unsigned num_cpus;
unsigned round;
Spinning_thread **threads;
uint64_t *thread_cnt;
void print(Output &out) const
{
using Genode::print;
print(out, "Affinity: Round ", Right_aligned(2, round), ": ");
for (unsigned i = 0; i < num_cpus; i++)
print(out, thread_cnt[i] == threads[i]->cnt ? " D " : " A ");
}
};
log(Table_header { .num_cpus = cpus.total() });
log(Table_entries { .num_cpus = cpus.total(),
.round = round,
.threads = threads,
.thread_cnt = thread_cnt });
for (unsigned i = 0; i < cpus.total(); i++)
thread_cnt[i] = threads[i]->cnt; thread_cnt[i] = threads[i]->cnt;
}
log(Cstring(output_buffer));
round ++; round ++;
} }
} }
destroy(heap, output_buffer);
for (unsigned i = 0; i < cpus.total(); i++) for (unsigned i = 0; i < cpus.total(); i++)
destroy(heap, threads[i]); destroy(heap, threads[i]);
destroy(heap, threads); destroy(heap, threads);

View File

@ -25,6 +25,9 @@
#include <cpu_thread/client.h> #include <cpu_thread/client.h>
#include <cpu/memory_barrier.h> #include <cpu/memory_barrier.h>
/* compiler includes */
#include <stdarg.h>
using namespace Genode; using namespace Genode;
@ -194,7 +197,7 @@ struct Cpu_helper : Thread
{ {
Env &_env; Env &_env;
Cpu_helper(Env &env, const char * name, Cpu_session &cpu) Cpu_helper(Env &env, Name const &name, Cpu_session &cpu)
: :
Thread(env, name, STACK_SIZE, Thread::Location(), Thread::Weight(), cpu), Thread(env, name, STACK_SIZE, Thread::Location(), Thread::Weight(), cpu),
_env(env) _env(env)
@ -306,7 +309,6 @@ static void test_create_as_many_threads(Env &env)
Thread::stack_virtual_size(); Thread::stack_virtual_size();
Cpu_helper * threads[max]; Cpu_helper * threads[max];
static char thread_name[8];
Heap heap(env.ram(), env.rm()); Heap heap(env.ram(), env.rm());
@ -314,8 +316,7 @@ static void test_create_as_many_threads(Env &env)
try { try {
for (; i < max; i++) { for (; i < max; i++) {
try { try {
snprintf(thread_name, sizeof(thread_name), "%u", i + 1); threads[i] = new (heap) Cpu_helper(env, Thread::Name(i + 1), env.cpu());
threads[i] = new (heap) Cpu_helper(env, thread_name, env.cpu());
threads[i]->start(); threads[i]->start();
threads[i]->join(); threads[i]->join();
} catch (Cpu_session::Thread_creation_failed) { } catch (Cpu_session::Thread_creation_failed) {