[PATCH xserver 1/2] modesetting: Don't reuse iterator in nested loop

Olivier Fourdan ofourdan at redhat.com
Thu Apr 5 14:11:14 UTC 2018


On Thu, Apr 5, 2018 at 3:58 PM, Daniel Stone <daniels at collabora.com> wrote:

> drmmode_crtc_set_mode has a loop nested inside another loop, where both
> of them were using 'i' as the loop iterator. Rename it to avoid an
> infinite loop.
>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> Reported-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  hw/xfree86/drivers/modesetting/drmmode_display.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c
> b/hw/xfree86/drivers/modesetting/drmmode_display.c
> index 0eacefba2..f5f9fa582 100644
> --- a/hw/xfree86/drivers/modesetting/drmmode_display.c
> +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
> @@ -778,12 +778,13 @@ drmmode_crtc_set_mode(xf86CrtcPtr crtc, Bool
> test_only)
>              drmmode_crtc_private_ptr other_drmmode_crtc =
> other_crtc->driver_private;
>              int lost_outputs = 0;
>              int remaining_outputs = 0;
> +           int j;
>
>              if (other_crtc == crtc)
>                  continue;
>
> -            for (i = 0; i < xf86_config->num_output; i++) {
> -                xf86OutputPtr output = xf86_config->output[i];
> +            for (j = 0; i < xf86_config->num_output; j++) {
>

 You mean j < xf86_config->num_output here :)


> +                xf86OutputPtr output = xf86_config->output[j];
>                  drmmode_output_private_ptr drmmode_output =
> output->driver_private;
>
>                  if (drmmode_output->current_crtc == other_crtc) {
> --
> 2.17.0
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20180405/059b5559/attachment.html>


More information about the xorg-devel mailing list