Replace use of base/snprintf.h by format library

Issue 
This commit is contained in:
Norman Feske 2023-03-06 14:58:06 +01:00 committed by Christian Helmuth
parent 9ef0f1b6cb
commit e9b249b709
54 changed files with 139 additions and 80 deletions
repos
base/recipes/src/test-xml_generator
dde_bsd
recipes/src/bsd_audio_drv
src
drivers/audio/pci_audio_drv
lib/audio
dde_ipxe
recipes/src/ipxe_nic_drv
src
drivers/nic
lib/dde_ipxe
dde_linux
lib/mk
recipes/src
legacy_usb_host_drv
usb_hid_drv
usb_modem_drv
usb_net_drv
vfs_lxip
src
drivers
include/legacy/lx_emul/impl
lib
dde_rump
lib/mk
recipes/src/rump
src/lib/rump
demo
lib/mk
recipes/src/demo
src/lib/mini_c
libports
lib/mk
recipes/src
gcov
test-ldso
vesa_drv
vfs_lwip
src
drivers/framebuffer/vesa
lib
gcov/libc
qemu-usb
vfs/lwip
test/ldso
ports/recipes/src
vbox5-nova
vbox5
vbox6

View File

@ -1,4 +1,5 @@
base
file_system_session
libgcov
format
os

View File

@ -1,5 +1,6 @@
base
os
format
audio_in_session
audio_out_session
platform_session

View File

@ -1,7 +1,7 @@
REQUIRES = x86
TARGET = pci_audio_drv
SRC_CC = main.cc
LIBS = dde_bsd_audio base
LIBS = dde_bsd_audio base format
INC_DIR += $(REP_DIR)/include
vpath %.cc $(REP_DIR)/src/drivers/audio

View File

