tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)

As a follow-up for db3f45e2d2 let's do the
same for all other cases where we create a FILE* with local scope and
know that no other threads hence can have access to it.

For most cases this shouldn't change much really, but this should speed
dbus introspection and calender time formatting up a bit.
This commit is contained in:
Lennart Poettering
2017-07-21 10:35:45 +02:00
committed by GitHub
parent 52b1478414
commit 4b61c87511
23 changed files with 185 additions and 185 deletions
+18 -18
View File
@@ -257,19 +257,19 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
if (l < 0) {
if (need_comma)
fputc(',', f);
fputc_unlocked(',', f);
else
need_comma = true;
fputs(days[x], f);
fputs_unlocked(days[x], f);
l = x;
}
} else if (l >= 0) {
if (x > l + 1) {
fputs(x > l + 2 ? ".." : ",", f);
fputs(days[x-1], f);
fputs_unlocked(x > l + 2 ? ".." : ",", f);
fputs_unlocked(days[x-1], f);
}
l = -1;
@@ -277,8 +277,8 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
}
if (l >= 0 && x > l + 1) {
fputs(x > l + 2 ? ".." : ",", f);
fputs(days[x-1], f);
fputs_unlocked(x > l + 2 ? ".." : ",", f);
fputs_unlocked(days[x-1], f);
}
}
@@ -288,12 +288,12 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us
assert(f);
if (!c) {
fputc('*', f);
fputc_unlocked('*', f);
return;
}
if (usec && c->start == 0 && c->repeat == USEC_PER_SEC && !c->next) {
fputc('*', f);
fputc_unlocked('*', f);
return;
}
@@ -314,7 +314,7 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us
fprintf(f, ".%06i", c->repeat % d);
if (c->next) {
fputc(',', f);
fputc_unlocked(',', f);
format_chain(f, space, c->next, usec);
}
}
@@ -334,23 +334,23 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
format_weekdays(f, c);
fputc(' ', f);
fputc_unlocked(' ', f);
}
format_chain(f, 4, c->year, false);
fputc('-', f);
fputc_unlocked('-', f);
format_chain(f, 2, c->month, false);
fputc(c->end_of_month ? '~' : '-', f);
fputc_unlocked(c->end_of_month ? '~' : '-', f);
format_chain(f, 2, c->day, false);
fputc(' ', f);
fputc_unlocked(' ', f);
format_chain(f, 2, c->hour, false);
fputc(':', f);
fputc_unlocked(':', f);
format_chain(f, 2, c->minute, false);
fputc(':', f);
fputc_unlocked(':', f);
format_chain(f, 2, c->microsecond, true);
if (c->utc)
fputs(" UTC", f);
fputs_unlocked(" UTC", f);
else if (IN_SET(c->dst, 0, 1)) {
/* If daylight saving is explicitly on or off, let's show the used timezone. */
@@ -358,8 +358,8 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
tzset();
if (!isempty(tzname[c->dst])) {
fputc(' ', f);
fputs(tzname[c->dst], f);
fputc_unlocked(' ', f);
fputs_unlocked(tzname[c->dst], f);
}
}
+9 -9
View File
@@ -824,29 +824,29 @@ static void write_env_var(FILE *f, const char *v) {
p = strchr(v, '=');
if (!p) {
/* Fallback */
fputs(v, f);
fputc('\n', f);
fputs_unlocked(v, f);
fputc_unlocked('\n', f);
return;
}
p++;
fwrite(v, 1, p-v, f);
fwrite_unlocked(v, 1, p-v, f);
if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE SHELL_NEED_QUOTES)) {
fputc('\"', f);
fputc_unlocked('\"', f);
for (; *p; p++) {
if (strchr(SHELL_NEED_ESCAPE, *p))
fputc('\\', f);
fputc_unlocked('\\', f);
fputc(*p, f);
fputc_unlocked(*p, f);
}
fputc('\"', f);
fputc_unlocked('\"', f);
} else
fputs(p, f);
fputs_unlocked(p, f);
fputc('\n', f);
fputc_unlocked('\n', f);
}
int write_env_file(const char *fname, char **l) {