Skip to content

Commit 838b118

Browse files
[libc] Fix missing UINTMAX_WIDTH (#87092)
In patch #82461 the sprintf tests were made to use UINTMAX_WIDTH which isn't defined on all systems. This patch changes it to sizeof(uintmax_t)*CHAR_BIT which is more portable.
1 parent e74332a commit 838b118

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libc/test/src/stdio/sprintf_test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ TEST(LlvmLibcSPrintfTest, IntConv) {
203203

204204
char format[64];
205205
char uintmax[128];
206-
LIBC_NAMESPACE::sprintf(format, "%%w%du", UINTMAX_WIDTH);
207-
const int uintmax_len = LIBC_NAMESPACE::sprintf(uintmax, "%ju", UINTMAX_MAX);
208-
written = LIBC_NAMESPACE::sprintf(buff, format, UINTMAX_MAX);
206+
LIBC_NAMESPACE::sprintf(format, "%%w%du", sizeof(uintmax_t) * CHAR_BIT);
207+
const int uintmax_len =
208+
LIBC_NAMESPACE::sprintf(uintmax, "%ju", sizeof(uintmax_t) * CHAR_BIT);
209+
written = LIBC_NAMESPACE::sprintf(buff, format, sizeof(uintmax_t) * CHAR_BIT);
209210
EXPECT_EQ(written, uintmax_len);
210211
ASSERT_STREQ(buff, uintmax);
211212

0 commit comments

Comments
 (0)