@ -19,6 +19,9 @@
#include <os/reporter.h>
#include <util/xml_node.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <audio/audio.h>
#include <bsd.h>
@ -143,7 +146,7 @@ static bool set_mixer_value(Mixer &mixer, char const * const field,
char const * const class_name = mixer.info[mixer_class].label.name;
char const * const name = info.label.name;
Genode::snprintf(buffer, sizeof(buffer), "%s.%s", class_name, name);
Format::snprintf(buffer, sizeof(buffer), "%s.%s", class_name, name);
if (Genode::strcmp(field, buffer) != 0)
continue;
@ -238,7 +241,7 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
{
for (int i = 0; i < info->un.e.num_mem; i++)
if (ctrl.un.ord == info->un.e.member[i].ord) {
Genode::snprintf(buffer, sizeof(buffer),
Format::snprintf(buffer, sizeof(buffer),
"%s", info->un.e.member[i].label.name);
break;
}
@ -250,7 +253,7 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
Genode::size_t n = 0;
for (int i = 0; i < info->un.s.num_mem; i++)
if (ctrl.un.mask & info->un.s.member[i].mask)
n += Genode::snprintf(p + n, sizeof(buffer) - n,
n += Format::snprintf(p + n, sizeof(buffer) - n,
"%s%s", n ? "," : "",
info->un.s.member[i].label.name);
break;
@ -258,11 +261,11 @@ static char const *get_mixer_value(mixer_devinfo_t const *info)
case AUDIO_MIXER_VALUE:
{
if (ctrl.un.value.num_channels == 2)
Genode::snprintf(buffer, sizeof(buffer), "%d,%d",
Format::snprintf(buffer, sizeof(buffer), "%d,%d",
ctrl.un.value.level[0],
ctrl.un.value.level[1]);
else
Genode::snprintf(buffer, sizeof(buffer), "%d",
Format::snprintf(buffer, sizeof(buffer), "%d",
ctrl.un.value.level[0]);
break;
}
@ -374,7 +377,7 @@ static void configure_mixer(Genode::Env &env, Mixer &mixer, Genode::Xml_node con
if (value) {
xml.node("mixer", [&]() {
char tmp[64];
Genode::snprintf(tmp, sizeof(tmp), "%s.%s",
Format::snprintf(tmp, sizeof(tmp), "%s.%s",
class_name, name);
xml.attribute("field", tmp);

View File

@ -15,9 +15,11 @@
/* Genode includes */
#include <base/log.h>
#include <base/sleep.h>
#include <base/snprintf.h>
#include <util/string.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <bsd_emul.h>
@ -440,7 +442,7 @@ extern "C" int snprintf(char *str, size_t size, const char *format, ...)
va_list list;
va_start(list, format);
Genode::String_console sc(str, size);
Format::String_console sc(str, size);
sc.vprintf(format, list);
va_end(list);

View File

@ -2,6 +2,7 @@ base
nic_driver
nic_session
os
format
platform_session
report_session
timer_session

View File

@ -1,6 +1,6 @@
TARGET = ipxe_nic_drv
REQUIRES = x86
LIBS = base dde_ipxe_nic nic_driver
LIBS = base dde_ipxe_nic nic_driver format
SRC_CC = main.cc
CC_CXX_WARN_STRICT =

View File

@ -39,6 +39,9 @@
#include <util/retry.h>
#include <util/reconstructible.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <dde_support.h>
@ -77,7 +80,7 @@ extern "C" void dde_vprintf(const char *format, va_list list)
using namespace Genode;
char buf[128] { };
String_console(buf, sizeof(buf)).vprintf(format, list);
Format::String_console(buf, sizeof(buf)).vprintf(format, list);
log(Cstring(buf));
}

View File

@ -3,7 +3,7 @@ SHARED_LIB = yes
LIB_DIR = $(REP_DIR)/src/lib/lxip
LIB_INC_DIR = $(LIB_DIR)/include
LIBS += lxip_include
LIBS += lxip_include format
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/lib/lxip
NET_DIR := $(LX_CONTRIB_DIR)/net

View File

@ -1,5 +1,6 @@
base
os
format
usb_session
gpio_session
platform_session

View File

@ -1,5 +1,6 @@
base
os
format
event_session
report_session
usb_session

View File

@ -1,5 +1,6 @@
base
os
format
nic_session
uplink_session
usb_session

View File

@ -1,5 +1,6 @@
base
os
format
nic_session
uplink_session
usb_session

View File

@ -4,3 +4,4 @@ os
so
timer_session
vfs
format

View File

@ -3,7 +3,7 @@ SRC_C := dummies.c
SRC_CC := main.cc lx_emul.cc evdev.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc env.cc work.cc
LIBS := base usb_hid_include lx_kit_setjmp
LIBS := base usb_hid_include lx_kit_setjmp format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_hid

View File

@ -20,6 +20,9 @@
#include <util/bit_allocator.h>
#include <util/string.h>
/* format-string includes */
#include <format/snprintf.h>
/* Local includes */
#include "signal.h"
#include "lx_emul.h"
@ -120,7 +123,7 @@ bool access_ok(int access, void *addr, size_t size) { return 1; }
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
Genode::String_console sc(buf, size);
Format::String_console sc(buf, size);
sc.vprintf(fmt, args);
return sc.len();
@ -132,7 +135,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args;
va_start(args, fmt);
Genode::String_console sc(buf, size);
Format::String_console sc(buf, size);
sc.vprintf(fmt, args);
va_end(args);
@ -145,7 +148,7 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
va_list args;
va_start(args, fmt);
Genode::String_console sc(buf, size);
Format::String_console sc(buf, size);
sc.vprintf(fmt, args);
va_end(args);

View File

@ -1,7 +1,7 @@
LX_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_host
SRC_CC = main.cc lx_emul.cc raw.cc
SRC_C = dummies.c raw_driver.c
LIBS = base usb_host_include lx_kit_setjmp
LIBS = base usb_host_include lx_kit_setjmp format
CC_CXX_WARN_STRICT =
INC_DIR += $(PRG_DIR)

View File

@ -14,7 +14,7 @@
#include <base/env.h>
#include <usb_session/client.h>
#include <base/snprintf.h>
#include <format/snprintf.h>
#include <nic_session/nic_session.h>
#include <util/xml_node.h>
@ -345,7 +345,7 @@ enum { MAC_LEN = 17 };
static void snprint_mac(char *buf, u8 *mac)
{
for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
Format::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
if ((i * 3) < MAC_LEN)
buf[(i * 3) + 2] = ':';
}

View File

@ -4,7 +4,7 @@ SRC_CC := main.cc lx_emul.cc terminal.cc fec_nic.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc
SRC_CC += uplink_client.cc
LIBS := base usb_modem_include lx_kit_setjmp nic_driver
LIBS := base usb_modem_include lx_kit_setjmp nic_driver format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_modem

View File

@ -1,6 +1,6 @@
#include <base/env.h>
#include <usb_session/client.h>
#include <base/snprintf.h>
#include <format/snprintf.h>
#include <nic_session/nic_session.h>
#include <util/xml_node.h>
@ -324,7 +324,7 @@ enum { MAC_LEN = 17 };
static void snprint_mac(char *buf, u8 *mac)
{
for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
Format::snprintf((char *)&buf[i * 3], 3, "%02x", mac[i]);
if ((i * 3) < MAC_LEN)
buf[(i * 3) + 2] = ':';
}

View File

@ -4,7 +4,7 @@ SRC_CC := main.cc lx_emul.cc linux_network_session_base.cc
SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc
SRC_CC += uplink_client.cc
LIBS := base usb_net_include lx_kit_setjmp nic_driver
LIBS := base usb_net_include lx_kit_setjmp nic_driver format
USB_CONTRIB_DIR := $(call select_from_ports,dde_linux)/src/drivers/usb_net

View File

@ -12,7 +12,7 @@
*/
/* Genode includes */
#include <base/snprintf.h>
#include <format/snprintf.h>
int sprintf(char *str, const char *format, ...)
@ -21,7 +21,7 @@ int sprintf(char *str, const char *format, ...)
va_list list;
va_start(list, format);
Genode::String_console sc(str, BUFFER_LEN);
Format::String_console sc(str, BUFFER_LEN);
sc.vprintf(format, list);
va_end(list);
@ -34,7 +34,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args;
va_start(args, fmt);
Genode::String_console sc(buf, size);
Format::String_console sc(buf, size);
sc.vprintf(fmt, args);
va_end(args);

View File

@ -15,10 +15,12 @@
/* Genode includes */
#include <base/entrypoint.h>
#include <base/snprintf.h>
#include <base/tslab.h>
#include <irq_session/client.h>
/* format-string includes */
#include <format/snprintf.h>
/* Linux emulation environment */
#include <lx_emul.h>
@ -43,7 +45,7 @@ class Lx_kit::Irq : public Lx::Irq
Name_composer(unsigned number)
{
Genode::snprintf(name, sizeof(name),
Format::snprintf(name, sizeof(name),
"irq_%02x", number);
}
};

View File

@ -14,11 +14,13 @@
/* Genode includes */
#include <base/env.h>
#include <base/log.h>
#include <base/snprintf.h>
#include <util/list.h>
#include <util/string.h>
#include <util/misc_math.h>
/* compiler includes */
#include <stdarg.h>
/* Libc includes */
#include <unistd.h>
#include <errno.h>

View File

@ -17,17 +17,18 @@
#include <base/allocator_avl.h>
#include <base/object_pool.h>
#include <base/sleep.h>
#include <base/snprintf.h>
#include <dataspace/client.h>
#include <region_map/client.h>
#include <trace/timestamp.h>
#include <timer_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <lx_emul.h>
#include <lx.h>
/* Lx_kit */
#include <legacy/lx_kit/env.h>
@ -271,7 +272,7 @@ int snprintf(char *str, size_t size, const char *format, ...)
va_list list;
va_start(list, format);
Genode::String_console sc(str, size);
Format::String_console sc(str, size);
sc.vprintf(format, list);
va_end(list);
@ -457,13 +458,13 @@ static void create_event(char const *fmt, va_list list)
using namespace Genode;
String_console sc(buf, BUFFER_LEN);
Format::String_console sc(buf, BUFFER_LEN);
sc.vprintf(fmt, list);
char event[EVENT_LEN];
static Trace::Timestamp last = 0;
Trace::Timestamp now = Trace::timestamp();
Genode::snprintf(event, sizeof(event), "delta = %llu ms %s",
Format::snprintf(event, sizeof(event), "delta = %llu ms %s",
(now - last) / 2260000, buf);
Thread::trace(event);
last = now;

View File

@ -18,6 +18,9 @@
#include <nic/packet_allocator.h>
#include <nic_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <lx.h>
#include <nic.h>
@ -162,7 +165,7 @@ void net_mac(void* mac, unsigned long size)
unsigned char const *mac_addr = (unsigned char const*)m.addr;
for (int i = 0; i < ETH_ALEN; i++) {
Genode::snprintf((char *)&str[i * 3], 3, "%02x", mac_addr[i]);
Format::snprintf((char *)&str[i * 3], 3, "%02x", mac_addr[i]);
if ((i * 3) < MAC_LEN)
str[(i * 3) + 2] = ':';
}

View File

@ -15,7 +15,6 @@
/* Genode includes */
#include <base/log.h>
#include <base/snprintf.h>
#include <net/ipv4.h>
#include <util/string.h>
#include <util/xml_node.h>
@ -25,6 +24,9 @@
#include <vfs/vfs_handle.h>
#include <timer_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* Lxip includes */
#include <lxip/lxip.h>
#include <lx.h>
@ -656,7 +658,7 @@ class Vfs::Lxip_listen_file final : public Vfs::Lxip_file
Byte_range_ptr const &dst,
file_size /* ignored */) override
{
return Genode::snprintf(dst.start, dst.num_bytes, "%lu\n", _backlog);
return Format::snprintf(dst.start, dst.num_bytes, "%lu\n", _backlog);
}
};
@ -764,11 +766,11 @@ class Vfs::Lxip_connect_file final : public Vfs::Lxip_file
switch (so_error) {
case 0:
return Genode::snprintf(dst.start, dst.num_bytes, "connected");
return Format::snprintf(dst.start, dst.num_bytes, "connected");
case Linux::ECONNREFUSED:
return Genode::snprintf(dst.start, dst.num_bytes, "connection refused");
return Format::snprintf(dst.start, dst.num_bytes, "connection refused");
default:
return Genode::snprintf(dst.start, dst.num_bytes, "unknown error");
return Format::snprintf(dst.start, dst.num_bytes, "unknown error");
}
}
};
@ -806,7 +808,7 @@ class Vfs::Lxip_local_file final : public Vfs::Lxip_file
in_addr const i_addr = addr->sin_addr;
unsigned char const *a = (unsigned char *)&i_addr.s_addr;
unsigned char const *p = (unsigned char *)&addr->sin_port;
return Genode::snprintf(dst.start, dst.num_bytes,
return Format::snprintf(dst.start, dst.num_bytes,
"%d.%d.%d.%d:%u\n",
a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0));
}
@ -883,7 +885,7 @@ class Vfs::Lxip_remote_file final : public Vfs::Lxip_file
in_addr const i_addr = addr->sin_addr;
unsigned char const *a = (unsigned char *)&i_addr.s_addr;
unsigned char const *p = (unsigned char *)&addr->sin_port;
return Genode::snprintf(dst.start, dst.num_bytes,
return Format::snprintf(dst.start, dst.num_bytes,
"%d.%d.%d.%d:%u\n",
a[0], a[1], a[2], a[3], (p[0]<<8)|(p[1]<<0));
}
@ -1014,7 +1016,7 @@ class Vfs::Lxip_socket_dir final : public Lxip::Socket_dir
_alloc(alloc), _parent(parent),
_sock(sock), id(parent.adopt_socket(*this))
{
Genode::snprintf(_name, sizeof(_name), "%u", id);
Format::snprintf(_name, sizeof(_name), "%u", id);
for (Vfs::File * &file : _files) file = nullptr;
@ -1177,7 +1179,7 @@ struct Vfs::Lxip_socket_handle final : Vfs::Lxip_vfs_handle
Read_result read(Byte_range_ptr const &dst, size_t &out_count) override
{
out_count = Genode::snprintf(
out_count = Format::snprintf(
dst.start, dst.num_bytes, "%s/%s\n", socket_dir.parent().name(), socket_dir.name());
return Read_result::READ_OK;
}

View File

@ -1,5 +1,5 @@
SRC_CC = vfs_rump.cc random.cc
LIBS = rump rump_fs
LIBS = rump rump_fs format
INC_DIR += $(REP_DIR)/src/lib/vfs/rump
INC_DIR += $(REP_DIR)/src/include
vpath %.cc $(REP_DIR)/src/lib/vfs/rump

View File

@ -5,3 +5,4 @@ file_system
file_system_session
timer_session
vfs
format

View File

@ -21,6 +21,7 @@
#include <util/allocator_fap.h>
#include <util/random.h>
#include <util/string.h>
#include <format/snprintf.h>
enum {
SUPPORTED_RUMP_VERSION = 17,
@ -193,7 +194,7 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen)
rump_ram = Genode::min((unsigned long)MAX_VIRTUAL_MEMORY, rump_ram);
/* convert to string */
Genode::snprintf((char *)buf, buflen, "%zu", rump_ram);
Format::snprintf((char *)buf, buflen, "%zu", rump_ram);
return 0;
}

View File

@ -17,6 +17,7 @@
#include <block_session/connection.h>
#include <rump/env.h>
#include <rump_fs/fs.h>
#include <format/snprintf.h>
static const bool verbose = false;
@ -361,7 +362,7 @@ void rumpuser_dprintf(const char *format, ...)
va_start(list, format);
char buf[128] { };
Genode::String_console(buf, sizeof(buf)).vprintf(format, list);
Format::String_console(buf, sizeof(buf)).vprintf(format, list);
Genode::log(Genode::Cstring(buf));
va_end(list);

View File

@ -2,6 +2,8 @@ SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \
malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \
mini_c.cc
LIBS += format
STDINC = yes
vpath % $(REP_DIR)/src/lib/mini_c

View File

@ -1,6 +1,7 @@
base
os
blit
format
nitpicker_gfx
timer_session
input_session

View File

@ -11,15 +11,15 @@
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/snprintf.h>
#include <format/snprintf.h>
#include <stdio.h>
extern "C" int snprintf(char *dst, Genode::size_t dst_len, const char *format, ...)
extern "C" int snprintf(char *dst, Format::size_t dst_len, const char *format, ...)
{
va_list list;
va_start(list, format);
Genode::String_console sc(dst, dst_len);
Format::String_console sc(dst, dst_len);
sc.vprintf(format, list);
va_end(list);

View File

@ -11,11 +11,11 @@
* under the terms of the GNU Affero General Public License version 3.
*/
#include <base/snprintf.h>
#include <format/snprintf.h>
extern "C" int vsnprintf(char *dst, Genode::size_t dst_len, const char *format, va_list list)
extern "C" int vsnprintf(char *dst, Format::size_t dst_len, const char *format, va_list list)
{
Genode::String_console sc(dst, dst_len);
Format::String_console sc(dst, dst_len);
sc.vprintf(format, list);
return (int)sc.len();
}

View File

@ -26,7 +26,7 @@ CC_OPT_version += -DBASEVER="\"10.3.0\"" \
-DPKGVERSION="\"(GCC) \"" \
-DBUGURL="\"<http://gcc.gnu.org/bugs.html>\""
LIBS += libc gmp stdcxx
LIBS += libc gmp stdcxx format
INC_DIR += $(GCOV_DIR)/include \
$(GCOV_DIR)/libcpp/include

View File

@ -70,3 +70,5 @@ vpath %.c $(GCOV_DIR)/libgcc
vpath libc.cc $(REP_DIR)/src/lib/gcov/libc
CC_CXX_WARN_STRICT =
LIBS += format

View File

@ -8,6 +8,7 @@ INC_DIR += $(LIB_DIR) $(QEMU_USB_DIR)
LIBS = qemu-usb_include
LIBS += libc
LIBS += libyuv
LIBS += format
SRC_CC = dummies.cc qemu_emul.cc host.cc webcam.cc

View File

@ -7,7 +7,7 @@ REP_INC_DIR += src/lib/lwip/include
LD_OPT += --version-script=$(VFS_DIR)/symbol.map
LIBS += lwip
LIBS += lwip format
vpath %.cc $(VFS_DIR)

View File

@ -4,3 +4,4 @@ libc
posix
stdcxx
zlib
format

View File

@ -1,3 +1,4 @@
base
libc
so
format

View File

@ -1,6 +1,7 @@
base
os
blit
format
platform_session
timer_session
capture_session

View File

@ -5,3 +5,4 @@ os
so
timer_session
vfs
format

View File

@ -22,6 +22,9 @@
#include <util/reconstructible.h>
#include <io_port_session/connection.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include "ifx86emu.h"
#include "framebuffer.h"
@ -502,7 +505,7 @@ void X86emu::printk(const char *format, ...)
va_start(list, format);
char buf[128];
String_console sc(buf, sizeof(buf));
Format::String_console sc(buf, sizeof(buf));
sc.vprintf(format, list);
va_end(list);

View File

@ -1,7 +1,7 @@
TARGET = vesa_fb_drv
REQUIRES = x86
SRC_CC = main.cc framebuffer.cc ifx86emu.cc hw_emul.cc
LIBS = base blit x86emu
LIBS = base blit x86emu format
INC_DIR += $(PRG_DIR)/include $(REP_DIR)/include/x86emu
CC_CXX_WARN_STRICT =

View File

@ -21,6 +21,7 @@
#include <file_system/util.h>
#include <util/string.h>
#include <util/xml_node.h>
#include <format/snprintf.h>
extern "C" {
#include "stdio.h"
@ -394,7 +395,7 @@ extern "C" void *malloc(size_t size)
extern "C" int sprintf(char *str, const char *format, ...)
{
using namespace Genode;
using namespace Format;
va_list list;
va_start(list, format);
@ -458,7 +459,7 @@ extern "C" int vfprintf(FILE *stream, const char *format, va_list list)
if (stream != stderr)
return 0;
using namespace Genode;
using namespace Format;
char buf[1024] { };
String_console sc { buf, sizeof(buf) };

View File

@ -18,6 +18,9 @@
#include <base/log.h>
#include <util/misc_math.h>
/* format-string includes */
#include <format/snprintf.h>
/* local includes */
#include <extern_c_begin.h>
#include <qemu_emul.h>
@ -157,7 +160,7 @@ void qemu_printf(char const *fmt, ...)
char buf[BUF_SIZE] { };
va_list args;
va_start(args, fmt);
Genode::String_console sc(buf, BUF_SIZE);
Format::String_console sc(buf, BUF_SIZE);
sc.vprintf(fmt, args);
Genode::log(Genode::Cstring(buf));
va_end(args);
@ -169,7 +172,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_list args;
va_start(args, fmt);
Genode::String_console sc(buf, size);
Format::String_console sc(buf, size);
sc.vprintf(fmt, args);
va_end(args);
@ -1056,7 +1059,7 @@ void error_setg(Error **errp, const char *fmt, ...)
va_list args;
va_start(args, fmt);
Genode::String_console sc(e->string, sizeof(e->string));
Format::String_console sc(e->string, sizeof(e->string));
sc.vprintf(fmt, args);
va_end(args);
}

View File

@ -12,8 +12,11 @@
*/
/* Genode includes */
#include <base/snprintf.h>
#include <base/env.h>
#include <util/string.h>
#include <base/log.h>
/* format-string includes */
#include <format/snprintf.h>
extern "C" {
@ -27,7 +30,7 @@ extern "C" {
va_start(list, format);
char buf[128] { };
Genode::String_console(buf, sizeof(buf)).vprintf(format, list);
Format::String_console(buf, sizeof(buf)).vprintf(format, list);
Genode::log(Genode::Cstring(buf));
va_end(list);

View File

@ -23,6 +23,9 @@
#include <base/registry.h>
#include <base/log.h>
/* format-string includes */
#include <format/snprintf.h>
/* LwIP includes */
#include <lwip_genode_init.h>
#include <nic_netif.h>
@ -329,7 +332,7 @@ struct Lwip::Socket_dir : Lwip::Directory
{
char buf[Socket_name::capacity()];
return Socket_name(Genode::Cstring(
buf, Genode::snprintf(buf, Socket_name::capacity(), "%x", num)));
buf, Format::snprintf(buf, Socket_name::capacity(), "%x", num)));
}
Genode::Allocator &alloc;
@ -920,7 +923,7 @@ class Lwip::Udp_socket_dir final :
return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->local_ip);
/* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->local_port);
return Read_result::READ_OK;
}
@ -928,9 +931,9 @@ class Lwip::Udp_socket_dir final :
case Lwip_file_handle::CONNECT: {
/* check if the PCB was connected */
if (!ip_addr_isany(&_pcb->remote_ip))
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connected");
out_count = Format::snprintf(dst.start, dst.num_bytes, "connected");
else
out_count = Genode::snprintf(dst.start, dst.num_bytes, "not connected");
out_count = Format::snprintf(dst.start, dst.num_bytes, "not connected");
return Read_result::READ_OK;
}
@ -943,14 +946,14 @@ class Lwip::Udp_socket_dir final :
_packet_queue.head([&] (Packet &pkt) {
char const *ip_str = ipaddr_ntoa(&pkt.addr);
/* TODO: IPv6 */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, pkt.port);
result = Read_result::READ_OK;
});
} else {
char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip);
/* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->remote_port);
result = Read_result::READ_OK;
}
@ -960,7 +963,7 @@ class Lwip::Udp_socket_dir final :
/*
* Print the location of this socket directory
*/
out_count = Genode::snprintf(dst.start, dst.num_bytes, "udp/%s\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "udp/%s\n",
name().string());
return Read_result::READ_OK;
break;
@ -1354,7 +1357,7 @@ class Lwip::Tcp_socket_dir final :
return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->remote_ip);
/* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "%s:%d\n",
ip_str, _pcb->remote_port);
return Read_result::READ_OK;
} else {
@ -1392,7 +1395,7 @@ class Lwip::Tcp_socket_dir final :
/*
* Print the location of this socket directory
*/
out_count = Genode::snprintf(dst.start, dst.num_bytes, "tcp/%s\n",
out_count = Format::snprintf(dst.start, dst.num_bytes, "tcp/%s\n",
name().string());
return Read_result::READ_OK;
break;
@ -1405,7 +1408,7 @@ class Lwip::Tcp_socket_dir final :
for (Pcb_pending *p = _pcb_pending.first(); p; p = p->next())
++pending_count;
out_count = Genode::snprintf(dst.start, dst.num_bytes, "%d\n", pending_count);
out_count = Format::snprintf(dst.start, dst.num_bytes, "%d\n", pending_count);
return Read_result::READ_OK;
}
@ -1416,7 +1419,7 @@ class Lwip::Tcp_socket_dir final :
return Read_result::READ_ERR_INVALID;
char const *ip_str = ipaddr_ntoa(&_pcb->local_ip);
/* TODO: [IPv6]:port */
out_count = Genode::snprintf(dst.start, dst.num_bytes,
out_count = Format::snprintf(dst.start, dst.num_bytes,
"%s:%d\n", ip_str, _pcb->local_port);
return Read_result::READ_OK;
}
@ -1425,10 +1428,10 @@ class Lwip::Tcp_socket_dir final :
case Lwip_file_handle::CONNECT:
switch (state) {
case READY:
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connected");
out_count = Format::snprintf(dst.start, dst.num_bytes, "connected");
break;
default:
out_count = Genode::snprintf(dst.start, dst.num_bytes, "connection refused");
out_count = Format::snprintf(dst.start, dst.num_bytes, "connection refused");
break;
}
return Read_result::READ_OK;

View File

@ -17,6 +17,7 @@
#include <base/heap.h>
#include <libc/component.h>
#include <base/shared_object.h>
#include <format/snprintf.h>
using namespace Genode;
@ -126,7 +127,7 @@ static void test_stack_align(char const *fmt, ...)
va_start(list, fmt);
char buf[128] { };
String_console(buf, sizeof(buf)).vprintf(fmt, list);
Format::String_console(buf, sizeof(buf)).vprintf(fmt, list);
log(Cstring(buf));
va_end(list);

View File

@ -1,6 +1,6 @@
SRC_CC = main.cc
TARGET = test-ldso
LIBS = base test-ldso_lib_1 test-ldso_lib_2 libc libm
LIBS = base test-ldso_lib_1 test-ldso_lib_2 libc libm format
INC_DIR += $(REP_DIR)/src/test/ldso/include
CC_CXX_WARN_STRICT =

View File

@ -20,3 +20,4 @@ vfs
nitpicker_gfx
blit
libyuv
format

View File

@ -20,3 +20,4 @@ vm_session
nitpicker_gfx
blit
libyuv
format

View File

@ -17,3 +17,4 @@ usb_session
vfs
vm_session
libyuv
format