Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1521967rwb; Wed, 28 Sep 2022 21:03:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4IAXLF4BM4hm3oL6QpZ9jL10eiDcMibycP6pCq1euhIYSHp/U00DFhV68n1C1/K7Nzxed1 X-Received: by 2002:a17:907:6eaa:b0:783:84e0:3823 with SMTP id sh42-20020a1709076eaa00b0078384e03823mr946588ejc.601.1664424191285; Wed, 28 Sep 2022 21:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664424191; cv=none; d=google.com; s=arc-20160816; b=kR4zvGipjeqXInyzDC1dbWr1hh7rC9xRpRDcBCIlM6+FuW4MwP530WRSWNHJui8m05 ggpUC63AyEZwrt8SElAMAmwBlASRrbpTzDxyqmUwSVORsgUERWk5KEeNB7UMvniGLhrT yq0wft1h48gz8q47XBGC9i9cudD/h4uoFodRwPkyjLE2WaweRGJc2d7T8lgtXR7vcUxK j4dhRix5OdjrKmXts9qlThcRTsVCuM53COi3IiorZuNFeNLxrgTFr85qBiSC7yg09ODb lbFOEu/tZdyEMVj13tYxmP5ZHuJm0jwNMlQAnT/axLKBQ9+SNwW1xXV1bvUq/Qv2VLee d3iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=CEu+ZVtjBGgK8hk3iwaSXBSqZRnpbVOjFHvU5b1rpdQ=; b=ORbzpzCKqspqsSP+v4yjbtUH2BRrL2H/xpPRV2yuCpGykhodhYpPLcb9cfQNF6YCoO KUdwbJtIoVSvly/goPDUbAZHeJ38d/9xa17orLOiPHvUAFFHQrZIvm2ViBXHA5UULw/m FCDW8+BBZHaxNOEtzlT7N3cDnKNhkCbVvYub4VWKcjKMFmsszNcOCeEqcPbc8/HxROU6 kXnsqWBZuO/YOtWFXu3Ph6FoKZRtVNew1JAEzr6uJADYqRNyh9zNRxNLl5xIL1lWZhVO Vzv86ebYW00+rF95IwQyuiRjUU3CYDfJHuK6ErQEiQJmaxGlFU7SjtndRoj5HKeO6qjM QvmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb27-20020a170907961b00b00730ac298aa9si7881328ejc.783.2022.09.28.21.02.41; Wed, 28 Sep 2022 21:03:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234749AbiI2DXB (ORCPT + 99 others); Wed, 28 Sep 2022 23:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbiI2DW6 (ORCPT ); Wed, 28 Sep 2022 23:22:58 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F16127541; Wed, 28 Sep 2022 20:22:56 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MdJTV64vQzHtmG; Thu, 29 Sep 2022 11:18:06 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 29 Sep 2022 11:22:44 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 29 Sep 2022 11:22:44 +0800 From: Yang Yingliang To: , , , CC: , Subject: [PATCH -next] compiler.h: fix compile error with gcc-8 or lower version Date: Thu, 29 Sep 2022 11:38:45 +0800 Message-ID: <20220929033845.485728-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 I got the follow compile error in latest linux-next kernel with gcc-8.4: In file included from : ./include/linux/percpu.h: In function ‘__alloc_reserved_percpu’: ././include/linux/compiler_types.h:279:30: error: expected declaration specifiers before ‘__alloc_size__’ #define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc ^~~~~~~~~~~~~~ ./include/linux/percpu.h:120:74: note: in expansion of macro ‘__alloc_size’ extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align) __alloc_size(1); __alloc_size is not defined in gcc-8 or lower version, so add back the conditional test for __alloc_size__ to fix it. Fixes: 63caa04ec605 ("slab: Remove __malloc attribute from realloc functions") Signed-off-by: Yang Yingliang --- include/linux/compiler_types.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index aa81da7a28eb..aae8852ccbdc 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -276,8 +276,13 @@ struct ftrace_likely_data { * be performing a _reallocation_, as that may alias the existing pointer. * For these, use __realloc_size(). */ +#ifdef __alloc_size__ #define __alloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) __malloc -#define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) +#define __realloc_size(x, ...) __alloc_size__(x, ## __VA_ARGS__) +#else +#define __alloc_size(x, ...) __malloc +#define __realloc_size(x, ...) __malloc +#endif #ifndef asm_volatile_goto #define asm_volatile_goto(x...) asm goto(x) -- 2.25.1