]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: rename req_opts_len -> n_req_opts
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Apr 2022 16:11:32 +0000 (01:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 3 Apr 2022 10:23:03 +0000 (19:23 +0900)
As 'len' is confusing and we may misunderstand it as the size of
the buffer instead of the number of options.

src/libsystemd-network/dhcp6-internal.h
src/libsystemd-network/sd-dhcp6-client.c

index 0d7813f613b05b05af050548aa574fb79bd58d08..176391ebecdd0926522828d958cd87073da3e68b 100644 (file)
@@ -64,7 +64,7 @@ struct sd_dhcp6_client {
         struct duid duid;
         size_t duid_len;
         be16_t *req_opts;
-        size_t req_opts_len;
+        size_t n_req_opts;
         char *fqdn;
         char *mudurl;
         char **user_class;
index 27864a0a49bb31368caa9afa4a4866878ff4cae5..e3e18b58269f4d763afd269471f97d64af685be1 100644 (file)
@@ -380,14 +380,14 @@ int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client, uint16_t option)
         if (!dhcp6_option_can_request(option))
                 return -EINVAL;
 
-        for (t = 0; t < client->req_opts_len; t++)
+        for (t = 0; t < client->n_req_opts; t++)
                 if (client->req_opts[t] == htobe16(option))
                         return -EEXIST;
 
-        if (!GREEDY_REALLOC(client->req_opts, client->req_opts_len + 1))
+        if (!GREEDY_REALLOC(client->req_opts, client->n_req_opts + 1))
                 return -ENOMEM;
 
-        client->req_opts[client->req_opts_len++] = htobe16(option);
+        client->req_opts[client->n_req_opts++] = htobe16(option);
 
         return 0;
 }
@@ -713,7 +713,7 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) {
         }
 
         r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_ORO,
-                                client->req_opts_len * sizeof(be16_t),
+                                client->n_req_opts * sizeof(be16_t),
                                 client->req_opts);
         if (r < 0)
                 return r;
@@ -1414,7 +1414,6 @@ DEFINE_TRIVIAL_REF_UNREF_FUNC(sd_dhcp6_client, sd_dhcp6_client, dhcp6_client_fre
 int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
         _cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
         _cleanup_free_ be16_t *req_opts = NULL;
-        size_t t;
 
         assert_return(ret, -EINVAL);
 
@@ -1422,7 +1421,7 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
         if (!req_opts)
                 return -ENOMEM;
 
-        for (t = 0; t < ELEMENTSOF(default_req_opts); t++)
+        for (size_t t = 0; t < ELEMENTSOF(default_req_opts); t++)
                 req_opts[t] = htobe16(default_req_opts[t]);
 
         client = new(sd_dhcp6_client, 1);
@@ -1436,7 +1435,7 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
                 .ifindex = -1,
                 .request_ia = DHCP6_REQUEST_IA_NA | DHCP6_REQUEST_IA_PD,
                 .fd = -1,
-                .req_opts_len = ELEMENTSOF(default_req_opts),
+                .n_req_opts = ELEMENTSOF(default_req_opts),
                 .req_opts = TAKE_PTR(req_opts),
         };