Control: tags -1 patch This patch should work, but is untested on hppa. James
Description: Fix FTBFS on hppa - add handling of flags with multiple bits set
On hppa the 'eventfd EINVAL' test was failing because the EFD_NONBLOCK was
being incorrectly parsed. On hppa this flag sets two separate bits but the
explain_parse_bits_print function does not handle this case. Fix by rewriting
the algorithm to work on both cases. The access_modes table needed reordering
to keep the old behavior there (this patch might change the ordering of some
flags).
Author: James Cowgill <jcowgill@debian.org>
Bug-Debian: https://bugs.debian.org/834511
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/libexplain/parse_bits/print.c
+++ b/libexplain/parse_bits/print.c
@@ -26,7 +26,7 @@ explain_parse_bits_print(explain_string_
const explain_parse_bits_table_t *table, int table_size)
{
int first;
- int other;
+ int i;
if (value == 0)
{
@@ -34,32 +34,29 @@ explain_parse_bits_print(explain_string_
return;
}
first = 1;
- other = 0;
- for (;;)
- {
- int bit;
- const explain_parse_bits_table_t *tp;
- bit = value & -value;
- value -= bit;
- tp = explain_parse_bits_find_by_value(bit, table, table_size);
- if (tp)
+ // Iterate over entire table checking value against each flag
+ for (i = 0; i < table_size; i++)
+ {
+ int flag = table[i].value;
+ if (flag != 0 && (flag & value) == flag)
{
+ value -= flag;
+
if (!first)
explain_string_buffer_puts(sb, " | ");
- explain_string_buffer_puts(sb, tp->name);
+ explain_string_buffer_puts(sb, table[i].name);
first = 0;
+
+ if (value == 0)
+ break;
}
- else
- other |= bit;
- if (!value)
- break;
}
- if (other)
+ if (value != 0)
{
if (!first)
explain_string_buffer_puts(sb, " | ");
- explain_string_buffer_printf(sb, "0x%X", other);
+ explain_string_buffer_printf(sb, "0x%X", value);
}
}
--- a/libexplain/buffer/access_mode.c
+++ b/libexplain/buffer/access_mode.c
@@ -27,10 +27,10 @@
static const explain_parse_bits_table_t table[] =
{
- { "F_OK", F_OK },
- { "R_OK", R_OK },
- { "W_OK", W_OK },
{ "X_OK", X_OK },
+ { "W_OK", W_OK },
+ { "R_OK", R_OK },
+ { "F_OK", F_OK },
};
Attachment:
signature.asc
Description: OpenPGP digital signature