mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
edit-util: EditFileContext: avoid reserved 'stdin'
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.
This commit is contained in:
parent
cbe65d38cf
commit
79f0e94e27
@ -402,7 +402,7 @@ int verb_edit(int argc, char *argv[], void *userdata) {
|
|||||||
.marker_start = DROPIN_MARKER_START,
|
.marker_start = DROPIN_MARKER_START,
|
||||||
.marker_end = DROPIN_MARKER_END,
|
.marker_end = DROPIN_MARKER_END,
|
||||||
.remove_parent = !!arg_drop_in,
|
.remove_parent = !!arg_drop_in,
|
||||||
.stdin = arg_stdin,
|
.read_from_stdin = arg_stdin,
|
||||||
};
|
};
|
||||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||||
ReloadFlags reload = 0;
|
ReloadFlags reload = 0;
|
||||||
|
@ -112,7 +112,7 @@ int edit_files_add(
|
|||||||
static int populate_edit_temp_file(EditFile *e, FILE *f, const char *filename) {
|
static int populate_edit_temp_file(EditFile *e, FILE *f, const char *filename) {
|
||||||
assert(e);
|
assert(e);
|
||||||
assert(e->context);
|
assert(e->context);
|
||||||
assert(!e->context->stdin);
|
assert(!e->context->read_from_stdin);
|
||||||
assert(e->path);
|
assert(e->path);
|
||||||
assert(f);
|
assert(f);
|
||||||
assert(filename);
|
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->path);
|
||||||
assert(!e->comment_paths || (e->context->marker_start && e->context->marker_end));
|
assert(!e->comment_paths || (e->context->marker_start && e->context->marker_end));
|
||||||
assert(contents || contents_size == 0);
|
assert(contents || contents_size == 0);
|
||||||
assert(e->context->stdin == !!contents);
|
assert(e->context->read_from_stdin == !!contents);
|
||||||
|
|
||||||
if (e->temp)
|
if (e->temp)
|
||||||
return 0;
|
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)
|
if (fchmod(fileno(f), 0644) < 0)
|
||||||
return log_error_errno(errno, "Failed to change mode of temporary file '%s': %m", temp);
|
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)
|
if (fwrite(contents, 1, contents_size, f) != contents_size)
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
||||||
"Failed to write stdin data to temporary file '%s'.", temp);
|
"Failed to write stdin data to temporary file '%s'.", temp);
|
||||||
@ -331,7 +331,7 @@ static int strip_edit_temp_file(EditFile *e) {
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
return log_oom();
|
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) {
|
if (with_marker) {
|
||||||
/* Trim out the lines between the two markers */
|
/* 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)
|
if (context->n_files == 0)
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), "Got no files to edit.");
|
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);
|
r = read_full_stream(stdin, &stdin_data, &stdin_size);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to read stdin: %m");
|
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;
|
_cleanup_close_ int stdin_data_fd = -EBADF;
|
||||||
|
|
||||||
FOREACH_ARRAY(editfile, context->files, context->n_files) {
|
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);
|
r = edit_file_install_one_stdin(editfile, stdin_data, stdin_size, &stdin_data_fd);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
log_notice("Stripped stdin content is empty, not writing file.");
|
log_notice("Stripped stdin content is empty, not writing file.");
|
||||||
|
@ -15,7 +15,7 @@ typedef struct EditFileContext {
|
|||||||
const char *marker_end;
|
const char *marker_end;
|
||||||
bool remove_parent;
|
bool remove_parent;
|
||||||
bool overwrite_with_origin; /* Always overwrite target with original file. */
|
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;
|
} EditFileContext;
|
||||||
|
|
||||||
void edit_file_context_done(EditFileContext *context);
|
void edit_file_context_done(EditFileContext *context);
|
||||||
|
@ -317,7 +317,7 @@ int verb_edit(int argc, char *argv[], void *userdata) {
|
|||||||
.marker_end = DROPIN_MARKER_END,
|
.marker_end = DROPIN_MARKER_END,
|
||||||
.remove_parent = !arg_full,
|
.remove_parent = !arg_full,
|
||||||
.overwrite_with_origin = true,
|
.overwrite_with_origin = true,
|
||||||
.stdin = arg_stdin,
|
.read_from_stdin = arg_stdin,
|
||||||
};
|
};
|
||||||
_cleanup_strv_free_ char **names = NULL;
|
_cleanup_strv_free_ char **names = NULL;
|
||||||
sd_bus *bus;
|
sd_bus *bus;
|
||||||
|
Loading…
Reference in New Issue
Block a user