Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp581808pxb; Fri, 15 Oct 2021 11:29:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyooUI4UdsYPhCC1DTgOWZmsu8Lu1lwsBTz36m4o73S+XVKLJcc2nmQ0lTm73EV3lF0EyNZ X-Received: by 2002:a63:101c:: with SMTP id f28mr10258578pgl.330.1634322545197; Fri, 15 Oct 2021 11:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634322545; cv=none; d=google.com; s=arc-20160816; b=RZMQIN8tCHun+mT59D+qvzuYBOQgVGDjzpfQLOAzKg8AWBDTsiMDTzvUcvAFz/9+oi DAy8KAVY5g+JJvvxk9DNRwrV2rT5tUjb/hXkK8tCEfk2s4STY3jiTZDWtDQvixvq6e7U DyijFqyjUAH1LQsng2ugHcWMzkZJ7/8ckrb9ViMCpgGFLmRbr9XUPWNDWsKzlAwRM/yn ISNRdIsfBLMCKreJK/xFs5vG7lt/e5Dk6YxWv7arvPmGBA6soubUsh9IE5d+8pThIQUt MpYGtNMzZRYelYI2ITCxNsfows1ER5RYgdNl1lSs+D2ItXAL61STj8939YEiEl/PMa3g syeA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=HlBUuPKW6eLGPtrxF8ihDCfwVdA6RrUXRaRHwVNrmjE=; b=yzYa7VAIE3nkGlk3ulw+bbjB2NoVXDy++iKKXOsWQXAP+lUEAQn+EiW1Nt//BIBB5D tghF6/voGQbj6vivBKBatSPXfNJ+uiTHkCgbC9JS3uSX3FuCmW+SJwTAU/jM07YOtidL eeoGxztai6i7r+fcrwgyijCrUZD11NU2lSG1qA6efGRZJbuAeI67sFbpz8XjgTPDSt91 wRevGS5AM76rWFTRocTMLJeumM+f3nS/4QNBv7mL+1f8tRvSvmCHwTvvfziWZ57c96gG H0e9FIt4k0XYKVxDiokGPsRcQf+bptBew9ReamQ/y6+6Hj9aes79+ZjxF5ncIX6Capaz jnBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si8117313pfg.60.2021.10.15.11.28.52; Fri, 15 Oct 2021 11:29:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237835AbhJOKQG (ORCPT + 99 others); Fri, 15 Oct 2021 06:16:06 -0400 Received: from mga12.intel.com ([192.55.52.136]:23621 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232991AbhJOKQD (ORCPT ); Fri, 15 Oct 2021 06:16:03 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="208002544" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="208002544" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 03:13:57 -0700 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="571720531" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.159]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 03:13:55 -0700 Received: from andy by smile with local (Exim 4.95) (envelope-from ) id 1mbN1p-000OyW-JH; Fri, 15 Oct 2021 16:13:41 +0300 Date: Fri, 15 Oct 2021 16:13:41 +0300 From: Andy Shevchenko To: Rasmus Villemoes Cc: akpm@linux-foundation.org, Miguel Ojeda , Nick Desaulniers , linux-kernel@vger.kernel.org Subject: Re: [PATCH] linux/container_of.h: switch to static_assert Message-ID: References: <20211015090530.2774079-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 04:11:01PM +0300, Andy Shevchenko wrote: > On Fri, Oct 15, 2021 at 11:05:30AM +0200, Rasmus Villemoes wrote: > > _Static_assert() is evaluated already in the compiler's frontend, and > > gives a somehat more to-the-point error, compared to the BUILD_BUG_ON > > macro, which only fires after the optimizer has had a chance to > > eliminate calls to functions marked with > > __attribute__((error)). In theory, this might make builds a tiny bit > > faster. > > > > There's also a little less gunk in the error message emitted: > > > > lib/sort.c: In function ‘foo’: > > ./include/linux/build_bug.h:78:41: error: static assertion failed: "pointer type mismatch in container_of()" > > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) > > > > compared to > > > > lib/sort.c: In function ‘foo’: > > ././include/linux/compiler_types.h:322:38: error: call to ‘__compiletime_assert_2’ declared with attribute error: pointer type mismatch in container_of() > > 322 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > > > > While at it, fix the copy-pasto in container_of_safe(). > > Thanks, Rasmus! > Make sense to me. Btw, shouldn't we also remove build_bug.h in the container_of.h with this? (Or if this goes first, do we still need bug.h?) -- With Best Regards, Andy Shevchenko