From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2378118757C for ; Fri, 27 Sep 2024 09:54:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727430854; cv=none; b=b6SX8DvQap8qA/z/wqGivQJxyvZa6nhwpIxZuAFWDl4T3QN2Cjuid9goaiFDh9SzW/Ic28dBlDzOsn9YyoJYgNeDZ3VHsbusbgdWxSOvBI3eMgRMIuhEHKWnw6SaVG7K2/S4Zp0aZlE4/pvFaInfDYcClh9zj74GpXPtAyC+JPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727430854; c=relaxed/simple; bh=o4i7tXlhj3m5lyhUwDKJ887axGnsQjKGCpplffx923M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QLsis7e1JrqpQcjTk3xOMCJ5APeBiI3/ebQtwIYgT2rA6wF9l0DGghcPg2qCzb+9A9nUNc49H9giih2Db5ktz3Qeo6ULddKgmVUvmpE1DPoRlZSxz8C4x9M7TBb2GMBmY1+hLlU16uHk1sx/89pMbCAsnZB5uqNTqszyyNUVZ2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org X-CSE-ConnectionGUID: Rk8drBe9RXS2o6ZlfCOQRA== X-CSE-MsgGUID: hHcpnnSTTYO4vYk4DlU9OA== X-IronPort-AV: E=McAfee;i="6700,10204,11207"; a="26077617" X-IronPort-AV: E=Sophos;i="6.11,158,1725346800"; d="scan'208";a="26077617" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 02:54:12 -0700 X-CSE-ConnectionGUID: 4b1CI0ykTW6p7tP9m2xgZQ== X-CSE-MsgGUID: FK/7O2QVR4y2pLTRxlf6xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,158,1725346800"; d="scan'208";a="109977131" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 02:54:10 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.98) (envelope-from ) id 1su7fq-0000000DWiZ-0oF7; Fri, 27 Sep 2024 12:54:06 +0300 Date: Fri, 27 Sep 2024 12:54:05 +0300 From: Andy Shevchenko To: Ricardo Ribalda Cc: Benoit Parrot , Mauro Carvalho Chehab , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Greg Kroah-Hartman , Hans de Goede , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH 3/3] media: atomisp: Use max() macros Message-ID: References: <20240927-cocci-6-12-v1-0-a318d4e6a19d@chromium.org> <20240927-cocci-6-12-v1-3-a318d4e6a19d@chromium.org> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240927-cocci-6-12-v1-3-a318d4e6a19d@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Fri, Sep 27, 2024 at 09:42:15AM +0000, Ricardo Ribalda wrote: > The max() macro produce nicer code and also fixes the following cocci > errors: > > drivers/staging/media/atomisp/pci/sh_css_frac.h:40:17-18: WARNING opportunity for max() > drivers/staging/media/atomisp/pci/sh_css_frac.h:50:17-18: WARNING opportunity for max() In some (rare) cases it's a bad advice. NAK. ... > - v >>= fit_shift > 0 ? fit_shift : 0; > + v >>= max(fit_shift, 0); max() with 0 is a bit unusual, esp. taking into account that the operator here is a right shift. So, what we check here is the signedness of the value to avoid not only potentially wrong calculations, but also UB. The original code is clearer for all this. -- With Best Regards, Andy Shevchenko