Module Name: src Committed By: rillig Date: Sat Feb 24 13:00:00 UTC 2024
Modified Files: src/tests/lib/libutil: t_snprintb.c Log Message: tests/snprintb: clean up tests Always write the value to be formatted in hexadecimal, to make it easily distinguishable from the buffer size and maximum line length. Use consistent wording in the comments of the test cases. Be stricter about mistakes in a format. Fix some wrong numbers in the snprintb_m tests for limited line length. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libutil/t_snprintb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/lib/libutil/t_snprintb.c diff -u src/tests/lib/libutil/t_snprintb.c:1.28 src/tests/lib/libutil/t_snprintb.c:1.29 --- src/tests/lib/libutil/t_snprintb.c:1.28 Sat Feb 24 12:40:00 2024 +++ src/tests/lib/libutil/t_snprintb.c Sat Feb 24 13:00:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_snprintb.c,v 1.28 2024/02/24 12:40:00 rillig Exp $ */ +/* $NetBSD: t_snprintb.c,v 1.29 2024/02/24 13:00:00 rillig Exp $ */ /* * Copyright (c) 2002, 2004, 2008, 2010, 2024 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008, 2010, 2024\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_snprintb.c,v 1.28 2024/02/24 12:40:00 rillig Exp $"); +__RCSID("$NetBSD: t_snprintb.c,v 1.29 2024/02/24 13:00:00 rillig Exp $"); #include <stdio.h> #include <string.h> @@ -44,15 +44,16 @@ __RCSID("$NetBSD: t_snprintb.c,v 1.28 20 static const char * vis_arr(const char *arr, size_t arrsize) { - static char buf[6][1024]; + static char buf[3][1024]; static size_t i; i = (i + 1) % (sizeof(buf) / sizeof(buf[0])); - buf[i][0] = '"'; int rv = strnvisx(buf[i] + 1, sizeof(buf[i]) - 2, arr, arrsize, VIS_WHITE | VIS_OCTAL); - ATF_REQUIRE_MSG(rv >= 0, "strnvisx failed for size %zu", arrsize); - strcpy(buf[i] + 1 + rv, "\""); + ATF_REQUIRE_MSG(rv >= 0, "buffer too small for size %zu", arrsize); + buf[i][0] = '"'; + buf[i][1 + rv] = '"'; + buf[i][1 + rv + 1] = '\0'; return buf[i]; } @@ -73,12 +74,12 @@ check_snprintb_m(const char *file, size_ file, line); if (bufsize == 0) want_bufsize = 0; + memset(buf, 0x5a, sizeof(buf)); - memset(buf, 'Z', sizeof(buf)); int rv = snprintb_m(buf, bufsize, bitfmt, val, line_max); size_t have_bufsize = sizeof(buf); - while (have_bufsize > 0 && buf[have_bufsize - 1] == 'Z') + while (have_bufsize > 0 && buf[have_bufsize - 1] == 0x5a) have_bufsize--; if (rv > 0 && (unsigned)rv < have_bufsize && buf[rv - 1] == '\0' && buf[rv] == '\0') @@ -122,7 +123,7 @@ check_snprintb_m(const char *file, size_ h_snprintb_m_len(bufsize, bitfmt, val, 0, want_rv, want_buf) #define h_snprintb_error(bitfmt, want_buf) \ - h_snprintb_m_len(1024, bitfmt, 0, 0, -1, want_buf) + h_snprintb_m_len(1024, bitfmt, 0x00, 0, -1, want_buf) #define h_snprintb_m(bitfmt, val, line_max, want_buf) \ h_snprintb_m_len(1024, bitfmt, val, line_max, \ @@ -141,7 +142,7 @@ ATF_TC_BODY(snprintb, tc) // The value 0 does not get a leading '0'. h_snprintb( "\010", - 0, + 0x00, "0"); // style and number base, old style, octal, nonzero value @@ -155,7 +156,7 @@ ATF_TC_BODY(snprintb, tc) // style and number base, old style, decimal, zero value h_snprintb( "\012", - 0, + 0x00, "0"); // style and number base, old style, decimal, nonzero value @@ -169,7 +170,7 @@ ATF_TC_BODY(snprintb, tc) // The value 0 does not get a leading '0x'. h_snprintb( "\020", - 0, + 0x00, "0"); // style and number base, old style, hexadecimal, nonzero value @@ -200,7 +201,7 @@ ATF_TC_BODY(snprintb, tc) // The value 0 does not get a leading '0'. h_snprintb( "\177\010", - 0, + 0x00, "0"); // style and number base, new style, octal, nonzero value @@ -214,7 +215,7 @@ ATF_TC_BODY(snprintb, tc) // style and number base, new style, decimal, zero value h_snprintb( "\177\012", - 0, + 0x00, "0"); // style and number base, new style, decimal, nonzero value @@ -228,7 +229,7 @@ ATF_TC_BODY(snprintb, tc) // The value 0 does not get a leading '0x'. h_snprintb( "\177\020", - 0, + 0x00, "0"); // style and number base, new style, hexadecimal, nonzero value @@ -278,7 +279,7 @@ ATF_TC_BODY(snprintb, tc) "\020" "\001bit1" "\041bit33", - 0x1, + 0x01, "0x1<bit1!bit33>"); // old style, repeated bit numbers @@ -289,14 +290,14 @@ ATF_TC_BODY(snprintb, tc) "\020" "\001once" "\001again", - 0x1, + 0x01, "0x1<once,again>"); // old style, non-printable description // // The characters ' ' and '\t' are interpreted as bit numbers, - // not as part of the description; the visual arrangement is - // misleading. + // not as part of the description; the visual arrangement in this + // example is intentionally misleading. h_snprintb( "\020" "\001least significant" @@ -318,16 +319,10 @@ ATF_TC_BODY(snprintb, tc) 0xff, "0xff<lsb,,,msb>"); - // old style, buffer size 0 - // - // With the buffer size being 0, the buffer is not modified at all. - h_snprintb_len( - 0, "\020", 0, - 1, ""); - // old style, buffer size 0, null buffer // - // If the buffer size is 0, the buffer may be NULL. + // If the buffer size is 0, the buffer is not accessed at all and + // may be a null pointer. int null_rv_old = snprintb(NULL, 0, "\020\001lsb", 0x01); ATF_CHECK_MSG( null_rv_old == 8, @@ -335,67 +330,62 @@ ATF_TC_BODY(snprintb, tc) // old style, buffer too small for value h_snprintb_len( - 1, "\020", 0, + 1, "\020", 0x00, 1, ""); // old style, buffer large enough for zero value h_snprintb_len( - 2, "\020", 0, - 1, "0"); - - // old style, buffer larger than necessary for zero value - h_snprintb_len( - 3, "\020", 0, + 2, "\020", 0x00, 1, "0"); // old style, buffer too small for nonzero value h_snprintb_len( - 3, "\020", 7, + 3, "\020", 0x07, 3, "0x"); // old style, buffer large enough for nonzero value h_snprintb_len( - 4, "\020", 7, + 4, "\020", 0x07, 3, "0x7"); // old style, buffer too small for '<' h_snprintb_len( - 4, "\020\001lsb", 7, + 4, "\020\001lsb", 0x07, 8, "0x7"); // old style, buffer too small for description h_snprintb_len( - 7, "\020\001lsb", 7, + 7, "\020\001lsb", 0x07, 8, "0x7<ls"); // old style, buffer too small for '>' h_snprintb_len( - 8, "\020\001lsb", 7, + 8, "\020\001lsb", 0x07, 8, "0x7<lsb"); - // old style, buffer large enough for '<' + // old style, buffer large enough for '>' h_snprintb_len( - 9, "\020\001lsb", 7, + 9, "\020\001lsb", 0x07, 8, "0x7<lsb>"); // old style, buffer too small for second description h_snprintb_len( - 9, "\020\001one\002two", 7, + 9, "\020\001one\002two", 0x07, 12, "0x7<one,"); // old style, buffer too small for second description h_snprintb_len( - 10, "\020\001one\002two", 7, + 10, "\020\001one\002two", 0x07, 12, "0x7<one,t"); // old style, buffer too small for '>' after second description h_snprintb_len( - 12, "\020\001one\002two", 7, + 12, "\020\001one\002two", 0x07, 12, "0x7<one,two"); // old style, buffer large enough for '>' after second description h_snprintb_len( - 13, "\020\001one\002two", 7, + 13, "\020\001one\002two", 0x07, 12, "0x7<one,two>"); // new style, buffer size 0, null buffer @@ -478,6 +468,8 @@ ATF_TC_BODY(snprintb, tc) "256<byte0=0,byte1=1>"); // new style named bit-field, hexadecimal + // + // The bit-field value gets a leading '0x' iff it is nonzero. h_snprintb( "\177\020" "f\000\010byte0\0" @@ -541,25 +533,25 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, from 1 width 9 // - // The '=' and ':' directives can only match a bit-field value between + // The '=' and ':' directives can match a bit-field value between // 0 and 255, independent of the bit-field's width. h_snprintb( "\177\020" "f\001\011uint9\0" "=\203match\0" - "*=other-f\0" + "*=default-f\0" "F\001\011\0" ":\203match\0" - "*other-F\0", + "*default-F\0", 0x0306, - "0x306<uint9=0x183=other-f,other-F>"); + "0x306<uint9=0x183=default-f,default-F>"); - // new style bit-field, from 32 width 32 + // new style bit-field, from 24 width 32 h_snprintb( "\177\020" - "f\040\040uint32\0", + "f\030\040uint32\0", 0xaaaa555500000000, - "0xaaaa555500000000<uint32=0xaaaa5555>"); + "0xaaaa555500000000<uint32=0xaa555500>"); // new style bit-field, from 60 width 4 h_snprintb( @@ -595,8 +587,8 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, empty field description // - // The description of a field may be empty, though this is probably a - // mistake, as it outputs an isolated '='. + // An empty field description results in an isolated '=', which is a + // mistake. h_snprintb( "\177\020" "f\000\004\0" @@ -622,8 +614,8 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, '=' with empty description // - // The description of a '=' directive may be empty, though this is - // probably a mistake, as it outputs several '=' in a row. + // The description of a '=' directive should not be empty, as the + // outputs contains several '=' in a row. h_snprintb( "\177\020" "f\000\004f\0" @@ -635,8 +627,8 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, 'F' followed by ':' with empty description // - // The description of a ':' directive may be empty, though this is - // probably a mistake, as it leads to empty angle brackets. + // An empty description of a ':' directive that doesn't match results + // in empty angle brackets, which is a mistake. h_snprintb( "\177\020" "F\000\004\0" @@ -647,9 +639,9 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, 'F', ':' with empty description, '*' // - // The ':' directive could be used to suppress a following '*' - // directive, but this combination is probably a mistake, as a - // matching ':' leads to empty angle brackets. + // An empty description of a ':' directive that matches results in + // normal-looking output, but if it didn't match, the output would + // contain empty angle brackets, which is a mistake. h_snprintb( "\177\020" "F\000\004\0" @@ -669,8 +661,9 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, 'F' with non-exhaustive ':' // - // A bit-field that does not match any values still generates empty - // angle brackets. + // An unnamed bit-field that does not match any values generates empty + // angle brackets, which looks confusing. The ':' directives should + // either be exhaustive, or there should be a '*' catch-all directive. h_snprintb( "\177\020" "F\000\004\0" @@ -681,8 +674,9 @@ ATF_TC_BODY(snprintb, tc) // new style bit-field, 'F' with non-exhaustive ':' // - // A bit-field that does not match any values still generates empty - // angle brackets or adjacent commas. + // A bit-field that does not match any values generates multiple commas + // in a row, which looks confusing. The ':' directives should either be + // exhaustive, or there should be a '*' catch-all directive. h_snprintb( "\177\020" "b\000bit0\0" @@ -694,6 +688,9 @@ ATF_TC_BODY(snprintb, tc) "0x3<bit0,,bit1>"); // new style bit-field, '=', can never match + // + // The extracted value from the bit-field has 7 bits and is thus less + // than 128, therefore it can neither match 128 nor 255. h_snprintb( "\177\020" "f\000\007f\0" @@ -742,17 +739,17 @@ ATF_TC_BODY(snprintb, tc) // // The ':' directive can almost emulate the '=' directive, without the // numeric output and with a different separator. It's best to use - // either 'f' with '=' or 'F' with ':', but not mix them. + // either 'f' with '=', or 'F' with ':', but not mix them. h_snprintb( "\177\020" "f\000\004field\0" - "=\010value\0" - "F\000\000\0" - ":\000field\0" // Since the description of 'F' is ignored. + "=\010f-value\0" + "F\000\000\0" // Use an empty bit-field + ":\000separator\0" // to generate a separator. "F\000\004\0" - ":\010value\0", + ":\010F-value\0", 0x18, - "0x18<field=0x8=value,field,value>"); + "0x18<field=0x8=f-value,separator,F-value>"); // new style bit-field default, fixed string // @@ -785,6 +782,8 @@ ATF_TC_BODY(snprintb, tc) "0x1122<f=0x11=f(17),F(34)>"); // new style bit-field default, can never match + // + // The '=' directive are exhaustive, making the '*' redundant. h_snprintb( "\177\020" "f\010\002f\0" @@ -792,7 +791,7 @@ ATF_TC_BODY(snprintb, tc) "=\001one\0" "=\002two\0" "=\003three\0" - "*other\0", + "*default\0", 0xff00, "0xff00<f=0x3=three>"); @@ -823,9 +822,8 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, 'b' '=' // - // A '=' directive without a preceding 'f' or 'F' directive applies to - // the whole value; its description may appear inside or outside the - // angle brackets. Having such a format is likely an error. + // A '=' directive without a preceding 'f' or 'F' directive generates + // misleading output outside the angle brackets, which is a mistake. h_snprintb( "\177\020" "b\004bit4\0" @@ -841,9 +839,9 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, 'b' ':' // - // A ':' directive without a preceding 'f' or 'F' directive applies to - // the whole value; its description may appear inside or outside the - // angle brackets. Having such a format is likely an error. + // A ':' directive without a preceding 'f' or 'F' directive generates + // misleading output outside or inside the angle brackets, which is a + // mistake. h_snprintb( "\177\020" "b\004bit4\0" @@ -871,31 +869,32 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, 'f' 'b' '=' // - // Between an 'f' and an '=' directive, there may be unrelated 'b' - // directives, they do not affect the value of the "previous field". - // Formats like these are probably mistakes. + // A 'b' directive that occurs between an 'f' and an '=' directive + // generates misleading output, which is a mistake. h_snprintb( "\177\020" "f\000\010f\0" "b\005bit5\0" - "=\xa5match\0", + "=\245match\0", 0xa5, "0xa5<f=0xa5,bit5=match>"); // new style combinations, 'f' 'b' ':' // - // Between an 'f' and a ':' directive, there may be unrelated 'b' - // directives, they do not affect the value of the "previous field". - // Formats like these are mistakes, as the output is garbled. + // A 'b' directive that occurs between an 'f' and a ':' directive + // generates misleading output, which is a mistake. h_snprintb( "\177\020" "f\000\010f\0" "b\005bit5\0" - ":\xa5match\0", + ":\245match\0", 0xa5, "0xa5<f=0xa5,bit5match>"); // new style combinations, 'f' ':' + // + // Combining the 'f' directive with the ':' directive produces the + // misleading output '0x1one', which is a mistake. h_snprintb( "\177\20" "f\000\004nibble\0" @@ -906,7 +905,7 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, 'F' '=' // // Combining the 'F' and '=' directives outputs an isolated '=', which - // doesn't look well-formed. + // is a mistake. h_snprintb( "\177\20" "F\000\004\0" @@ -916,30 +915,29 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, '=' // - // A '=' directive without a preceding 'f' or 'F' directive matches on - // the complete value. This is not documented in the manual page, and - // formats like these are probably mistakes. + // A '=' directive without a preceding 'f' or 'F' directive generates + // output that doesn't match the standard '0xaa<description>' form, + // which is a mistake. h_snprintb( "\177\020" - "=\xa5match\0", + "=\245match\0", 0xa5, "0xa5=match"); // new style combinations, ':' // - // A ':' directive without a preceding 'f' or 'F' directive matches on - // the complete value. This is not documented in the manual page, and - // formats like these are probably mistakes. + // A ':' directive without a preceding 'f' or 'F' directive generates + // misleading output, which is a mistake. h_snprintb( "\177\020" - ":\xa5match\0", + ":\245match\0", 0xa5, "0xa5match"); // new style combinations, '*' // - // A '*' directive without a preceding 'f' or 'F' is skipped. Formats - // like these are mistakes. + // A '*' directive without a preceding 'f' or 'F' is useless, which is + // a mistake. h_snprintb( "\177\020" "*match\0", @@ -948,33 +946,32 @@ ATF_TC_BODY(snprintb, tc) // new style combinations, 'f' '*' '=' // - // A '*' directive may be followed by a '=' directive. Formats like - // this are probably a mistake. + // After a catch-all '*' directive, any following '=' directive + // generates misleading output, which is a mistake. h_snprintb( "\177\020" "f\000\010f\0" "*=default\0" - "=\xa5match\0", + "=\245match\0", 0xa5, "0xa5<f=0xa5=default=match>"); // new style combinations, 'F' '*' ':' // - // A '*' directive may be followed by a ':' directive. Formats like - // this are probably a mistake. + // After a catch-all '*' directive, any following ':' directive + // generates misleading output, which is a mistake. h_snprintb( "\177\020" "F\000\010F\0" "*default\0" - ":\xa5-match\0", + ":\245-match\0", 0xa5, "0xa5<default-match>"); // new style combinations, '*' '*' // - // The first '*' directive matches everything, so the second '*' - // directive cannot match anything and is thus redundant. Formats like - // this are a mistake. + // After a catch-all '*' directive, any further '*' directive is + // ignored and thus redundant, which is a mistake. h_snprintb( "\177\020" "f\000\010f\0" @@ -986,13 +983,19 @@ ATF_TC_BODY(snprintb, tc) 0xa5, "0xa5<f=0xa5=default-f,default-F>"); - // manual page, old style octal + // example from the manual page, old style octal h_snprintb( "\10\2BITTWO\1BITONE", - 3, + 0x03, "03<BITTWO,BITONE>"); - // manual page, old style hexadecimal + // example from the manual page, old style hexadecimal + // + // When using a hexadecimal escape sequence to encode a bit number, + // the description must not start with a hexadecimal digit, or that + // digit is interpreted as part of the bit number. To prevent this, + // the bit number and the description need to be written as separate + // string literals. h_snprintb( "\20" "\x10NOTBOOT" "\x0f""FPP" "\x0eSDVMA" @@ -1002,7 +1005,7 @@ ATF_TC_BODY(snprintb, tc) 0xe860, "0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>"); - // manual page, new style bits and fields + // example from the manual page, new style bits and fields h_snprintb( "\177\020" "b\0LSB\0" "b\1BITONE\0" @@ -1012,7 +1015,7 @@ ATF_TC_BODY(snprintb, tc) 0x800f0701, "0x800f0701<LSB,NIBBLE2=0,BURST=0xf=FIFTEEN,MSB>"); - // manual page, new style mmap + // example from the manual page, new style mmap #define MAP_FMT \ "\177\020" \ "b\0" "SHARED\0" \ @@ -1068,43 +1071,43 @@ ATF_TC_BODY(snprintb, tc) // new style, small buffers h_snprintb_len( - 0, "\177\020", 0, + 0, "\177\020", 0x00, 1, ""); h_snprintb_len( - 1, "\177\020", 0, + 1, "\177\020", 0x00, 1, ""); h_snprintb_len( - 2, "\177\020", 0, + 2, "\177\020", 0x00, 1, "0"); h_snprintb_len( - 3, "\177\020", 0, + 3, "\177\020", 0x00, 1, "0"); h_snprintb_len( - 3, "\177\020", 7, + 3, "\177\020", 0x07, 3, "0x"); h_snprintb_len( - 4, "\177\020", 7, + 4, "\177\020", 0x07, 3, "0x7"); h_snprintb_len( - 7, "\177\020b\000lsb\0", 7, + 7, "\177\020b\000lsb\0", 0x07, 8, "0x7<ls"); h_snprintb_len( - 8, "\177\020b\000lsb\0", 7, + 8, "\177\020b\000lsb\0", 0x07, 8, "0x7<lsb"); h_snprintb_len( - 9, "\177\020b\000lsb\0", 7, + 9, "\177\020b\000lsb\0", 0x07, 8, "0x7<lsb>"); h_snprintb_len( - 9, "\177\020b\000one\0b\001two\0", 7, + 9, "\177\020b\000one\0b\001two\0", 0x07, 12, "0x7<one,"); h_snprintb_len( - 10, "\177\020b\000one\0b\001two\0", 7, + 10, "\177\020b\000one\0b\001two\0", 0x07, 12, "0x7<one,t"); h_snprintb_len( - 12, "\177\020b\000one\0b\001two\0", 7, + 12, "\177\020b\000one\0b\001two\0", 0x07, 12, "0x7<one,two"); h_snprintb_len( - 13, "\177\020b\000one\0b\001two\0", 7, + 13, "\177\020b\000one\0b\001two\0", 0x07, 12, "0x7<one,two>"); } @@ -1171,7 +1174,7 @@ ATF_TC_BODY(snprintb_m, tc) "0xff<1>\0" "0xff<bit#\0"); - // old style complete + // old style, complete h_snprintb_m( "\020" "\0011" @@ -1185,8 +1188,8 @@ ATF_TC_BODY(snprintb_m, tc) h_snprintb_m( "\177\020", 0xff, - 1, - "#\0"); + 3, + "0x#\0"); // new style, line_max exceeded by single-bit '<' in line 1 h_snprintb_m( @@ -1230,11 +1233,11 @@ ATF_TC_BODY(snprintb_m, tc) h_snprintb_m( "\177\020" "b\000one\0" - "b\001four\0", + "b\001three\0", 0xff, - 9, + 10, "0xff<one>\0" - "0xff<fou#\0"); + "0xff<thre#\0"); // new style, single-bit complete h_snprintb_m( @@ -1262,8 +1265,7 @@ ATF_TC_BODY(snprintb_m, tc) 4, "0xf#\0"); - // new style, line_max exceeded by named bit-field field description - // in line 1 + // new style, line_max exceeded by bit-field description in line 1 h_snprintb_m( "\177\020" "f\000\004lo\0", @@ -1293,8 +1295,8 @@ ATF_TC_BODY(snprintb_m, tc) "f\000\004lo\0" "=\017match\0", 0xff, - 11, - "0xff<lo=0x#\0"); + 12, + "0xff<lo=0xf#\0"); // new style, line_max exceeded by named bit-field value description in // line 1 @@ -1315,7 +1317,8 @@ ATF_TC_BODY(snprintb_m, tc) 17, "0xff<lo=0xf=matc#\0"); - // new style, line_max exceeded by named bit-field description in line 2 + // new style, line_max exceeded by named bit-field description in + // line 2 h_snprintb_m( "\177\020" "f\000\004lo\0" @@ -1355,9 +1358,9 @@ ATF_TC_BODY(snprintb_m, tc) "f\000\004low-bits\0" "=\017match\0", 0xff, - 17, + 18, "0xff<lo=0xf>\0" - "0xff<low-bits=0x#\0"); + "0xff<low-bits=0xf#\0"); // new style, line_max exceeded by named bit-field value description // in line 2 @@ -1472,12 +1475,12 @@ ATF_TC_BODY(snprintb_m, tc) h_snprintb_m( "\177\020" "f\000\004bits\0" - ":\000other\0", + ":\000zero\0", 0xff, 11, "0xff<bits=#\0"); - // manual page, new style bits and fields + // example from the manual page, new style bits and fields h_snprintb_m( "\177\020" "b\0LSB\0" @@ -1502,8 +1505,7 @@ ATF_TC_BODY(snprintb_m, tc) 11, 20, "0xff<lsb>\0" - "0xf\0" // XXX: incomplete number may be misleading - ); + "0xf\0"); // XXX: incomplete number may be misleading // new-style format, buffer too small for '<' in line 2 h_snprintb_m_len( @@ -1515,8 +1517,7 @@ ATF_TC_BODY(snprintb_m, tc) 11, 20, "0xff<lsb>\0" - "0xff\0" - ); + "0xff\0"); // new-style format, buffer too small for fallback h_snprintb_m( @@ -1526,8 +1527,7 @@ ATF_TC_BODY(snprintb_m, tc) "b\0024\0", 0xff, 64, - "0xff<bits=0xf=fallback,4>\0" - ); + "0xff<bits=0xf=fallback,4>\0"); // new-style format, buffer too small for numeric fallback h_snprintb_m_len( @@ -1538,8 +1538,7 @@ ATF_TC_BODY(snprintb_m, tc) 0xff, 64, 57, - "0xff<fallback(0000\0" - ); + "0xff<fallback(0000\0"); // new-style format, buffer too small for numeric fallback past buffer h_snprintb_m_len( @@ -1552,8 +1551,7 @@ ATF_TC_BODY(snprintb_m, tc) 0xff, 64, 48, - "0xff<fallback\0" - ); + "0xff<fallback\0"); // new style, bits and fields, line break between fields h_snprintb_m( @@ -1568,8 +1566,7 @@ ATF_TC_BODY(snprintb_m, tc) 0x800f0701, 33, "0x800f0701<LSB,NIBBLE2=0>\0" - "0x800f0701<BURST=0xf=FIFTEEN,MSB>\0" - ); + "0x800f0701<BURST=0xf=FIFTEEN,MSB>\0"); // new style, bits and fields, line break after field description h_snprintb_m( @@ -1577,10 +1574,10 @@ ATF_TC_BODY(snprintb_m, tc) "b\0LSB\0" "b\1_BITONE\0" "f\4\4NIBBLE2\0" - "f\x10\4BURST\0" + "f\020\4BURST\0" "=\04FOUR\0" "=\17FIFTEEN\0" - "b\x1fMSB\0", + "b\037MSB\0", 0x800f0701, 32, "0x800f0701<LSB,NIBBLE2=0>\0"