From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B269C001B0 for ; Tue, 15 Aug 2023 11:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235836AbjHOL1y (ORCPT ); Tue, 15 Aug 2023 07:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236251AbjHOL1o (ORCPT ); Tue, 15 Aug 2023 07:27:44 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7629E73 for ; Tue, 15 Aug 2023 04:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692098863; x=1723634863; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=c0UQwalrepMpq1VW/SpIyUAEXIcvIN5UafwiPH6RW2c=; b=hZ/pvIAsmLClJV6Kzk3ttcmV0Bc3Ei8z6haN1JzWacazeHKiEqTxHbQm DWcQFX7e75gPCBpRKrZUVZfIZAAFX58wwvrndta583IePG1TF1ttiw1nl 3xoc93MFVs4JC8OnNoUXFZxzICoMJxjHVte+uZJviwt73Y13p8x3JzFO/ /gqJKWZgaSdRDnJlDwe6tVxdX+L/H4yofmEX3n9R7eR3mxrMppWhI2yzN 1pT88weKmNVu81pNQ/RtXGGMNGqc07FqcXPB7NnhtKaIxooTZXDGy/nh5 dqHAuY5kpIzbO6iC59pvhV+kD3gN1eVR0rINfph2IO4D/8nQFDnLWFuip Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="351844540" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="351844540" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2023 04:27:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10802"; a="980338041" X-IronPort-AV: E=Sophos;i="6.01,174,1684825200"; d="scan'208";a="980338041" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 15 Aug 2023 04:27:38 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3C520350; Tue, 15 Aug 2023 14:35:42 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Herve Codina , Mark Brown , alsa-devel@alsa-project.org Subject: [PATCH v1 1/1] minmax: Deduplicate __unconst_integer_typeof() Date: Tue, 15 Aug 2023 14:35:34 +0300 Message-Id: <20230815113534.10592-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It appears that compiler_types.h already have an implementation of the __unconst_integer_typeof() called __unqual_scalar_typeof(). Use it instead of the copy. Signed-off-by: Andy Shevchenko --- As the initial code is in Linux Next via ASoC tree, it's assumed to go via that tree as well. include/linux/minmax.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 83aebc244cba..69bbe987fa87 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MINMAX_H #define _LINUX_MINMAX_H +#include #include #include @@ -134,27 +135,6 @@ */ #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) -/* - * Remove a const qualifier from integer types - * _Generic(foo, type-name: association, ..., default: association) performs a - * comparison against the foo type (not the qualified type). - * Do not use the const keyword in the type-name as it will not match the - * unqualified type of foo. - */ -#define __unconst_integer_type_cases(type) \ - unsigned type: (unsigned type)0, \ - signed type: (signed type)0 - -#define __unconst_integer_typeof(x) typeof( \ - _Generic((x), \ - char: (char)0, \ - __unconst_integer_type_cases(char), \ - __unconst_integer_type_cases(short), \ - __unconst_integer_type_cases(int), \ - __unconst_integer_type_cases(long), \ - __unconst_integer_type_cases(long long), \ - default: (x))) - /* * Do not check the array parameter using __must_be_array(). * In the following legit use-case where the "array" passed is a simple pointer, @@ -169,13 +149,13 @@ * 'int *buff' and 'int buff[N]' types. * * The array can be an array of const items. - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order * to discard the const qualifier for the __element variable. */ #define __minmax_array(op, array, len) ({ \ typeof(&(array)[0]) __array = (array); \ typeof(len) __len = (len); \ - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ while (__len--) \ __element = op(__element, __array[__len]); \ __element; }) -- 2.40.0.1.gaa8946217a0b