Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5954680pxb; Mon, 14 Feb 2022 11:36:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFTVwhqO4H8QxXBb4FfVtX+gVhF2eA86nRX6AUdE8+rPzHGF6QhFYZ39FYe0Z3ReOP5c4O X-Received: by 2002:a63:6a89:: with SMTP id f131mr518519pgc.108.1644867368967; Mon, 14 Feb 2022 11:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644867368; cv=none; d=google.com; s=arc-20160816; b=jbRLSfZi6AYg5eVD/FLKL6d7HIwLpt1PPFFdpsOo1kJYAGeD5IyiMEuTX8vQpDkyFd xEBgeCMeoN4raK1O/PiYhzayKXeMKQ5coDl9VFP1TDRrPbsIn1ih7QS05E3DIC18G5r0 /o+wWJHQsUZBAXtFdXhQyX3KsCgOEXmNERsISHGI7cCsUBIpcjaLnn9pYMh2GcSwYBh9 KmPwadVUnfEdSsjCVtomLyKqKqozPUqlA8L9GXGhs/koi/TDxSHUsREKhG1m/6181S2C 6r+ABtB82+ybx4iUKf/f1786giqEwQMzbPYV2/OPxzeRWYt5QkkpxZUmtLlXOXcJ7Bp4 RgGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=SQrH3exqBXKgpKYt/u29wft1YIw7itlhTXjFBq8YQwk=; b=KK+XGCNpCsYGTsvqd+10IhG145nhoS1AbxnfkHv3uSkoJMHanEnTNXinz7SrRzGaGU NcqpAla7euyvjF8jYKUCD8ScshC+hAWvZWhnGLXjqmbXAm5yZa3Yrhdd4aDLhaFKJ0k0 ZvJWudeEsRVGGVzy8FSIh026ALqNSdWoQI9w0cmCYQAe9KTQ8lkeOA2JzkxvWEGccLSM ZggFdSxw0CrHcT93j45iIgnU0svEcnPRNvLPPJX5YZUP1Nn1tT3VAME3YZDW2isiHB0X MQlVjkUAN47ZUZrAayRfI5aHiJKuYqUz85qWRwOXA81gAtefXJOg/gKR4QfUhyfGb9Wh 6Mzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhkhntxu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e66si524980pgc.700.2022.02.14.11.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 11:36:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhkhntxu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEAF6FBF2C; Mon, 14 Feb 2022 11:23:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350103AbiBNLMn (ORCPT + 99 others); Mon, 14 Feb 2022 06:12:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350992AbiBNLLK (ORCPT ); Mon, 14 Feb 2022 06:11:10 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00A3EA889C; Mon, 14 Feb 2022 02:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644835171; x=1676371171; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=C9m2rcxcDwLvUl2QbsECG3i5+PvKcHA60fHQFVqzZzs=; b=dhkhntxuAdMfT9J1D8023bmadjBHne0lC0goQVMLLlrxixpdQRhFMXVw wE9KhVl/y2By+y8UUtjFchH09gJWC6Tk7aaVx0xKDAzPRCOzG7EcOUhO4 4Hdfa5TEhNgenE7lB6+3f6N3dpfAJzoRRm0lZIQQri9Xmez1OyoshS5Z2 XUbOhVbyWbl2gTk/5CS5q1oE2f9JU7qPXhd/VY+iJ68as+6iIvHfWZgrz KpYfRrHMIOlErd7l4yLHAtW5fPkoR2cwQS4dB3OfSekVpM/7KD8wG/R7O XvqPP1i177p/Z3JnpvKxiukFzynom7c21l6Gy6lAoklGiMHXZrs68ch92 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10257"; a="313342043" X-IronPort-AV: E=Sophos;i="5.88,367,1635231600"; d="scan'208";a="313342043" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 02:39:15 -0800 X-IronPort-AV: E=Sophos;i="5.88,367,1635231600"; d="scan'208";a="570085760" Received: from smile.fi.intel.com ([10.237.72.61]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 02:39:12 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nJYkG-004Pw8-Jg; Mon, 14 Feb 2022 12:38:12 +0200 Date: Mon, 14 Feb 2022 12:38:12 +0200 From: Andy Shevchenko To: Thomas Zimmermann Cc: Jani Nikula , Javier Martinez Canillas , linux-fbdev@vger.kernel.org, David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Geert Uytterhoeven , Maxime Ripard , Sam Ravnborg Subject: Re: [PATCH v4 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() Message-ID: References: <20220211091927.2988283-1-javierm@redhat.com> <20220211091927.2988283-2-javierm@redhat.com> <4fa465d9-4fac-4199-9a04-d8e09d164308@redhat.com> <7560cd10-0a7c-3fda-da83-9008833e3901@suse.de> <87pmnt7gm3.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 14, 2022 at 10:03:53AM +0100, Thomas Zimmermann wrote: > Am 11.02.22 um 16:41 schrieb Andy Shevchenko: ... > > > IMO *always* prefer a for loop over while or do-while. > > > > > > The for (i = 0; i < N; i++) is such a strong paradigm in C. You > > > instantly know how many times you're going to loop, at a glance. Not so > > > with with the alternatives, which should be used sparingly. > > > > while () {} _is_ a paradigm, for-loop is syntax sugar on top of it. > > Naw, that's not true. In the section 3.5 "Loops - While and For" in "The C Programming Language" 2nd by K&R, the authors said: The for statement ... is equivalent to ... while..." They said that for is equivalent to while, and not otherwise. Also, syntax sugar by definition declares something that can be written as a single line of code, which usually is done using more (not always). > An idiomatic for loop, such as for (i = ...; i < N; > ++i), is such a strong pattern that it's way better than the corresponding > while loop. > > > And yes, the do-while suggested above is buggy, and you actually need to > > > stop and think to see why. > > > > It depends if pixels can be 0 or not and if it's not, then does it contain last > > or number. > > > > The do {} while (--pixels); might be buggy iff pixels may be 0. -- With Best Regards, Andy Shevchenko