Commit 74945024 authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

Reformat char literals in HTTP2 to use '\xNN' format.

This way, there won't be a signedness issue when compared to the
internal codebase.

Merge internal change: 222066172

R=bnc@chromium.org

Change-Id: I5c528d96fa459b039582ba3852a16da158db1f70
Reviewed-on: https://chromium-review.googlesource.com/c/1341653Reviewed-by: default avatarBence Béky <bnc@chromium.org>
Commit-Queue: Victor Vasiliev <vasilvv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609321}
parent 43566aa1
......@@ -105,12 +105,12 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) {
{
// Realistic input.
const char kData[] = {
0x00, 0x00, 0x05, // Payload length: 5
0x01, // Frame type: HEADERS
0x08, // Flags: PADDED
0x00, 0x00, 0x00, 0x01, // Stream ID: 1
0x04, // Padding length: 4
0x00, 0x00, 0x00, 0x00, // Padding bytes
'\x00', '\x00', '\x05', // Payload length: 5
'\x01', // Frame type: HEADERS
'\x08', // Flags: PADDED
'\x00', '\x00', '\x00', '\x01', // Stream ID: 1
'\x04', // Padding length: 4
'\x00', '\x00', '\x00', '\x00', // Padding bytes
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -123,10 +123,10 @@ TEST_F(FrameHeaderDecoderTest, DecodesLiteral) {
{
// Unlikely input.
const char kData[] = {
0xffu, 0xffu, 0xffu, // Payload length: uint24 max
0xffu, // Frame type: Unknown
0xffu, // Flags: Unknown/All
0xffu, 0xffu, 0xffu, 0xffu, // Stream ID: uint31 max, plus R-bit
'\xff', '\xff', '\xff', // Payload length: uint24 max
'\xff', // Frame type: Unknown
'\xff', // Flags: Unknown/All
'\xff', '\xff', '\xff', '\xff', // Stream ID: uint31 max, plus R-bit
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -150,8 +150,8 @@ class PriorityFieldsDecoderTest
TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x80u, 0x00, 0x00, 0x05, // Exclusive (yes) and Dependency (5)
0xffu, // Weight: 256 (after adding 1)
'\x80', '\x00', '\x00', '\x05', // Exclusive (yes) and Dependency (5)
'\xff', // Weight: 256 (after adding 1)
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -162,9 +162,9 @@ TEST_F(PriorityFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0x7f, 0xffu,
0xffu, 0xffu, // Exclusive (no) and Dependency (0x7fffffff)
0x00, // Weight: 1 (after adding 1)
'\x7f', '\xff',
'\xff', '\xff', // Exclusive (no) and Dependency (0x7fffffff)
'\x00', // Weight: 1 (after adding 1)
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -187,7 +187,7 @@ class RstStreamFieldsDecoderTest
TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x00, 0x00, 0x01, // Error: PROTOCOL_ERROR
'\x00', '\x00', '\x00', '\x01', // Error: PROTOCOL_ERROR
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -197,7 +197,8 @@ TEST_F(RstStreamFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Error: max uint32 (Unknown error code)
'\xff', '\xff', '\xff',
'\xff', // Error: max uint32 (Unknown error code)
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -219,8 +220,8 @@ class SettingFieldsDecoderTest
TEST_F(SettingFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x01, // Setting: HEADER_TABLE_SIZE
0x00, 0x00, 0x40, 0x00, // Value: 16K
'\x00', '\x01', // Setting: HEADER_TABLE_SIZE
'\x00', '\x00', '\x40', '\x00', // Value: 16K
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -232,8 +233,8 @@ TEST_F(SettingFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0x00, 0x00, // Setting: Unknown (0)
0xffu, 0xffu, 0xffu, 0xffu, // Value: max uint32
'\x00', '\x00', // Setting: Unknown (0)
'\xff', '\xff', '\xff', '\xff', // Value: max uint32
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -255,7 +256,7 @@ class PushPromiseFieldsDecoderTest
TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x01, 0x8au, 0x92u, // Promised Stream ID: 101010
'\x00', '\x01', '\x8a', '\x92', // Promised Stream ID: 101010
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -266,7 +267,8 @@ TEST_F(PushPromiseFieldsDecoderTest, DecodesLiteral) {
// Promised stream id has R-bit (reserved for future use) set, which
// should be cleared by the decoder.
const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Promised Stream ID: max uint31 and R-bit
'\xff', '\xff', '\xff',
'\xff', // Promised Stream ID: max uint31 and R-bit
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -287,7 +289,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
{
// Each byte is different, so can detect if order changed.
const char kData[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -298,7 +300,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
{
// All zeros, detect problems handling NULs.
const char kData[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -308,7 +310,7 @@ TEST_F(PingFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -330,8 +332,8 @@ class GoAwayFieldsDecoderTest : public StructureDecoderTest<Http2GoAwayFields> {
TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x00, 0x00, 0x00, // Last Stream ID: 0
0x00, 0x00, 0x00, 0x00, // Error: NO_ERROR (0)
'\x00', '\x00', '\x00', '\x00', // Last Stream ID: 0
'\x00', '\x00', '\x00', '\x00', // Error: NO_ERROR (0)
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -342,8 +344,8 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0x00, 0x00, 0x00, 0x01, // Last Stream ID: 1
0x00, 0x00, 0x00, 0x0d, // Error: HTTP_1_1_REQUIRED
'\x00', '\x00', '\x00', '\x01', // Last Stream ID: 1
'\x00', '\x00', '\x00', '\x0d', // Error: HTTP_1_1_REQUIRED
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -354,8 +356,10 @@ TEST_F(GoAwayFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0xffu, 0xffu, 0xffu, 0xffu, // Last Stream ID: max uint31 and R-bit
0xffu, 0xffu, 0xffu, 0xffu, // Error: max uint32 (Unknown error code)
'\xff', '\xff',
'\xff', '\xff', // Last Stream ID: max uint31 and R-bit
'\xff', '\xff',
'\xff', '\xff', // Error: max uint32 (Unknown error code)
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -378,7 +382,7 @@ class WindowUpdateFieldsDecoderTest
TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x01, 0x00, 0x00, // Window Size Increment: 2 ^ 16
'\x00', '\x01', '\x00', '\x00', // Window Size Increment: 2 ^ 16
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -389,7 +393,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
// Increment must be non-zero, but we need to be able to decode the invalid
// zero to detect it.
const char kData[] = {
0x00, 0x00, 0x00, 0x00, // Window Size Increment: 0
'\x00', '\x00', '\x00', '\x00', // Window Size Increment: 0
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -402,7 +406,7 @@ TEST_F(WindowUpdateFieldsDecoderTest, DecodesLiteral) {
// clang-format off
const char kData[] = {
// Window Size Increment: max uint31 and R-bit
0xffu, 0xffu, 0xffu, 0xffu,
'\xff', '\xff', '\xff', '\xff',
};
// clang-format on
DecodeLeadingStructure(kData);
......@@ -424,7 +428,7 @@ class AltSvcFieldsDecoderTest : public StructureDecoderTest<Http2AltSvcFields> {
TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
{
const char kData[] = {
0x00, 0x00, // Origin Length: 0
'\x00', '\x00', // Origin Length: 0
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -433,7 +437,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0x00, 0x14, // Origin Length: 20
'\x00', '\x14', // Origin Length: 20
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......@@ -442,7 +446,7 @@ TEST_F(AltSvcFieldsDecoderTest, DecodesLiteral) {
}
{
const char kData[] = {
0xffu, 0xffu, // Origin Length: uint16 max
'\xff', '\xff', // Origin Length: uint16 max
};
DecodeLeadingStructure(kData);
if (!HasFailure()) {
......
......@@ -56,7 +56,7 @@ class HpackEntryDecoderTest : public RandomDecoderTest {
TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
{
const char input[] = {0x82u}; // == Index 2 ==
const char input[] = {'\x82'}; // == Index 2 ==
DecodeBuffer b(input);
auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(2));
......@@ -67,7 +67,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
}
collector_.Clear();
{
const char input[] = {0xfeu}; // == Index 126 ==
const char input[] = {'\xfe'}; // == Index 126 ==
DecodeBuffer b(input);
auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(126));
......@@ -78,7 +78,7 @@ TEST_F(HpackEntryDecoderTest, IndexedHeader_Literals) {
}
collector_.Clear();
{
const char input[] = {0xffu, 0x00}; // == Index 127 ==
const char input[] = {'\xff', '\x00'}; // == Index 127 ==
DecodeBuffer b(input);
auto do_check = [this]() {
VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(127));
......
......@@ -81,7 +81,7 @@ class HpackStringDecoderTest : public RandomDecoderTest {
TEST_F(HpackStringDecoderTest, DecodeEmptyString) {
{
Validator validator = ValidateDoneAndEmpty(MakeValidator("", kCompressed));
const char kData[] = {0x80u};
const char kData[] = {'\x80'};
DecodeBuffer b(kData);
EXPECT_TRUE(
DecodeAndValidateSeveralWays(&b, kMayReturnZeroOnFirst, validator));
......@@ -90,7 +90,7 @@ TEST_F(HpackStringDecoderTest, DecodeEmptyString) {
// Make sure it stops after decoding the empty string.
Validator validator =
ValidateDoneAndOffset(1, MakeValidator("", kUncompressed));
const char kData[] = {0x00, 0xffu};
const char kData[] = {'\x00', '\xff'};
DecodeBuffer b(kData);
EXPECT_EQ(2u, b.Remaining());
EXPECT_TRUE(
......
......@@ -115,9 +115,9 @@ TEST(HpackBlockBuilderTest, ExamplesFromSpecC4) {
b.AppendIndexedHeader(kStaticTableMethodGET);
b.AppendIndexedHeader(kStaticTableSchemeHttp);
b.AppendIndexedHeader(kStaticTablePathSlash);
const char kHuffmanWwwExampleCom[] = {0xf1u, 0xe3u, 0xc2u, 0xe5u,
0xf2u, 0x3au, 0x6bu, 0xa0u,
0xabu, 0x90u, 0xf4u, 0xffu};
const char kHuffmanWwwExampleCom[] = {'\xf1', '\xe3', '\xc2', '\xe5',
'\xf2', '\x3a', '\x6b', '\xa0',
'\xab', '\x90', '\xf4', '\xff'};
b.AppendNameIndexAndLiteralValue(
HpackEntryType::kIndexedLiteralHeader, 1, kCompressed,
Http2StringPiece(kHuffmanWwwExampleCom, sizeof kHuffmanWwwExampleCom));
......@@ -139,7 +139,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(0);
EXPECT_EQ(1u, b.size());
const char kData[] = {0x20};
const char kData[] = {'\x20'};
Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer());
}
......@@ -148,7 +148,7 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(4096); // The default size.
EXPECT_EQ(3u, b.size());
const char kData[] = {0x3f, 0xe1u, 0x1f};
const char kData[] = {'\x3f', '\xe1', '\x1f'};
Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer());
}
......@@ -157,7 +157,8 @@ TEST(HpackBlockBuilderTest, DynamicTableSizeUpdate) {
b.AppendDynamicTableSizeUpdate(1000000000000); // A very large value.
EXPECT_EQ(7u, b.size());
const char kData[] = {0x3fu, 0xe1u, 0x9fu, 0x94u, 0xa5u, 0x8du, 0x1du};
const char kData[] = {'\x3f', '\xe1', '\x9f', '\x94',
'\xa5', '\x8d', '\x1d'};
Http2StringPiece expected(kData, sizeof kData);
EXPECT_EQ(expected, b.buffer());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment