"failout",
"dryrun",
"all_targets",
+ "broadcast",
+ "orphan",
NULL
};
int flag;
int rc;
int i;
+ bool newline = (bits != 0 ? false : true);
- rc = snprintf(*buf, *len, "%s:%c", prefix, bits != 0 ? ' ' : '\n');
+ rc = snprintf(*buf, *len, "%s:%c", prefix, newline ? '\n' : ' ');
if (rc <= 0)
return -ENOSPC;
if (flag & bits) {
bits &= ~flag;
if (names[i] != NULL) {
+ if (bits == 0)
+ newline = true;
+
rc = snprintf(*buf, *len, "%s%c", names[i],
- bits != 0 ? ',' : '\n');
+ newline ? '\n' : ',');
if (rc <= 0)
return -ENOSPC;
}
}
}
+
+ if (!newline) {
+ rc = snprintf(*buf, *len, "\n");
+ if (rc <= 0)
+ return -ENOSPC;
+
+ *buf += rc;
+ *len -= rc;
+ }
+
return save - *len;
}