Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4113541rwl; Tue, 28 Mar 2023 02:49:59 -0700 (PDT) X-Google-Smtp-Source: AKy350Zmh6LlqD20qKiTJLLz2u9UWKLhQ41u36VOw/xVkMOM+yJ2KTFxQ+pMn//uytvVmKfh5L/a X-Received: by 2002:a17:906:94cc:b0:930:b130:b7b with SMTP id d12-20020a17090694cc00b00930b1300b7bmr15915933ejy.6.1679996999320; Tue, 28 Mar 2023 02:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679996999; cv=none; d=google.com; s=arc-20160816; b=Q58t2KGqGyTAPN3ULVX5bjw3zywrU1vQ6v/WL3OBQaj57Oqq99puuY5wpaolnzBAw/ lAaaVZ2SFGdjGRj2FfGz4I8bg4QgTsNYzOc0S3ay8g8wCO6bdFJusyyuH6KGyYUEQwgn 2me6og9cB13x2iUVPNqCbjEYJR9oWBqq1/XK1Rpz4VGxJxmXemFDH10MuTsiZCyK6e69 JIufjEpH9XL+CR/aO4B1nKvfZJVjQjnhvw7ZoEqf2fGbTagnX0xEJx9zOHIWCwbFkh5a 9yeEuSr/Y7273PUtIWvYDo6j4LZ1mJdBqma4FtHXsPs1rePxsEcpNebRJgfwoXY7pkEm EM+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=ZJUsCpyk++InuJD8c8lxndmlf4x2V623RySxbdpxX/k=; b=cENsfzeU9L5mSqKEpYzFHcdJSRZksMiK2p+bfBP9YnWon1kobzY3fPI1WzKtynIp0E vbMyAp0o93A9LRn7P+CbAsM2cfwMO6peO/WyOSzIwH9puU4tOG43vgldl60GGh3Il/jz tW7N3nv3Hk8T5F/oS9HXxXiGc9nbglI6DzS+OpgIKM4cHPuIX1LJr+jsO6mUhw0+Rm8r VLgAESbMzSGxWbKn3htj9LRXb06jN7l6LLkH/E7FMHuYAZTFY1FSnWChkXdfcczsHDg3 l5UDAALCh6cG/Up87A84DUvdgSF9no6YLAOm63NZ02NDmsbl3NGNrpDeSWwusssA4mle /SWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Uyj1ACFT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IplZafMH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vj7-20020a170907d48700b0093cf8c96422si10144296ejc.719.2023.03.28.02.49.33; Tue, 28 Mar 2023 02:49:59 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Uyj1ACFT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IplZafMH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbjC1Joa (ORCPT + 99 others); Tue, 28 Mar 2023 05:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232926AbjC1Jnt (ORCPT ); Tue, 28 Mar 2023 05:43:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A73619C; Tue, 28 Mar 2023 02:43:48 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679996626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZJUsCpyk++InuJD8c8lxndmlf4x2V623RySxbdpxX/k=; b=Uyj1ACFTSvJ37+qTPnzpaAJOMaiSAelVgF1p9i/ti4EZvOobjhHWGgYRRN5sMBjcETUXWR 1cMdDksX6+EgiwtW6YvmB/kfDTZoBXT7sZrUg01dFAEQ5SvSb0DPTwSla6hBQMI/PQKSWp F4eJdNhm2nnljlMOt+yub+n8x7paNu18P2CLLBfbcypP4ViRkic5BnZU4BBmM59Nk/9LZk Kksd2lf2VOoed6cIxk7ScVaSPVZmZUGEDFKrGQllQn8LxRbKrPA8ZDpbbkXDtpIO3NHn3n DDfIcE76WdRVye+lTkl0k+auwIijCwhdh19hUgAFbuZLFmLaWmELSRkabjZGzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679996626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZJUsCpyk++InuJD8c8lxndmlf4x2V623RySxbdpxX/k=; b=IplZafMHsF4nv815SX/K+f2hvIwBR0S2XIVpBTpNkVSGZYRCb/mxkvMLfvuGcxKOR0QBGZ s7+2n3ygmO8H4JDA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-fsdevel@vger.kernel.org Subject: Re: union: was: Re: [PATCH printk v1 05/18] printk: Add non-BKL console basic infrastructure In-Reply-To: References: <20230302195618.156940-1-john.ogness@linutronix.de> <20230302195618.156940-6-john.ogness@linutronix.de> <87y1nip3a1.fsf@jogness.linutronix.de> Date: Tue, 28 Mar 2023 11:48:06 +0206 Message-ID: <87cz4tus9d.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 2023-03-28, Petr Mladek wrote: >> A compilation check would be nice. Is that possible? > > I think the following might do the trick: > > static_assert(sizeof(struct cons_state) == sizeof(atomic_long_t)); I never realized the kernel code was allowed to have that. But it is everywhere! :-) Thanks. I've added and tested the following: /* * The nbcon_state struct is used to easily create and interpret values that * are stored in the console.nbcon_state variable. Make sure this struct stays * within the size boundaries of that atomic variable's underlying type in * order to avoid any accidental truncation. */ static_assert(sizeof(struct nbcon_state) <= sizeof(long)); Note that I am checking against sizeof(long), the underlying variable type. We probably shouldn't assume sizeof(atomic_long_t) is always sizeof(long). John