From: Michal Hocko <mhocko@suse.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
cgroups@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/2][next] mm: memcontrol: Use the preferred form for passing the size of a structure type
Date: Tue, 4 Aug 2020 15:25:47 +0200 [thread overview]
Message-ID: <20200804132547.GD7306@dhcp22.suse.cz> (raw)
In-Reply-To: <773e013ff2f07fe2a0b47153f14dea054c0c04f1.1596214831.git.gustavoars@kernel.org>
On Fri 31-07-20 12:13:14, Gustavo A. R. Silva wrote:
> Use the preferred form for passing the size of a structure type. The
> alternative form where the structure type is spelled out hurts
> readability and introduces an opportunity for a bug when the object
> type is changed but the corresponding object identifier to which the
> sizeof operator is applied is not.
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index bd7f972ceea4..bd0f56785841 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4255,7 +4255,7 @@ static int __mem_cgroup_usage_register_event(struct mem_cgroup *memcg,
> new->entries[size - 1].threshold = threshold;
>
> /* Sort thresholds. Registering of new threshold isn't time-critical */
> - sort(new->entries, size, sizeof(struct mem_cgroup_threshold),
> + sort(new->entries, size, sizeof(*new->entries),
> compare_thresholds, NULL);
>
> /* Find current threshold */
> --
> 2.27.0
--
Michal Hocko
SUSE Labs
prev parent reply other threads:[~2020-08-04 13:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 17:12 [PATCH 0/2][next] Use flexible_array_size() helper in memcpy() Gustavo A. R. Silva
2020-07-31 17:12 ` [PATCH 1/2][next] mm: memcontrol: Use flex_array_size() " Gustavo A. R. Silva
2020-08-04 13:25 ` Michal Hocko
2020-07-31 17:13 ` [PATCH 2/2][next] mm: memcontrol: Use the preferred form for passing the size of a structure type Gustavo A. R. Silva
2020-08-04 13:25 ` Michal Hocko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200804132547.GD7306@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=gustavoars@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox