]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
edit-util: EditFileContext: avoid reserved 'stdin'
authorA. Wilcox <AWilcox@Wilcox-Tech.com>
Wed, 21 Aug 2024 13:51:08 +0000 (08:51 -0500)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 5 Sep 2024 23:29:45 +0000 (08:29 +0900)
The identifier 'stdin' is reserved in C.  It can be #defined to any
statement that evaluates to a FILE*.  We do not want that for our field,
so change to a more descriptive name.

src/network/networkctl-config-file.c
src/shared/edit-util.c
src/shared/edit-util.h
src/systemctl/systemctl-edit.c

index 1bfc185f7ccbe35327a4731b401b758683a3317f..6d60d7eb99e393b22419b2ae3fb184d918657a89 100644 (file)
@@ -402,7 +402,7 @@ int verb_edit(int argc, char *argv[], void *userdata) {
                 .marker_start = DROPIN_MARKER_START,
                 .marker_end = DROPIN_MARKER_END,
                 .remove_parent = !!arg_drop_in,
-                .stdin = arg_stdin,
+                .read_from_stdin = arg_stdin,
         };
         _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
         ReloadFlags reload = 0;
index 89ca9459e063b69fd6caec6279863ec08e8bc538..e37609c2e1ce07ab439f1e9d966d01240ef036da 100644 (file)
@@ -112,7 +112,7 @@ int edit_files_add(
 static int populate_edit_temp_file(EditFile *e, FILE *f, const char *filename) {
         assert(e);
         assert(e->context);
-        assert(!e->context->stdin);
+        assert(!e->context->read_from_stdin);
         assert(e->path);
         assert(f);
         assert(filename);
@@ -200,7 +200,7 @@ static int create_edit_temp_file(EditFile *e, const char *contents, size_t conte
         assert(e->path);
         assert(!e->comment_paths || (e->context->marker_start && e->context->marker_end));
         assert(contents || contents_size == 0);
-        assert(e->context->stdin == !!contents);
+        assert(e->context->read_from_stdin == !!contents);
 
         if (e->temp)
                 return 0;
@@ -216,7 +216,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->read_from_stdin) {
                 if (fwrite(contents, 1, contents_size, f) != contents_size)
                         return log_error_errno(SYNTHETIC_ERRNO(EIO),
                                                "Failed to write stdin data to temporary file '%s'.", temp);
@@ -331,7 +331,7 @@ static int strip_edit_temp_file(EditFile *e) {
         if (!tmp)
                 return log_oom();
 
-        with_marker = e->context->marker_start && !e->context->stdin;
+        with_marker = e->context->marker_start && !e->context->read_from_stdin;
 
         if (with_marker) {
                 /* Trim out the lines between the two markers */
@@ -457,7 +457,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->read_from_stdin) {
                 r = read_full_stream(stdin, &stdin_data, &stdin_size);
                 if (r < 0)
                         return log_error_errno(r, "Failed to read stdin: %m");
@@ -476,7 +476,7 @@ int do_edit_files_and_install(EditFileContext *context) {
         _cleanup_close_ int stdin_data_fd = -EBADF;
 
         FOREACH_ARRAY(editfile, context->files, context->n_files) {
-                if (context->stdin) {
+                if (context->read_from_stdin) {
                         r = edit_file_install_one_stdin(editfile, stdin_data, stdin_size, &stdin_data_fd);
                         if (r == 0) {
                                 log_notice("Stripped stdin content is empty, not writing file.");
index 9d9c890f2a97ef590d26788c0b1b6814c59e5371..2affa7eab16838f7eff597aa716a00b50d17f22e 100644 (file)
@@ -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 read_from_stdin;       /* Read contents from stdin instead of launching an editor. */
 } EditFileContext;
 
 void edit_file_context_done(EditFileContext *context);
index 880bd4d742e39d660166c28eb66f32a31725c66c..c42a31153dc65422592a54a1c22eff421a62c4f6 100644 (file)
@@ -317,7 +317,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,
+                .read_from_stdin = arg_stdin,
         };
         _cleanup_strv_free_ char **names = NULL;
         sd_bus *bus;