From: Masatake YAMATO Date: Tue, 1 Oct 2024 20:58:34 +0000 (+0900) Subject: lsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof X-Git-Tag: v2.42-start~186^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e1f40d7c62f1be5d8206e4cc672c363d3e83e67;p=thirdparty%2Futil-linux.git lsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof Signed-off-by: Masatake YAMATO --- diff --git a/lsfd-cmd/lsfd.c b/lsfd-cmd/lsfd.c index dfd9c774e..582a56bb6 100644 --- a/lsfd-cmd/lsfd.c +++ b/lsfd-cmd/lsfd.c @@ -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; diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c index d727c7e04..9cb9f6a4f 100644 --- a/tests/helpers/test_mkfds.c +++ b/tests/helpers/test_mkfds.c @@ -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); }