diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-07-21 10:35:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-21 10:35:45 +0200 |
commit | 4b61c8751135c58be043d86b9fef4c8ec7aadf18 (patch) | |
tree | 5a0686acb073a0b21620501c7fcf273b0791883c /src/libsystemd | |
parent | Merge pull request #6413 from poettering/getpid (diff) | |
download | systemd-4b61c8751135c58be043d86b9fef4c8ec7aadf18.tar.xz systemd-4b61c8751135c58be043d86b9fef4c8ec7aadf18.zip |
tree-wide: fput[cs]() → fput[cs]_unlocked() wherever that makes sense (#6396)
As a follow-up for db3f45e2d2586d78f942a43e661415bc50716d11 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.
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/bus-introspect.c | 38 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-match.c | 14 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-objects.c | 4 |
3 files changed, 28 insertions, 28 deletions
diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c index 8f93edb8da..5dab4a9af3 100644 --- a/src/libsystemd/sd-bus/bus-introspect.c +++ b/src/libsystemd/sd-bus/bus-introspect.c @@ -36,8 +36,8 @@ int introspect_begin(struct introspect *i, bool trusted) { if (!i->f) return -ENOMEM; - fputs(BUS_INTROSPECT_DOCTYPE - "<node>\n", i->f); + fputs_unlocked(BUS_INTROSPECT_DOCTYPE + "<node>\n", i->f); return 0; } @@ -45,12 +45,12 @@ int introspect_begin(struct introspect *i, bool trusted) { int introspect_write_default_interfaces(struct introspect *i, bool object_manager) { assert(i); - fputs(BUS_INTROSPECT_INTERFACE_PEER - BUS_INTROSPECT_INTERFACE_INTROSPECTABLE - BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f); + fputs_unlocked(BUS_INTROSPECT_INTERFACE_PEER + BUS_INTROSPECT_INTERFACE_INTROSPECTABLE + BUS_INTROSPECT_INTERFACE_PROPERTIES, i->f); if (object_manager) - fputs(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f); + fputs_unlocked(BUS_INTROSPECT_INTERFACE_OBJECT_MANAGER, i->f); return 0; } @@ -76,27 +76,27 @@ int introspect_write_child_nodes(struct introspect *i, Set *s, const char *prefi static void introspect_write_flags(struct introspect *i, int type, int flags) { if (flags & SD_BUS_VTABLE_DEPRECATED) - fputs(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f); if (type == _SD_BUS_VTABLE_METHOD && (flags & SD_BUS_VTABLE_METHOD_NO_REPLY)) - fputs(" <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n", i->f); if (type == _SD_BUS_VTABLE_PROPERTY || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) { if (flags & SD_BUS_VTABLE_PROPERTY_EXPLICIT) - fputs(" <annotation name=\"org.freedesktop.systemd1.Explicit\" value=\"true\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.systemd1.Explicit\" value=\"true\"/>\n", i->f); if (flags & SD_BUS_VTABLE_PROPERTY_CONST) - fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"const\"/>\n", i->f); else if (flags & SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION) - fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"invalidates\"/>\n", i->f); else if (!(flags & SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE)) - fputs(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Property.EmitsChangedSignal\" value=\"false\"/>\n", i->f); } if (!i->trusted && (type == _SD_BUS_VTABLE_METHOD || type == _SD_BUS_VTABLE_WRITABLE_PROPERTY) && !(flags & SD_BUS_VTABLE_UNPRIVILEGED)) - fputs(" <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.systemd1.Privileged\" value=\"true\"/>\n", i->f); } static int introspect_write_arguments(struct introspect *i, const char *signature, const char *direction) { @@ -117,7 +117,7 @@ static int introspect_write_arguments(struct introspect *i, const char *signatur if (direction) fprintf(i->f, " direction=\"%s\"/>\n", direction); else - fputs("/>\n", i->f); + fputs_unlocked("/>\n", i->f); signature += l; } @@ -140,7 +140,7 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) { case _SD_BUS_VTABLE_START: if (v->flags & SD_BUS_VTABLE_DEPRECATED) - fputs(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f); + fputs_unlocked(" <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n", i->f); break; case _SD_BUS_VTABLE_METHOD: @@ -148,7 +148,7 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) { introspect_write_arguments(i, strempty(v->x.method.signature), "in"); introspect_write_arguments(i, strempty(v->x.method.result), "out"); introspect_write_flags(i, v->type, v->flags); - fputs(" </method>\n", i->f); + fputs_unlocked(" </method>\n", i->f); break; case _SD_BUS_VTABLE_PROPERTY: @@ -158,14 +158,14 @@ int introspect_write_interface(struct introspect *i, const sd_bus_vtable *v) { v->x.property.signature, v->type == _SD_BUS_VTABLE_WRITABLE_PROPERTY ? "readwrite" : "read"); introspect_write_flags(i, v->type, v->flags); - fputs(" </property>\n", i->f); + fputs_unlocked(" </property>\n", i->f); break; case _SD_BUS_VTABLE_SIGNAL: fprintf(i->f, " <signal name=\"%s\">\n", v->x.signal.member); introspect_write_arguments(i, strempty(v->x.signal.signature), NULL); introspect_write_flags(i, v->type, v->flags); - fputs(" </signal>\n", i->f); + fputs_unlocked(" </signal>\n", i->f); break; } @@ -182,7 +182,7 @@ int introspect_finish(struct introspect *i, sd_bus *bus, sd_bus_message *m, sd_b assert(m); assert(reply); - fputs("</node>\n", i->f); + fputs_unlocked("</node>\n", i->f); r = fflush_and_check(i->f); if (r < 0) diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c index db01f21135..02587a3e8d 100644 --- a/src/libsystemd/sd-bus/bus-match.c +++ b/src/libsystemd/sd-bus/bus-match.c @@ -957,18 +957,18 @@ char *bus_match_to_string(struct bus_match_component *components, unsigned n_com char buf[32]; if (i != 0) - fputc(',', f); + fputc_unlocked(',', f); - fputs(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f); - fputc('=', f); - fputc('\'', f); + fputs_unlocked(bus_match_node_type_to_string(components[i].type, buf, sizeof(buf)), f); + fputc_unlocked('=', f); + fputc_unlocked('\'', f); if (components[i].type == BUS_MATCH_MESSAGE_TYPE) - fputs(bus_message_type_to_string(components[i].value_u8), f); + fputs_unlocked(bus_message_type_to_string(components[i].value_u8), f); else - fputs(components[i].value_str, f); + fputs_unlocked(components[i].value_str, f); - fputc('\'', f); + fputc_unlocked('\'', f); } r = fflush_and_check(f); diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 98911d5203..bb06d302ca 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -955,7 +955,7 @@ static int process_introspect( if (!streq_ptr(previous_interface, c->interface)) { if (previous_interface) - fputs(" </interface>\n", intro.f); + fputs_unlocked(" </interface>\n", intro.f); fprintf(intro.f, " <interface name=\"%s\">\n", c->interface); } @@ -968,7 +968,7 @@ static int process_introspect( } if (previous_interface) - fputs(" </interface>\n", intro.f); + fputs_unlocked(" </interface>\n", intro.f); if (empty) { /* Nothing?, let's see if we exist at all, and if not |