memcpy_safe(_q_, p, _l_); \
})
+static inline void unsetp(void *p) {
+ /* A trivial "destructor" that can be used in cases where we want to
+ * unset a pointer from a _cleanup_ function. */
+
+ *(void**)p = NULL;
+}
+
static inline void freep(void *p) {
*(void**)p = mfree(*(void**) p);
}
arg_kill_who = "all";
/* --fail was specified */
- if (streq(arg_job_mode, "fail"))
+ if (streq(arg_job_mode(), "fail"))
kill_who = strjoina(arg_kill_who, "-fail");
r = expand_unit_names(bus, strv_skip(argv, 1), NULL, &names, NULL);
char **arg_properties = NULL;
bool arg_all = false;
enum dependency arg_dependency = DEPENDENCY_FORWARD;
-const char *arg_job_mode = "replace";
+const char *_arg_job_mode = NULL;
UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
bool arg_wait = false;
bool arg_no_block = false;
STATIC_DESTRUCTOR_REGISTER(arg_types, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_states, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_properties, strv_freep);
+STATIC_DESTRUCTOR_REGISTER(_arg_job_mode, unsetp);
STATIC_DESTRUCTOR_REGISTER(arg_wall, strv_freep);
+STATIC_DESTRUCTOR_REGISTER(arg_kill_who, unsetp);
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_reboot_argument, unsetp);
+STATIC_DESTRUCTOR_REGISTER(arg_host, unsetp);
+STATIC_DESTRUCTOR_REGISTER(arg_boot_loader_entry, unsetp);
STATIC_DESTRUCTOR_REGISTER(arg_clean_what, strv_freep);
static int systemctl_help(void) {
break;
case ARG_JOB_MODE:
- arg_job_mode = optarg;
+ _arg_job_mode = optarg;
break;
case ARG_FAIL:
- arg_job_mode = "fail";
+ _arg_job_mode = "fail";
break;
case ARG_IRREVERSIBLE:
- arg_job_mode = "replace-irreversibly";
+ _arg_job_mode = "replace-irreversibly";
break;
case ARG_IGNORE_DEPENDENCIES:
- arg_job_mode = "ignore-dependencies";
+ _arg_job_mode = "ignore-dependencies";
break;
case ARG_USER:
extern char **arg_properties;
extern bool arg_all;
extern enum dependency arg_dependency;
-extern const char *arg_job_mode;
+extern const char *_arg_job_mode;
extern UnitFileScope arg_scope;
extern bool arg_wait;
extern bool arg_no_block;
extern bool arg_mkdir;
extern bool arg_marked;
+static inline const char* arg_job_mode(void) {
+ return _arg_job_mode ?: "replace";
+}
+
int systemctl_dispatch_parse_argv(int argc, char *argv[]);