Compare commits

..

1 Commits

Author SHA1 Message Date
def4175d0a Fix aksl_sprintf, wasnt properly using va_args 2026-05-24 19:56:55 -04:00

View File

@@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
akerr_ErrorContext AKERR_NOIGNORE *aksl_malloc(size_t size, void **dst) akerr_ErrorContext AKERR_NOIGNORE *aksl_malloc(size_t size, void **dst)
{ {
@@ -122,6 +123,7 @@ akerr_ErrorContext AKERR_NOIGNORE *aksl_sprintf(int *count, char *restrict str,
FAIL_ZERO_RETURN(e, count, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format); FAIL_ZERO_RETURN(e, count, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format);
FAIL_ZERO_RETURN(e, str, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format); FAIL_ZERO_RETURN(e, str, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format);
FAIL_ZERO_RETURN(e, format, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format); FAIL_ZERO_RETURN(e, format, AKERR_NULLPOINTER, "count=%p, str=%p, format=%p", (void *)count, (void *)str, (void *)format);
va_start(args, format);
*count = vsprintf(str, format, args); *count = vsprintf(str, format, args);
FAIL_NONZERO_RETURN(e, (*count == -1), errno, "Short write"); FAIL_NONZERO_RETURN(e, (*count == -1), errno, "Short write");
SUCCEED_RETURN(e); SUCCEED_RETURN(e);
@@ -160,6 +162,6 @@ akerr_ErrorContext AKERR_NOIGNORE *aksl_realpath(const char *restrict path, char
PREPARE_ERROR(e); PREPARE_ERROR(e);
FAIL_ZERO_RETURN(e, path, AKERR_NULLPOINTER, "path=%p, dest=%p", (void *)path, (void *)resolved_path); FAIL_ZERO_RETURN(e, path, AKERR_NULLPOINTER, "path=%p, dest=%p", (void *)path, (void *)resolved_path);
result = realpath(path, resolved_path); result = realpath(path, resolved_path);
FAIL_ZERO_RETURN(e, result, errno, "Error"); FAIL_ZERO_RETURN(e, result, errno, "path=%s, dest=%s", path, resolved_path);
SUCCEED_RETURN(e); SUCCEED_RETURN(e);
} }