From d10b132bf5393e648a1c64569746c8e886d50702 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 2 Nov 2017 12:14:51 +0100 Subject: stdio-common: Use array_length and array_end macros --- stdio-common/tstdiomisc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'stdio-common/tstdiomisc.c') diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c index 89009e0549..c2fc73deb1 100644 --- a/stdio-common/tstdiomisc.c +++ b/stdio-common/tstdiomisc.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -66,8 +67,7 @@ t3 (void) retval = sprintf (buf, "%p", (char *) NULL); result |= retval != 5 || strcmp (buf, "(nil)") != 0; - retval = swprintf (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), - L"%p", (char *) NULL); + retval = swprintf (wbuf, array_length (wbuf), L"%p", (char *) NULL); result |= retval != 5 || wcscmp (wbuf, L"(nil)") != 0; return result; @@ -142,38 +142,38 @@ F (void) printf ("expected \"-inf -INF -inf -INF -inf -INF -inf -INF\", got \"%s\"\n", buf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", qnanval, qnanval, qnanval, qnanval, qnanval, qnanval, qnanval, qnanval); result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", -qnanval, -qnanval, -qnanval, -qnanval, -qnanval, -qnanval, -qnanval, -qnanval); result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", snanval, snanval, snanval, snanval, snanval, snanval, snanval, snanval); result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", msnanval, msnanval, msnanval, msnanval, msnanval, msnanval, msnanval, msnanval); result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0; printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", infval, infval, infval, infval, infval, infval, infval, infval); result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0; printf ("expected L\"inf INF inf INF inf INF inf INF\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G", + swprintf (wbuf, array_length (wbuf), L"%a %A %e %E %f %F %g %G", -infval, -infval, -infval, -infval, -infval, -infval, -infval, -infval); result |= wcscmp (wbuf, L"-inf -INF -inf -INF -inf -INF -inf -INF") != 0; @@ -223,14 +223,14 @@ F (void) printf ("expected \"-inf -INF -inf -INF -inf -INF -inf -INF\", got \"%s\"\n", buf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", lqnanval, lqnanval, lqnanval, lqnanval, lqnanval, lqnanval, lqnanval, lqnanval); result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", -lqnanval, -lqnanval, -lqnanval, -lqnanval, -lqnanval, -lqnanval, -lqnanval, -lqnanval); @@ -238,14 +238,14 @@ F (void) printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", lsnanval, lsnanval, lsnanval, lsnanval, lsnanval, lsnanval, lsnanval, lsnanval); result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0; printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", lmsnanval, lmsnanval, lmsnanval, lmsnanval, lmsnanval, lmsnanval, lmsnanval, lmsnanval); @@ -253,14 +253,14 @@ F (void) printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", linfval, linfval, linfval, linfval, linfval, linfval, linfval, linfval); result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0; printf ("expected L\"inf INF inf INF inf INF inf INF\", got L\"%S\"\n", wbuf); - swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), + swprintf (wbuf, array_length (wbuf), L"%La %LA %Le %LE %Lf %LF %Lg %LG", -linfval, -linfval, -linfval, -linfval, -linfval, -linfval, -linfval, -linfval); -- cgit v1.2.3