Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1800984pxj; Fri, 18 Jun 2021 16:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy24YaMTQH+9gn6OkkFSR+jIT4g7+wR1pIrTCz3m8FQNQ9Dl/+CB9E8KsgNDm8izaqokRQd X-Received: by 2002:a05:6402:1776:: with SMTP id da22mr7812857edb.133.1624058091805; Fri, 18 Jun 2021 16:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624058091; cv=none; d=google.com; s=arc-20160816; b=rRu5jvW/NyqDjiYmlMRitAUxtD259hkfFrqqVmuxdhKdpRPZcJ6NMGMWgix+MY9D6u VkKPQr90xsMOi8tuvEpwN+ojrqH4qvUiAqo4IrxHegZDgateOoePLk8Uvy7FaPpy4+YW Qf2gqy9O1E9jyZXM7yXPutY8SGJqp8+9uI8cxifzRbUYzYCCLNkyh/VEvShNGxQ81+ik svB3Doanvgn+QWWj4tVXsp2JHhNxTKZgWJNn99o3YO+lL7JyuVkR5g9bn175HLnJl2IG xr+FbggyOtt/nw2nKRZsNEtXmxmBgEne95VpncJ7+/JXWSiXCSA3UVLWcmbq7NFNgfDa Iyew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=7urAYt51sXBH3eqU148HY3WTp6INsjJIsWapEke7IcA=; b=ffAUJUuD4RRS7UyluFLOwKlG4R7JG84Vq04GJSqKNij7iukAUyyKEfongjIc6gLErJ IDa34DdfrGEJoAD+jpShn0gm4YrGkNd1fEugec14WA9eWXOMXY+yLEYXuhxIn6UVvHUz 66Rfluoi+oOF/Yyh+3wCHnYW/a5d/+Pz31QVtRO9kMJ/E5MuMsNW3k+3EjAEzqsh6qEE hDcRFASBOY3/cmcbp2ieYD6d0wJNmg+2/dBk+W7lPCkhEF9f1FaLcHW0D5bbqn2Xzztb ule76k7veACVGJP0el0gPJ3vhpc9/qIBwI3dpd7uwnMaQTNzoJ5fZPMpFPevgQhRY75G IwsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si3238306edd.588.2021.06.18.16.14.15; Fri, 18 Jun 2021 16:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236395AbhFRS2t (ORCPT + 99 others); Fri, 18 Jun 2021 14:28:49 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36141 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236356AbhFRS2f (ORCPT ); Fri, 18 Jun 2021 14:28:35 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1luJCC-0006jZ-0q; Fri, 18 Jun 2021 18:26:24 +0000 Subject: Re: gma500: issue with continue statement not doing anything useful To: Patrik Jakobsson Cc: David Airlie , Daniel Vetter , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" References: <9eff854f-92ed-3f09-997f-f81c78a8b5a3@canonical.com> From: Colin Ian King Message-ID: <85da780c-404b-dd23-c9ab-39c139e717da@canonical.com> Date: Fri, 18 Jun 2021 19:26:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/06/2021 12:19, Patrik Jakobsson wrote: > On Fri, Jun 18, 2021 at 12:26 PM Colin Ian King > wrote: >> >> Hi, > > Hi Colin > >> >> Static analysis with Coverity has found a rather old issue in >> drivers/gpu/drm/gma500/oaktrail_crtc.c with the following commit: > > Relevant code is in drivers/gpu/drm/gma500/oaktrail_lvds.c > >> >> commit 9bd81acdb648509dbbc32d4da0477c9fae0d6a73 >> Author: Patrik Jakobsson >> Date: Mon Dec 19 21:41:33 2011 +0000 >> >> gma500: Convert Oaktrail to work with new output handling >> >> The analysis is as follows: >> >> 114 /* Find the connector we're trying to set up */ >> 115 list_for_each_entry(connector, &mode_config->connector_list, >> head) { >> 116 if (!connector->encoder || connector->encoder->crtc >> != crtc) >> >> Continue has no effect (NO_EFFECT)useless_continue: Statement >> continue does not have any effect. >> >> 117 continue; >> 118 } >> 119 >> 120 if (!connector) { >> 121 DRM_ERROR("Couldn't find connector when setting mode"); >> 122 gma_power_end(dev); >> 123 return; >> 124 } >> >> Currently it appears the loop just iterates to the end of the list >> without doing anything useful. I'm not sure what the original intent >> was, so I'm not sure how this should be fixed. > > The code assumes there is only one correct connector so when iterating > over the connectors it checks for the connectors that does _not_ match > our criteria (!connector->encoder || connector->encoder->crtc >> != crtc). When the loop is done we end up with the correct connector set in the connector variable, hence the immediate check of "if (!connector) ...". > > So the code is correct but perhaps unintuitive. You could do the > opposite (if that makes more sense to you): > > list_for_each_entry(connector, &mode_config->connector_list, head) { > if (connector->encoder && connector->encoder->crtc == crtc) > break; > } OK, that makes sense. I'll send a fix for this shortly > > -Patrik > >> >> Colin