aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-10-06 13:31:55 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-10-06 13:31:55 -0700
commit1485683fcd725169a9b8d9cd3f1dbf1706da6045 (patch)
tree6a8712d2ee5e0ba0247bbd8039c28eb930a03ffd /tools
parentfbfd3d42d2f4fcbc627b713f5ba7f0540bc0a8d0 (diff)
parent35284f0c8442ae31dc9057583d2064c5257fae4f (diff)
Merge pull request #3615 from dgquintas/gcc_520
Type conversion fixes to make GCC 5.2.0 happy
Diffstat (limited to 'tools')
-rw-r--r--tools/codegen/core/gen_hpack_tables.c13
-rw-r--r--tools/codegen/core/gen_legal_metadata_characters.c7
2 files changed, 17 insertions, 3 deletions
diff --git a/tools/codegen/core/gen_hpack_tables.c b/tools/codegen/core/gen_hpack_tables.c
index d924aba602..bae4e4cd73 100644
--- a/tools/codegen/core/gen_hpack_tables.c
+++ b/tools/codegen/core/gen_hpack_tables.c
@@ -71,7 +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++) {
- out |= (unsigned char)(1 << (7 - 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). 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,7 +96,12 @@ 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) {
- suffix = suffix_mask(fields[j].prefix_length) & (unsigned char)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). 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)) {
if (fields[j].index != 2) continue;
} else if (suffix == 0) {
diff --git a/tools/codegen/core/gen_legal_metadata_characters.c b/tools/codegen/core/gen_legal_metadata_characters.c
index 2ffda54a21..677fa5c155 100644
--- a/tools/codegen/core/gen_legal_metadata_characters.c
+++ b/tools/codegen/core/gen_legal_metadata_characters.c
@@ -41,7 +41,12 @@ static unsigned char legal_bits[256 / 8];
static void legal(int x) {
int byte = x / 8;
int bit = x % 8;
- legal_bits[byte] |= (unsigned char)(1 << bit);
+ /* 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). 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)));
}
static void dump(void) {