Skip to content

Commit dccf9f7

Browse files
authored
Base printf routines on one another (#248)
There should only be one printf routine present given its size, but the inliner may inline the implementation into multiple different versions of the function. Explicitly basing the routines on one another discourages this.
1 parent a6e5206 commit dccf9f7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mos-platform/common/c/printf.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,24 +941,23 @@ static int _vsnprintf(out_fct_type out, char *buffer, const size_t maxlen,
941941
int printf(const char *format, ...) {
942942
va_list va;
943943
va_start(va, format);
944-
char buffer[1];
945-
const int ret = _vsnprintf(_out_char, buffer, (size_t)-1, format, va);
944+
const int ret = vprintf(format, va);
946945
va_end(va);
947946
return ret;
948947
}
949948

950949
int sprintf(char *buffer, const char *format, ...) {
951950
va_list va;
952951
va_start(va, format);
953-
const int ret = _vsnprintf(_out_buffer, buffer, (size_t)-1, format, va);
952+
const int ret = vsnprintf(buffer, (size_t)-1, format, va);
954953
va_end(va);
955954
return ret;
956955
}
957956

958957
int snprintf(char *buffer, size_t count, const char *format, ...) {
959958
va_list va;
960959
va_start(va, format);
961-
const int ret = _vsnprintf(_out_buffer, buffer, count, format, va);
960+
const int ret = vsnprintf(buffer, count, format, va);
962961
va_end(va);
963962
return ret;
964963
}

0 commit comments

Comments
 (0)