summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--src/basic/hashmap.c2
-rw-r--r--src/basic/hashmap.h1
-rw-r--r--src/systemctl/systemctl.c37
-rw-r--r--src/test/test-hashmap.c43
5 files changed, 38 insertions, 49 deletions
diff --git a/Makefile.am b/Makefile.am
index 532d5eeb86..936e4edd81 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1281,14 +1281,14 @@ src/basic/cap-from-name.h: src/basic/cap-from-name.gperf
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_capability -H hash_capability_name -p -C <$< >$@
-audit_list_includes = -include linux/audit.h missing.h
+audit_list_includes = -include linux/audit.h -include missing.h
if HAVE_AUDIT
audit_list_includes += -include libaudit.h
endif
src/journal/audit_type-list.txt:
$(AM_V_at)$(MKDIR_P) $(dir $@)
- $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include linux/audit.h -include missing.h - </dev/null | grep -vE 'AUDIT_.*(FIRST|LAST)_' | $(SED) -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | sort -k2 >$@
+ $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM $(audit_list_includes) - </dev/null | grep -vE 'AUDIT_.*(FIRST|LAST)_' | $(SED) -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | sort -k2 >$@
src/journal/audit_type-to-name.h: src/journal/audit_type-list.txt
$(AM_V_at)$(MKDIR_P) $(dir $@)
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index 0ee2f3bd31..e5f05f36f8 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -1798,8 +1798,6 @@ void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
struct ordered_hashmap_entry *e;
unsigned hash, idx;
- assert(key);
-
if (!h)
return NULL;
diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h
index 5723f09ca9..2af23024de 100644
--- a/src/basic/hashmap.h
+++ b/src/basic/hashmap.h
@@ -65,7 +65,6 @@ typedef struct {
} Iterator;
#define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
-#define _IDX_ITERATOR_NIL (UINT_MAX)
#define ITERATOR_FIRST ((Iterator) { .idx = _IDX_ITERATOR_FIRST, .next_key = NULL })
typedef unsigned long (*hash_func_t)(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 23fc946fbf..538838b7fc 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5855,23 +5855,15 @@ static int run_editor(char **paths) {
if (pid == 0) {
const char **args;
- char *editor;
+ char *editor, **editor_args = NULL;
char **tmp_path, **original_path, *p;
- unsigned i = 1;
+ unsigned n_editor_args = 0, i = 1;
size_t argc;
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
argc = strv_length(paths)/2 + 1;
- args = newa(const char*, argc + 1);
-
- args[0] = NULL;
- STRV_FOREACH_PAIR(original_path, tmp_path, paths) {
- args[i] = *tmp_path;
- i++;
- }
- args[argc] = NULL;
/* SYSTEMD_EDITOR takes precedence over EDITOR which takes precedence over VISUAL
* If neither SYSTEMD_EDITOR nor EDITOR nor VISUAL are present,
@@ -5884,9 +5876,30 @@ static int run_editor(char **paths) {
editor = getenv("VISUAL");
if (!isempty(editor)) {
- args[0] = editor;
- execvp(editor, (char* const*) args);
+ editor_args = strv_split(editor, WHITESPACE);
+ if (!editor_args) {
+ (void) log_oom();
+ _exit(EXIT_FAILURE);
+ }
+ n_editor_args = strv_length(editor_args);
+ argc += n_editor_args - 1;
}
+ args = newa(const char*, argc + 1);
+
+ if (n_editor_args > 0) {
+ args[0] = editor_args[0];
+ for (; i < n_editor_args; i++)
+ args[i] = editor_args[i];
+ }
+
+ STRV_FOREACH_PAIR(original_path, tmp_path, paths) {
+ args[i] = *tmp_path;
+ i++;
+ }
+ args[i] = NULL;
+
+ if (n_editor_args > 0)
+ execvp(args[0], (char* const*) args);
FOREACH_STRING(p, "editor", "nano", "vim", "vi") {
args[0] = p;
diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c
index 767cbd90e9..d0e65001f5 100644
--- a/src/test/test-hashmap.c
+++ b/src/test/test-hashmap.c
@@ -24,38 +24,17 @@ void test_hashmap_funcs(void);
void test_ordered_hashmap_funcs(void);
static void test_ordered_hashmap_next(void) {
- OrderedHashmap *m;
- char *val1, *val2, *val3, *val4, *r;
-
- m = ordered_hashmap_new(&string_hash_ops);
- val1 = strdup("val1");
- assert_se(val1);
- val2 = strdup("val2");
- assert_se(val2);
- val3 = strdup("val3");
- assert_se(val3);
- val4 = strdup("val4");
- assert_se(val4);
-
- ordered_hashmap_put(m, "key 1", val1);
- ordered_hashmap_put(m, "key 2", val2);
- ordered_hashmap_put(m, "key 3", val3);
- ordered_hashmap_put(m, "key 4", val4);
-
- r = ordered_hashmap_next(m, "key 1");
- assert_se(streq(r, val2));
- r = ordered_hashmap_next(m, "key 2");
- assert_se(streq(r, val3));
- r = ordered_hashmap_next(m, "key 3");
- assert_se(streq(r, val4));
- r = ordered_hashmap_next(m, "key 4");
- assert_se(!r);
- r = ordered_hashmap_next(NULL, "key 1");
- assert_se(!r);
- r = ordered_hashmap_next(m, "key 5");
- assert_se(!r);
-
- ordered_hashmap_free_free(m);
+ _cleanup_ordered_hashmap_free_ OrderedHashmap *m = NULL;
+ int i;
+
+ assert_se(m = ordered_hashmap_new(NULL));
+ for (i = -2; i <= 2; i++)
+ assert_se(ordered_hashmap_put(m, INT_TO_PTR(i), INT_TO_PTR(i+10)) == 1);
+ for (i = -2; i <= 1; i++)
+ assert_se(ordered_hashmap_next(m, INT_TO_PTR(i)) == INT_TO_PTR(i+11));
+ assert_se(!ordered_hashmap_next(m, INT_TO_PTR(2)));
+ assert_se(!ordered_hashmap_next(NULL, INT_TO_PTR(1)));
+ assert_se(!ordered_hashmap_next(m, INT_TO_PTR(3)));
}
static void test_uint64_compare_func(void) {