Re: [RFC PATCH] checkpatch: check for function calls with struct or union on stack

From: Joe Perches
Date: Thu Jul 26 2018 - 16:05:35 EST


On Thu, 2018-07-26 at 12:28 -0700, Andrew Morton wrote:
> On Thu, 26 Jul 2018 12:25:33 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > I'll give it a spin, see how noisy it is.
>
> Actually, I would prefer if the message, changelog and title
> used the term "passed by value". It's a more familiar term
> and it is possible for a passed-by-value aggregate to in fact
> be passed in registers.

RFC, No worries, I'll change it if it's OK.

I'm testing it right now against the last 5000 commits
(which takes awhile here) via

$ git log --no-merges --format=oneline -5000 | \
cut -f1 -d" " | \
while read commit ; do \
echo $commit; \
./scripts/checkpatch.pl --git $commit --types=aggregate_on_stack --quiet --no-summary ; \
done

It doesn't seem noisy at all, but maybe there are a few
known structs like "struct timespec64" that could be
excluded.

The only real hits so far are:

commit f2fb56afba11426ee5c9603b28a9827c530909c0
WARNING: Unusual use of 'struct msm_display_topology' on stack
#28374: FILE: drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:149:
+enum dpu_rm_topology_name
+dpu_rm_get_topology_name(struct msm_display_topology topology)
+{

WARNING: Unusual use of 'struct msm_display_topology' on stack
#29021: FILE: drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:796:
+static int _dpu_rm_populate_requirements(
+ struct dpu_rm *rm,
+ struct drm_encoder *enc,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ struct dpu_rm_requirements *reqs,
+ struct msm_display_topology req_topology)
+{

WARNING: Unusual use of 'struct msm_display_topology' on stack
#29203: FILE: drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c:978:
+int dpu_rm_reserve(
+ struct dpu_rm *rm,
+ struct drm_encoder *enc,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ struct msm_display_topology topology,
+ bool test_only)
+{

WARNING: Unusual use of 'struct msm_display_topology' on stack
#29443: FILE: drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h:133:
+int dpu_rm_reserve(struct dpu_rm *rm,
+ struct drm_encoder *drm_enc,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ struct msm_display_topology topology,
+ bool test_only);

WARNING: Unusual use of 'struct msm_display_topology' on stack
#29506: FILE: drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h:196:
+enum dpu_rm_topology_name
+dpu_rm_get_topology_name(struct msm_display_topology topology);

and

33477d84c26bbfa626da2c032e567a90dd70a528
WARNING: Unusual use of 'struct cppc_perf_fb_ctrs' on stack
#45: FILE: drivers/cpufreq/cppc_cpufreq.c:307:
+static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu,
+ struct cppc_perf_fb_ctrs fb_ctrs_t0,
+ struct cppc_perf_fb_ctrs fb_ctrs_t1)
+{

WARNING: Unusual use of 'struct cppc_perf_fb_ctrs' on stack
#45: FILE: drivers/cpufreq/cppc_cpufreq.c:307:
+static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu,
+ struct cppc_perf_fb_ctrs fb_ctrs_t0,
+ struct cppc_perf_fb_ctrs fb_ctrs_t1)
+{