gentoo-overlay/sys-apps/systemd/files/0029-edit-util-Don-t-clobbe...

88 lines
3.7 KiB
Diff

From 8b6e1c92f19163707789698860070738c607c2e8 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 18 Aug 2024 03:17:18 -0500
Subject: [PATCH 29/34] edit-util: Don't clobber reserved identifier stdin
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
It may be #define'd instead of a global variable, which breaks using it
as an identifier for ourselves.
Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
src/shared/edit-util.c | 8 ++++----
src/shared/edit-util.h | 2 +-
src/systemctl/systemctl-edit.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/shared/edit-util.c b/src/shared/edit-util.c
index b0496032f7b8..412aeb219607 100644
--- a/src/shared/edit-util.c
+++ b/src/shared/edit-util.c
@@ -212,7 +212,7 @@ static int create_edit_temp_file(EditFile *e, const char *contents, size_t conte
if (fchmod(fileno(f), 0644) < 0)
return log_error_errno(errno, "Failed to change mode of temporary file '%s': %m", temp);
- if (e->context->stdin) {
+ if (e->context->_stdin) {
if (fwrite(contents, 1, contents_size, f) != contents_size)
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Failed to copy input to temporary file '%s'.", temp);
@@ -326,7 +326,7 @@ static int strip_edit_temp_file(EditFile *e) {
if (!tmp)
return log_oom();
- if (e->context->marker_start && !e->context->stdin) {
+ if (e->context->marker_start && !e->context->_stdin) {
/* Trim out the lines between the two markers */
char *contents_start, *contents_end;
@@ -374,7 +374,7 @@ int do_edit_files_and_install(EditFileContext *context) {
if (context->n_files == 0)
return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), "Got no files to edit.");
- if (context->stdin) {
+ if (context->_stdin) {
r = read_full_stream(stdin, &data, &data_size);
if (r < 0)
return log_error_errno(r, "Failed to read stdin: %m");
@@ -386,7 +386,7 @@ int do_edit_files_and_install(EditFileContext *context) {
return r;
}
- if (!context->stdin) {
+ if (!context->_stdin) {
r = run_editor(context);
if (r < 0)
return r;
diff --git a/src/shared/edit-util.h b/src/shared/edit-util.h
index 9d9c890f2a97..70b9bff2dd98 100644
--- a/src/shared/edit-util.h
+++ b/src/shared/edit-util.h
@@ -15,7 +15,7 @@ typedef struct EditFileContext {
const char *marker_end;
bool remove_parent;
bool overwrite_with_origin; /* Always overwrite target with original file. */
- bool stdin; /* Read contents from stdin instead of launching an editor. */
+ bool _stdin; /* Read contents from stdin instead of launching an editor. */
} EditFileContext;
void edit_file_context_done(EditFileContext *context);
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
index 15398f83646e..ae08d65b0f12 100644
--- a/src/systemctl/systemctl-edit.c
+++ b/src/systemctl/systemctl-edit.c
@@ -316,7 +316,7 @@ int verb_edit(int argc, char *argv[], void *userdata) {
.marker_end = DROPIN_MARKER_END,
.remove_parent = !arg_full,
.overwrite_with_origin = true,
- .stdin = arg_stdin,
+ ._stdin = arg_stdin,
};
_cleanup_strv_free_ char **names = NULL;
sd_bus *bus;
--
2.41.0