lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_MbocNRzAP6-2gR+CNofo-eFFM7GGsUFGUjQzKz7Q8qDg@mail.gmail.com>
Date: Fri, 26 Jul 2024 10:04:35 -0400
From: Alex Deucher <alexdeucher@...il.com>
To: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc: harry.wentland@....com, sunpeng.li@....com, Rodrigo.Siqueira@....com, 
	alexander.deucher@....com, christian.koenig@....com, Xinhui.Pan@....com, 
	airlied@...il.com, daniel@...ll.ch, amd-gfx@...ts.freedesktop.org, 
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, 
	Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH -next] drm/amd/display: Use ARRAY_SIZE for array length

Applied.  Thanks!

On Fri, Jul 26, 2024 at 5:55 AM Jiapeng Chong
<jiapeng.chong@...ux.alibaba.com> wrote:
>
> Use of macro ARRAY_SIZE to calculate array size minimizes
> the redundant code and improves code reusability.
>
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1552:57-58: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1561:57-58: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1573:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1578:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1592:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1597:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1611:50-51: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1616:50-51: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1630:50-51: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1635:50-51: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1649:60-61: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1663:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1677:52-53: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1691:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1705:53-54: WARNING: Use ARRAY_SIZE.
> ./drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c:1719:54-55: WARNING: Use ARRAY_SIZE.
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9580
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>  .../display/dc/spl/dc_spl_scl_easf_filters.c  | 63 ++++++-------------
>  1 file changed, 20 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c b/drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c
> index 09bf82f7d468..e847af94419a 100644
> --- a/drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c
> +++ b/drivers/gpu/drm/amd/display/dc/spl/dc_spl_scl_easf_filters.c
> @@ -1530,14 +1530,13 @@ static uint32_t spl_easf_get_scale_ratio_to_reg_value(struct spl_fixed31_32 rati
>         value = lookup_table_index_ptr->reg_value;
>
>         while (count < num_entries) {
> -
>                 lookup_table_index_ptr = (lookup_table_base_ptr + count);
>                 if (lookup_table_index_ptr->numer < 0)
>                         break;
>
>                 if (ratio.value < spl_fixpt_from_fraction(
> -                       lookup_table_index_ptr->numer,
> -                       lookup_table_index_ptr->denom).value) {
> +                   lookup_table_index_ptr->numer,
> +                   lookup_table_index_ptr->denom).value) {
>                         value = lookup_table_index_ptr->reg_value;
>                         break;
>                 }
> @@ -1548,21 +1547,13 @@ static uint32_t spl_easf_get_scale_ratio_to_reg_value(struct spl_fixed31_32 rati
>  }
>  uint32_t spl_get_v_bf3_mode(struct spl_fixed31_32 ratio)
>  {
> -       uint32_t value;
> -       unsigned int num_entries = sizeof(easf_v_bf3_mode_lookup) /
> -               sizeof(struct scale_ratio_to_reg_value_lookup);
> -       value = spl_easf_get_scale_ratio_to_reg_value(ratio,
> -               easf_v_bf3_mode_lookup, num_entries);
> -       return value;
> +       unsigned int num_entries = ARRAY_SIZE(easf_v_bf3_mode_lookup);
> +       return spl_easf_get_scale_ratio_to_reg_value(ratio, easf_v_bf3_mode_lookup, num_entries);
>  }
>  uint32_t spl_get_h_bf3_mode(struct spl_fixed31_32 ratio)
>  {
> -       uint32_t value;
> -       unsigned int num_entries = sizeof(easf_h_bf3_mode_lookup) /
> -               sizeof(struct scale_ratio_to_reg_value_lookup);
> -       value = spl_easf_get_scale_ratio_to_reg_value(ratio,
> -               easf_h_bf3_mode_lookup, num_entries);
> -       return value;
> +       unsigned int num_entries = ARRAY_SIZE(easf_h_bf3_mode_lookup);
> +       return spl_easf_get_scale_ratio_to_reg_value(ratio, easf_h_bf3_mode_lookup, num_entries);
>  }
>  uint32_t spl_get_reducer_gain6(int taps, struct spl_fixed31_32 ratio)
>  {
> @@ -1570,13 +1561,11 @@ uint32_t spl_get_reducer_gain6(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 4) {
> -               num_entries = sizeof(easf_reducer_gain6_4tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_reducer_gain6_4tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_reducer_gain6_4tap_lookup, num_entries);
>         } else if (taps == 6) {
> -               num_entries = sizeof(easf_reducer_gain6_6tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_reducer_gain6_6tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_reducer_gain6_6tap_lookup, num_entries);
>         } else
> @@ -1589,13 +1578,11 @@ uint32_t spl_get_reducer_gain4(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 4) {
> -               num_entries = sizeof(easf_reducer_gain4_4tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_reducer_gain4_4tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_reducer_gain4_4tap_lookup, num_entries);
>         } else if (taps == 6) {
> -               num_entries = sizeof(easf_reducer_gain4_6tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_reducer_gain4_6tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_reducer_gain4_6tap_lookup, num_entries);
>         } else
> @@ -1608,13 +1595,11 @@ uint32_t spl_get_gainRing6(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 4) {
> -               num_entries = sizeof(easf_gain_ring6_4tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_gain_ring6_4tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_gain_ring6_4tap_lookup, num_entries);
>         } else if (taps == 6) {
> -               num_entries = sizeof(easf_gain_ring6_6tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_gain_ring6_6tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_gain_ring6_6tap_lookup, num_entries);
>         } else
> @@ -1627,13 +1612,11 @@ uint32_t spl_get_gainRing4(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 4) {
> -               num_entries = sizeof(easf_gain_ring4_4tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_gain_ring4_4tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_gain_ring4_4tap_lookup, num_entries);
>         } else if (taps == 6) {
> -               num_entries = sizeof(easf_gain_ring4_6tap_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_gain_ring4_6tap_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_gain_ring4_6tap_lookup, num_entries);
>         } else
> @@ -1646,8 +1629,7 @@ uint32_t spl_get_3tap_dntilt_uptilt_offset(int taps, struct spl_fixed31_32 ratio
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_dntilt_uptilt_offset_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_dntilt_uptilt_offset_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_dntilt_uptilt_offset_lookup, num_entries);
>         } else
> @@ -1660,8 +1642,7 @@ uint32_t spl_get_3tap_uptilt_maxval(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_uptilt_maxval_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_uptilt_maxval_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_uptilt_maxval_lookup, num_entries);
>         } else
> @@ -1674,8 +1655,7 @@ uint32_t spl_get_3tap_dntilt_slope(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_dntilt_slope_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_dntilt_slope_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_dntilt_slope_lookup, num_entries);
>         } else
> @@ -1688,8 +1668,7 @@ uint32_t spl_get_3tap_uptilt1_slope(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_uptilt1_slope_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_uptilt1_slope_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_uptilt1_slope_lookup, num_entries);
>         } else
> @@ -1702,8 +1681,7 @@ uint32_t spl_get_3tap_uptilt2_slope(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_uptilt2_slope_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_uptilt2_slope_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_uptilt2_slope_lookup, num_entries);
>         } else
> @@ -1716,8 +1694,7 @@ uint32_t spl_get_3tap_uptilt2_offset(int taps, struct spl_fixed31_32 ratio)
>         unsigned int num_entries;
>
>         if (taps == 3) {
> -               num_entries = sizeof(easf_3tap_uptilt2_offset_lookup) /
> -                       sizeof(struct scale_ratio_to_reg_value_lookup);
> +               num_entries = ARRAY_SIZE(easf_3tap_uptilt2_offset_lookup);
>                 value = spl_easf_get_scale_ratio_to_reg_value(ratio,
>                         easf_3tap_uptilt2_offset_lookup, num_entries);
>         } else
> --
> 2.32.0.3.g01195cf9f
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