]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof
authorMasatake YAMATO <yamato@redhat.com>
Tue, 1 Oct 2024 20:58:34 +0000 (05:58 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Thu, 3 Oct 2024 02:50:34 +0000 (11:50 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
lsfd-cmd/lsfd.c
tests/helpers/test_mkfds.c

index dfd9c774e27dada8986eebf2794c1621fc570d28..582a56bb69fa40837d9fb979740feb0e0947a6b0 100644 (file)
@@ -1731,7 +1731,7 @@ unsigned long add_name(struct name_manager *nm, const char *name)
        if (e)
                return e->id;
 
-       e = xmalloc(sizeof(struct identry));
+       e = xmalloc(sizeof(*e));
        e->name = xstrdup(name);
        e->id = nm->next_id++;
        e->next = nm->cache->ent;
@@ -2268,7 +2268,7 @@ static struct counter_spec *new_counter_spec(const char *spec_str)
                     _("don't use `{' in the name of a counter: %s"),
                     spec_str);
 
-       spec = xmalloc(sizeof(struct counter_spec));
+       spec = xmalloc(sizeof(*spec));
        INIT_LIST_HEAD(&spec->specs);
        spec->name = spec_str;
        spec->expr = sep + 1;
index d727c7e04ef26b58f29a83ed6857e4f7ec4a66b9..9cb9f6a4f44b3360b50f551095c92875a32be071 100644 (file)
@@ -998,14 +998,14 @@ static int make_packet_socket(int socktype, const char *interface)
        if (interface == NULL)
                return sd;      /* Just making a socket */
 
-       memset(&addr, 0, sizeof(struct sockaddr_ll));
+       memset(&addr, 0, sizeof(addr));
        addr.sll_family = AF_PACKET;
        addr.sll_ifindex = if_nametoindex(interface);
        if (addr.sll_ifindex == 0) {
                err(EXIT_FAILURE,
                    "failed to get the interface index for %s", interface);
        }
-       if (bind(sd, (struct sockaddr *)&addr, sizeof(struct sockaddr_ll)) < 0) {
+       if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
                err(EXIT_FAILURE,
                    "failed to get the interface index for %s", interface);
        }