Received: by 10.213.65.68 with SMTP id h4csp439522imn; Tue, 27 Mar 2018 02:08:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELsTJBSEYULlUbfYRe6bsR0EFdWIv7gNE2xdqhYK1spB2+FZoKzyhIe6DDfpCny7A648mCOV X-Received: by 2002:a17:902:7185:: with SMTP id b5-v6mr44041010pll.221.1522141731301; Tue, 27 Mar 2018 02:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522141731; cv=none; d=google.com; s=arc-20160816; b=r1UYsMFR8uMsouDv3ZYwirn7ct8KOVAgZGaEwm1O8LsDx1j4R9w+FWZ3MlJAH1+WC3 HCdXpB0ZxGngY2C1H2Do79K2/1hZf4DWapyp3iLyEp5VDVd9vcGJXhebE4fSSfOXVTSo 6cv5sLZHswoIeWzjDWKKfMyiGGeMV4ET20c/b9J/Y63jjG13OXOjUlF4C2gxzBqySECc BZGGikOXuOSv4srML3iDe0f/7pmiAktnrJdIv+rO6xITFGYSWEz//vfDWnIAt/qMUimp vVwyf/UqPSeTOWGV1swBgpFrD5ulUKFLbx3FTTplv5EglIhPZh9opnjASODDavBwd2vY kulA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=VWIH+cu5VW6202wWb51yVuMKErnGENcaE3Loa2IWrvE=; b=ZaJAPIBLIt5QGc+CvNSkzoiZUL+gfCOF6OioApHLrPpA2BidsVc88SULMbJHJ+AL2F un+o3+F5jbCRHvkOiUD1O/7OPFPxpzEUTXEzsqjFzuoxis8BO1gHMW7zFaKRqIVJ3eQI 66NA4U16qHB32D+IF5TsnwgsLTV5lPC6o3M8D+kWSgK/yKJ+t7xOoMCD94x7BVZRLDsk w0fX7vdD/dV9pWn4FbmfZWC0IUfTENqHBEXTBHAf4BE3Yn15KkNVDs3bhUaivTusoi/Y Ue3+DQqWgjWu/gDZJmvDSlPOmeWCduG3XcmTe1awlRcb+dRSIAkmjTXfaABsuXPwjd+T p2Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GPLG5JzM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si545733pgu.760.2018.03.27.02.08.36; Tue, 27 Mar 2018 02:08:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GPLG5JzM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbeC0JGI (ORCPT + 99 others); Tue, 27 Mar 2018 05:06:08 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:41406 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750978AbeC0JGF (ORCPT ); Tue, 27 Mar 2018 05:06:05 -0400 Received: by mail-qt0-f196.google.com with SMTP id d18so10518859qtl.8; Tue, 27 Mar 2018 02:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=VWIH+cu5VW6202wWb51yVuMKErnGENcaE3Loa2IWrvE=; b=GPLG5JzMLoVxLMUC6qsnXfWDPbVm8XNCiPjPA5Vnxx8dffSZmc+VykLfPsuraQSL4E eMlAY3NbThLBzVFhz/idIaMCrKPQGMo/Lx+E8WNKoV34nRxAYx2t2s04JPVrnKscXmeI x6Vfg0+Ku3G/R2qKj665G5PS8ngBOavvGBUvNw7T9uGvSkqEIoo3NNBpErvpuht5EUDk P6p+r9qc13OaA6SkAxCshoL6dkTnaazumw7uEo3SMKIkaBrgD/QvicytzJl/XrcFvIzB on6hme3kMMlg/ZfJZvdtvJ/ugOumJx4edASnBeu2duut/GYOEz4mmJAmt/0h8oLTEEMK e4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=VWIH+cu5VW6202wWb51yVuMKErnGENcaE3Loa2IWrvE=; b=AlGXwyD3+OGEVFBw0+6JYejfq/u6FVjHSw4OpQ1iolmFiBpghlTrSex4d4MbYEFJQ1 X3q11nq9VILlOvIf/pjrqSCgCX5g28lHP7wjoDVQ/irB0gNIScLHBh+15XUR8gmL4TB9 7ZQEjRjF0TyjZlCfH8obV8iE7VcxG4ZkngXevchfn79A8cWi1KtwxFgyH4sf0AsUmlQq flR4NhS5m/S3KkZyx+/a6SSm8xyyu4ndREQTqw5Og2jpn463/EEKaUcIYNsyRQrwXrpj kjWToRSrYdUGKetG9GA/CxyK0Cn/hpCDgv20eFXzPmaIOFHwybcLKPewIa2LucUq4dIT 6eDA== X-Gm-Message-State: AElRT7FEweKyAv6tFfdb/Ghs73sru37VqqtTrWr/vjEe7j/Ny0jIlw07 orPCDu75Glnp/ZAScWoPqXdPDowgH9d05XpTzzI= X-Received: by 10.200.44.164 with SMTP id 33mr5435458qtw.160.1522141564428; Tue, 27 Mar 2018 02:06:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.54.147 with HTTP; Tue, 27 Mar 2018 02:06:03 -0700 (PDT) In-Reply-To: <8115587a-4925-5602-43db-4285a3de7b0e@samsung.com> References: <1521213399-31947-1-git-send-email-jacopo+renesas@jmondi.org> <1521213399-31947-3-git-send-email-jacopo+renesas@jmondi.org> <30381869-9bc8-b6aa-a37a-598d9c8f280d@mentor.com> <8115587a-4925-5602-43db-4285a3de7b0e@samsung.com> From: Geert Uytterhoeven Date: Tue, 27 Mar 2018 11:06:03 +0200 X-Google-Sender-Auth: xCtGOAlD_UqPWzLpRaTkT2cf1VQ Message-ID: Subject: Re: [PATCH v6 2/3] drm: bridge: Add thc63lvd1024 LVDS decoder driver To: Andrzej Hajda Cc: Vladimir Zapolskiy , Jacopo Mondi , Archit Taneja , Laurent Pinchart , David Airlie , Simon Horman , Magnus Damm , =?UTF-8?Q?Niklas_S=C3=B6derlund?= , Sergei Shtylyov , Rob Herring , Mark Rutland , DRI Development , Linux-Renesas , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrezj, On Tue, Mar 27, 2018 at 10:36 AM, Andrzej Hajda wrote: > On 27.03.2018 09:36, Geert Uytterhoeven wrote: >> On Tue, Mar 27, 2018 at 9:28 AM, Andrzej Hajda wrote: >>>>> --- /dev/null >>>>> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c >>>>> +static void thc63_enable(struct drm_bridge *bridge) >>>>> +{ >>>>> + struct thc63_dev *thc63 = to_thc63(bridge); >>>>> + struct regulator *vcc; >>>>> + int i; >>>> unsigned int i; >>> Why? You are introducing silly bug this way, see few lines below. >>> >>>>> + >>>>> + for (i = 0; i < ARRAY_SIZE(thc63->vccs); i++) { >>>>> + vcc = thc63->vccs[i]; >>>>> + if (!vcc) >>>>> + continue; >>>>> + >>>>> + if (regulator_enable(vcc)) >>>>> + goto error_vcc_enable; >>>>> + } >>>>> + >>>>> + if (thc63->pdwn) >>>>> + gpiod_set_value(thc63->pdwn, 0); >>>>> + >>>>> + if (thc63->oe) >>>>> + gpiod_set_value(thc63->oe, 1); >>>>> + >>>>> + return; >>>>> + >>>>> +error_vcc_enable: >>>>> + dev_err(thc63->dev, "Failed to enable regulator %s\n", >>>>> + thc63_reg_names[i]); >>>>> + >>>>> + for (i = i - 1; i >= 0; i--) { >>> Here, the loop will not end if you define i unsigned. >> True. >> >>> I know one can change the loop, to make it working with unsigned. But >>> this clearly shows that using unsigned is more risky. >>> What are advantages of unsigned vs int in this case. Are there some >>> guidelines/discussions about it? >> Some people consider signed integers harmful, as they may be converted >> silently by the compiler to the "larger" unsigned type when needed. > > Wow, it sounds crazy, shall we expect gigantic patchsets, converting all > occurrences of int to "unsigned int" ? :) No we shall not. > I know both types have their pros and cons and can behave unexpectedly > in corner cases, but I do not see why unsigned should be preferred over > signed in general, or in this particular case. When looping over array indices, and comparing with ARRAY_SIZE (which is unsigned), using "unsigned int" is preferred. However, in this case the error code relies on the index becoming negative, so a signed integer should be used. > I guess there were somewhere discussion about it, could you point me to > it if possible, to avoid unnecessary noise in this thread. Not here, but Google pointed me to http://blog.robertelder.org/signed-or-unsigned/ Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds