+ return r;
}
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
+@@
+expression f, buf, sz;
+@@
+- f = open_memstream(&buf, &sz);
++ f = open_memstream_unlocked(&buf, &sz);
+ if (!f)
+ return ...;
+- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
return 0;
}
+FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc) {
+ FILE *f = open_memstream(ptr, sizeloc);
+ if (!f)
+ return NULL;
+
+ (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
+
+ return f;
+}
+
int write_string_stream_ts(
FILE *f,
const char *line,
int fopen_unlocked(const char *path, const char *options, FILE **ret);
int fdopen_unlocked(int fd, const char *options, FILE **ret);
+FILE* open_memstream_unlocked(char **ptr, size_t *sizeloc);
int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts);
static inline int write_string_stream(FILE *f, const char *line, WriteStringFileFlags flags) {
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
* 2. Strips ANSI color sequences (a subset of CSI), i.e. ESC '[' … 'm' sequences
* 3. Strips ANSI operating system sequences (CSO), i.e. ESC ']' … BEL sequences
*
- * Everything else will be left as it is. In particular other ANSI sequences are left as they are, as are any
- * other special characters. Truncated ANSI sequences are left-as is too. This call is supposed to suppress the
- * most basic formatting noise, but nothing else.
+ * Everything else will be left as it is. In particular other ANSI sequences are left as they are, as
+ * are any other special characters. Truncated ANSI sequences are left-as is too. This call is
+ * supposed to suppress the most basic formatting noise, but nothing else.
*
* Why care for CSO sequences? Well, to undo what terminal_urlify() and friends generate. */
isz = _isz ? *_isz : strlen(*ibuf);
- f = open_memstream(&obuf, &osz);
+ /* Note we turn off internal locking on f for performance reasons. It's safe to do so since we
+ * created f here and it doesn't leave our scope. */
+ f = open_memstream_unlocked(&obuf, &osz);
if (!f)
return NULL;
- /* Note we turn off internal locking on f for performance reasons. It's safe to do so since we created f here
- * and it doesn't leave our scope. */
-
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
for (i = *ibuf; i < *ibuf + isz + 1; i++) {
switch (state) {
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <stdio.h>
-#include <stdio_ext.h>
#include <sys/mman.h>
#include "alloc-util.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <getopt.h>
-#include <stdio_ext.h>
#include "sd-bus.h"
if (r < 0)
return bus_log_parse_error(r);
- mf = open_memstream(&buf, &sz);
+ mf = open_memstream_unlocked(&buf, &sz);
if (!mf)
return log_oom();
- (void) __fsetlocking(mf, FSETLOCKING_BYCALLER);
-
r = format_cmdline(reply, mf, false);
if (r < 0)
return bus_log_parse_error(r);
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <arpa/inet.h>
-#include <stdio_ext.h>
#include "af-list.h"
#include "alloc-util.h"
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fprintf(f, "%s=\n", name);
LIST_FOREACH(device_limits, a, c->io_device_limits)
if (a->limits[iol_type] != cgroup_io_limit_defaults[iol_type])
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("IODeviceWeight=\n", f);
LIST_FOREACH(device_weights, a, c->io_device_weights)
fprintf(f, "IODeviceWeight=%s %" PRIu64 "\n", a->path, a->weight);
unit_invalidate_cgroup(u, CGROUP_MASK_IO);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("IODeviceLatencyTargetSec=\n", f);
LIST_FOREACH(device_latencies, a, c->io_device_latencies)
fprintf(f, "IODeviceLatencyTargetSec=%s %s\n",
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
if (read) {
fputs("BlockIOReadBandwidth=\n", f);
LIST_FOREACH(device_bandwidths, a, c->blockio_device_bandwidths)
unit_invalidate_cgroup(u, CGROUP_MASK_BLKIO);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("BlockIODeviceWeight=\n", f);
LIST_FOREACH(device_weights, a, c->blockio_device_weights)
fprintf(f, "BlockIODeviceWeight=%s %" PRIu64 "\n", a->path, a->weight);
unit_invalidate_cgroup(u, CGROUP_MASK_DEVICES);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("DeviceAllow=\n", f);
LIST_FOREACH(device_allow, a, c->device_allow)
fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
*list = ip_address_access_free_all(*list);
unit_invalidate_cgroup_bpf(u);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs(name, f);
fputs("=\n", f);
#include <sys/mount.h>
#include <sys/prctl.h>
-#include <stdio_ext.h>
#if HAVE_SECCOMP
#include <seccomp.h>
if (n == 0)
*exec_command = exec_command_free_list(*exec_command);
- f = open_memstream(&buf, &size);
+ f = open_memstream_unlocked(&buf, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("ExecStart=\n", f);
LIST_FOREACH(command, c, *exec_command) {
if (r < 0)
return r;
- f = open_memstream(&joined, &size);
+ f = open_memstream_unlocked(&joined, &size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("EnvironmentFile=\n", f);
STRV_FOREACH(i, c->environment_files) {
#include <fcntl.h>
#include <linux/kd.h>
#include <signal.h>
-#include <stdio_ext.h>
#include <string.h>
#include <sys/epoll.h>
#include <sys/inotify.h>
assert(m);
assert(ret);
- f = open_memstream(&dump, &size);
+ f = open_memstream_unlocked(&dump, &size);
if (!f)
return -errno;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
manager_dump(m, f, NULL);
r = fflush_and_check(f);
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <sys/prctl.h>
#include <sys/xattr.h>
#include <unistd.h>
if (proc_fdinfo_fd < 0)
return -errno;
- stream = open_memstream(&buffer, &size);
+ stream = open_memstream_unlocked(&buffer, &size);
if (!stream)
return -ENOMEM;
- (void) __fsetlocking(stream, FSETLOCKING_BYCALLER);
-
FOREACH_DIRENT(dent, proc_fd_dir, return -errno) {
_cleanup_fclose_ FILE *fdinfo = NULL;
_cleanup_free_ char *fdname = NULL;
#include <dwarf.h>
#include <elfutils/libdwfl.h>
-#include <stdio_ext.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
+#include "fileio.h"
#include "fd-util.h"
#include "format-util.h"
#include "macro.h"
if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
return -errno;
- c.f = open_memstream(&buf, &sz);
+ c.f = open_memstream_unlocked(&buf, &sz);
if (!c.f)
return -ENOMEM;
- (void) __fsetlocking(c.f, FSETLOCKING_BYCALLER);
-
elf_version(EV_CURRENT);
c.elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
#include <qrencode.h>
#include <stdbool.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <stdlib.h>
+#include "fileio.h"
#include "journal-qrcode.h"
#include "macro.h"
assert(seed);
assert(seed_size > 0);
- f = open_memstream(&url, &url_size);
+ f = open_memstream_unlocked(&url, &url_size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
fputs("fss://", f);
for (i = 0; i < seed_size; i++) {
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio_ext.h>
-
#include "bus-internal.h"
#include "bus-introspect.h"
#include "bus-objects.h"
zero(*i);
i->trusted = trusted;
- i->f = open_memstream(&i->introspection, &i->size);
+ i->f = open_memstream_unlocked(&i->introspection, &i->size);
if (!i->f)
return -ENOMEM;
- (void) __fsetlocking(i->f, FSETLOCKING_BYCALLER);
-
fputs(BUS_INTROSPECT_DOCTYPE
"<node>\n", i->f);
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio_ext.h>
-
#include "alloc-util.h"
#include "bus-internal.h"
#include "bus-match.h"
assert(components);
- f = open_memstream(&buffer, &size);
+ f = open_memstream_unlocked(&buffer, &size);
if (!f)
return NULL;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
for (i = 0; i < n_components; i++) {
char buf[32];
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio_ext.h>
-
#include "bus-common-errors.h"
#include "bus-error.h"
#include "conf-files.h"
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <stdio_ext.h>
-
#if HAVE_GCRYPT
-#include <gcrypt.h>
+# include <gcrypt.h>
#endif
#include "alloc-util.h"
/* Bring the RRs into canonical order */
typesafe_qsort(list, n, rr_compare);
- f = open_memstream(&sig_data, &sig_size);
+ f = open_memstream_unlocked(&sig_data, &sig_size);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
fwrite_uint16(f, rrsig->rrsig.type_covered);
fwrite_uint8(f, rrsig->rrsig.algorithm);
#include <fcntl.h>
#include <netinet/in.h>
#include <poll.h>
-#include <stdio_ext.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
assert(si);
assert(m);
- f = open_memstream(&buffer, &size);
+ f = open_memstream_unlocked(&buffer, &size);
if (!f)
return log_oom();
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
LIST_FOREACH(scopes, scope, m->dns_scopes)
dns_scope_dump(scope, f);
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
assert(c);
assert(p);
- f = open_memstream(&buf, &sz);
+ f = open_memstream_unlocked(&buf, &sz);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
format_weekdays(f, c);
fputc(' ', f);
/* SPDX-License-Identifier: LGPL-2.1+ */
#include <ctype.h>
-#include <stdio_ext.h>
#include "alloc-util.h"
#include "fd-util.h"
size_t sz = 0;
int r;
- f = open_memstream(&buf, &sz);
+ f = open_memstream_unlocked(&buf, &sz);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
r = table_print(t, f);
if (r < 0)
return r;
#include <locale.h>
#include <math.h>
#include <stdarg.h>
-#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
{
_cleanup_fclose_ FILE *f = NULL;
- f = open_memstream(&s, &sz);
+ f = open_memstream_unlocked(&s, &sz);
if (!f)
return -ENOMEM;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
-
json_variant_dump(v, flags, f, NULL);
r = fflush_and_check(f);