⛏️ index : haiku.git

author PulkoMandy <pulkomandy@pulkomandy.tk> 2025-12-01 20:43:19.0 +01:00:00
committer Adrien Destugues <pulkomandy@pulkomandy.tk> 2025-12-02 9:43:45.0 +00:00:00
commit
b939b5a9f43ff446a3d420c0d1f146d505cdb7b1 [patch]
tree
bce34c7ee1c4300128e98b55a26408f45730b98b
parent
ccf8b1e96f9dab37dc16b6e8e3be1cd4aec8385f
download
b939b5a9f43ff446a3d420c0d1f146d505cdb7b1.tar.gz

debug_printf: return number of printed characters

For compatibility with other printf functions

Change-Id: I52c85d590b8480427952740cb896112bb4e71c18
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10044
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>

Diff

 headers/os/kernel/OS.h        |  4 ++--
 src/system/libroot/os/debug.c | 15 ++++++++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h
index 301686e..0c68555 100644
--- a/headers/os/kernel/OS.h
+++ b/headers/os/kernel/OS.h
@@ -424,9 +424,9 @@
extern int			disable_debugger(int state);

/* TODO: Remove. Temporary debug helper. */
extern void			debug_printf(const char *format, ...)
extern int			debug_printf(const char *format, ...)
						__attribute__ ((format (__printf__, 1, 2)));
extern void			debug_vprintf(const char *format, va_list args);
extern int			debug_vprintf(const char *format, va_list args);
extern void			ktrace_printf(const char *format, ...)
						__attribute__ ((format (__printf__, 1, 2)));
extern void			ktrace_vprintf(const char *format, va_list args);
diff --git a/src/system/libroot/os/debug.c b/src/system/libroot/os/debug.c
index 2e7a5c7..5dc1239 100644
--- a/src/system/libroot/os/debug.c
+++ b/src/system/libroot/os/debug.c
@@ -268,27 +268,32 @@
	return 0;
}


// TODO: Remove. Temporary debug helper.
// (accidently these are more or less the same as _sPrintf())

void
int
debug_printf(const char *format, ...)
{
	int count;

	va_list list;
	va_start(list, format);

	debug_vprintf(format, list);
	count = debug_vprintf(format, list);

	va_end(list);
	return count;
}


void
int
debug_vprintf(const char *format, va_list args)
{
	char buffer[1024];
	vsnprintf(buffer, sizeof(buffer), format, args);
	int count = vsnprintf(buffer, sizeof(buffer), format, args);

	_kern_debug_output(buffer);
	return count;
}