ps->buf = string(ps->buf, ps->end, s, ps->spec);
}
+static void printf_char(struct printf_state *ps, char c)
+{
+ if (ps->buf < ps->end)
+ *ps->buf = c;
+ ps->buf++;
+}
+
static noinline_for_stack
char *pointer_string(struct printf_state *ps, const void *ptr)
{
printf_string(ps, hd->disk_name);
if (bdev->bd_part->partno) {
- if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) {
- if (ps->buf < ps->end)
- *ps->buf = 'p';
- ps->buf++;
- }
+ if (isdigit(hd->disk_name[strlen(hd->disk_name)-1]))
+ printf_char(ps, 'p');
printf_number(ps, bdev->bd_part->partno);
}
return ps->buf;
len = min_t(int, ps->spec.field_width, 64);
for (i = 0; i < len; ++i) {
- if (ps->buf < ps->end)
- *ps->buf = hex_asc_hi(addr[i]);
- ++ps->buf;
- if (ps->buf < ps->end)
- *ps->buf = hex_asc_lo(addr[i]);
- ++ps->buf;
+ printf_char(ps, hex_asc_hi(addr[i]));
+ printf_char(ps, hex_asc_lo(addr[i]));
- if (separator && i != len - 1) {
- if (ps->buf < ps->end)
- *ps->buf = separator;
- ++ps->buf;
- }
+ if (separator && i != len - 1)
+ printf_char(ps, separator);
}
return ps->buf;
bit = i % BITS_PER_LONG;
val = (bitmap[word] >> bit) & chunkmask;
- if (!first) {
- if (ps->buf < ps->end)
- *ps->buf = ',';
- ps->buf++;
- }
+ if (!first)
+ printf_char(ps, ',');
first = false;
ps->spec.field_width = DIV_ROUND_UP(chunksz, 4);
if (cur < nr_bits && cur <= rtop + 1)
continue;
- if (!first) {
- if (ps->buf < ps->end)
- *ps->buf = ',';
- ps->buf++;
- }
+ if (!first)
+ printf_char(ps, ',');
first = false;
printf_number(ps, rbot);
if (rbot < rtop) {
- if (ps->buf < ps->end)
- *ps->buf = '-';
- ps->buf++;
-
+ printf_char(ps, '-');
printf_number(ps, rtop);
}
printf_string(ps, names->name);
flags &= ~mask;
- if (flags) {
- if (ps->buf < ps->end)
- *ps->buf = '|';
- ps->buf++;
- }
+ if (flags)
+ printf_char(ps, '|');
}
if (flags) {
for (pass = false; strspn(fmt,"fnpPFcC"); fmt++, pass = true) {
int precision;
- if (pass) {
- if (ps->buf < ps->end)
- *ps->buf = ':';
- ps->buf++;
- }
+ if (pass)
+ printf_char(ps, ':');
switch (*fmt) {
case 'f': /* full_name */
has_mult = false;
of_property_for_each_string(dn, "compatible", prop, p) {
if (has_mult)
- ps->buf = string(ps->buf, ps->end, ",", str_spec);
- ps->buf = string(ps->buf, ps->end, "\"", str_spec);
+ printf_char(ps, ',');
+ printf_char(ps, '"');
ps->buf = string(ps->buf, ps->end, p, str_spec);
- ps->buf = string(ps->buf, ps->end, "\"", str_spec);
-
+ printf_char(ps, '"');
has_mult = true;
}
break;