diff options
author | David Garcia Quintas <dgq@google.com> | 2015-10-05 13:40:07 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-10-05 13:40:07 -0700 |
commit | 809831eef7263c2c6ed189b28c5df617cbb8a543 (patch) | |
tree | 93210bbb860c7a7570c46be36db2614396c0d96c /tools/codegen/core | |
parent | d76cdac17a394d5a4be882ef0474db605db0c950 (diff) |
Added comments
Diffstat (limited to 'tools/codegen/core')
-rw-r--r-- | tools/codegen/core/gen_hpack_tables.c | 10 | ||||
-rw-r--r-- | tools/codegen/core/gen_legal_metadata_characters.c | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/codegen/core/gen_hpack_tables.c b/tools/codegen/core/gen_hpack_tables.c index 21667f0651..48398bebd5 100644 --- a/tools/codegen/core/gen_hpack_tables.c +++ b/tools/codegen/core/gen_hpack_tables.c @@ -71,6 +71,11 @@ static unsigned char prefix_mask(unsigned char prefix_len) { unsigned char i; unsigned char out = 0; for (i = 0; i < prefix_len; i++) { + /* NB: the following integer arithmetic operation needs to be in its + * expanded form due to the "integral promotion" performed (see section + * 3.2.1.1 of the C89 draft standard), which in this case upcasts the result + * of the bitwise OR to "unsigned". A cast to the smaller container type is + * then required to avoid the compiler warning */ out = (unsigned char)(out | (unsigned char)(1 << (7 - i))); } return out; @@ -92,6 +97,11 @@ static void generate_first_byte_lut(void) { chrspec = NULL; for (j = 0; j < num_fields; j++) { if ((prefix_mask(fields[j].prefix_length) & i) == fields[j].prefix) { + /* NB: the following integer arithmetic operation needs to be in its + * expanded form due to the "integral promotion" performed (see section + * 3.2.1.1 of the C89 draft standard), which in this case upcasts the + * result of the bitwise AND to "unsigned". A cast to the smaller + * container type is then required to avoid the compiler warning */ suffix = (unsigned char)(suffix_mask(fields[j].prefix_length) & (unsigned char)i); if (suffix == suffix_mask(fields[j].prefix_length)) { diff --git a/tools/codegen/core/gen_legal_metadata_characters.c b/tools/codegen/core/gen_legal_metadata_characters.c index 5783c3ff69..3718916577 100644 --- a/tools/codegen/core/gen_legal_metadata_characters.c +++ b/tools/codegen/core/gen_legal_metadata_characters.c @@ -41,6 +41,11 @@ static unsigned char legal_bits[256 / 8]; static void legal(int x) { int byte = x / 8; int bit = x % 8; + /* NB: the following integer arithmetic operation needs to be in its + * expanded form due to the "integral promotion" performed (see section + * 3.2.1.1 of the C89 draft standard), which in this case upcasts the result + * of the bitwise OR to "unsigned". A cast to the smaller container type is + * then required to avoid the compiler warning */ legal_bits[byte] = (unsigned char)((legal_bits[byte] | (unsigned char)(1 << bit))); } |