]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: rename etc_hosts_free() -> etc_hosts_clear()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Dec 2022 13:30:45 +0000 (22:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Dec 2022 11:26:55 +0000 (20:26 +0900)
src/resolve/fuzz-etc-hosts.c
src/resolve/resolved-etc-hosts.c
src/resolve/resolved-etc-hosts.h
src/resolve/test-resolved-etc-hosts.c

index 050c85dab4cd506bb2116ca4bc572cbf5648636d..bd6d0a8d5d22c807be27f187a8e1c120834e35af 100644 (file)
@@ -6,7 +6,7 @@
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         _cleanup_fclose_ FILE *f = NULL;
-        _cleanup_(etc_hosts_free) EtcHosts h = {};
+        _cleanup_(etc_hosts_clear) EtcHosts h = {};
 
         if (!getenv("SYSTEMD_LOG_LEVEL"))
                 log_set_max_level(LOG_CRIT);
index 8a58db4a21a1f630032f5f5696bd096572e943ad..5dff0d96ba7f1920483869a3543a3969627299c3 100644 (file)
@@ -29,14 +29,16 @@ static void etc_hosts_item_by_name_free(EtcHostsItemByName *item) {
         free(item);
 }
 
-void etc_hosts_free(EtcHosts *hosts) {
+void etc_hosts_clear(EtcHosts *hosts) {
+        assert(hosts);
+
         hosts->by_address = hashmap_free_with_destructor(hosts->by_address, etc_hosts_item_free);
         hosts->by_name = hashmap_free_with_destructor(hosts->by_name, etc_hosts_item_by_name_free);
         hosts->no_address = set_free_free(hosts->no_address);
 }
 
 void manager_etc_hosts_flush(Manager *m) {
-        etc_hosts_free(&m->etc_hosts);
+        etc_hosts_clear(&m->etc_hosts);
         m->etc_hosts_stat = (struct stat) {};
 }
 
@@ -251,7 +253,7 @@ static void strip_localhost(EtcHosts *hosts) {
 }
 
 int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
-        _cleanup_(etc_hosts_free) EtcHosts t = {};
+        _cleanup_(etc_hosts_clear) EtcHosts t = {};
         unsigned nr = 0;
         int r;
 
@@ -282,7 +284,7 @@ int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
 
         strip_localhost(&t);
 
-        etc_hosts_free(hosts);
+        etc_hosts_clear(hosts);
         *hosts = t;
         t = (EtcHosts) {}; /* prevent cleanup */
         return 0;
index df66e714da5e5a773e772cc5cf549038fc9461b8..44eaf2b347b69d84872f94804bfbaca265975ab6 100644 (file)
@@ -20,7 +20,7 @@ typedef struct EtcHostsItemByName {
 } EtcHostsItemByName;
 
 int etc_hosts_parse(EtcHosts *hosts, FILE *f);
-void etc_hosts_free(EtcHosts *hosts);
+void etc_hosts_clear(EtcHosts *hosts);
 
 void manager_etc_hosts_flush(Manager *m);
 int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer);
index d6cd184b5e2d8ed4fec6d757745fae8112964a79..a0f712cbb64cb91bf70f7ec22beeab0ecead521d 100644 (file)
@@ -23,7 +23,7 @@ TEST(parse_etc_hosts_system) {
                 return;
         }
 
-        _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+        _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
         assert_se(etc_hosts_parse(&hosts, f) == 0);
 }
 
@@ -67,7 +67,7 @@ TEST(parse_etc_hosts) {
         assert_se(fflush_and_check(f) >= 0);
         rewind(f);
 
-        _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+        _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
         assert_se(etc_hosts_parse(&hosts, f) == 0);
 
         EtcHostsItemByName *bn;
@@ -124,7 +124,7 @@ TEST(parse_etc_hosts) {
 }
 
 static void test_parse_file_one(const char *fname) {
-        _cleanup_(etc_hosts_free) EtcHosts hosts = {};
+        _cleanup_(etc_hosts_clear) EtcHosts hosts = {};
         _cleanup_fclose_ FILE *f;
 
         log_info("/* %s(\"%s\") */", __func__, fname);