+/* Returns the string representation of the given cfm_fault_reason 'reason'. */
+const char *
+cfm_fault_reason_to_str(int reason) {
+ switch (reason) {
+#define CFM_FAULT_REASON(NAME, STR) case CFM_FAULT_##NAME: return #STR;
+ CFM_FAULT_REASONS
+#undef CFM_FAULT_REASON
+ default: return "<unknown>";
+ }
+}
+
+static void
+ds_put_cfm_fault(struct ds *ds, int fault)
+{
+ size_t length = ds->length;
+ int i;
+
+ for (i = 0; i < CFM_FAULT_N_REASONS; i++) {
+ int reason = 1 << i;
+
+ if (fault & reason) {
+ ds_put_format(ds, "%s ", cfm_fault_reason_to_str(reason));
+ }
+ }
+
+ if (ds->length > length) {
+ ds_truncate(ds, ds->length - 1);
+ }
+}
+