Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4324094rwl; Tue, 28 Mar 2023 05:53:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YH2Ohs90KjQFQp9cO5u26MqtJbF4ELqMLt995lOqh38ZLxc77KtLiPmBR7BipmPxs/uG8y X-Received: by 2002:aa7:950d:0:b0:627:8e40:68d8 with SMTP id b13-20020aa7950d000000b006278e4068d8mr14852122pfp.18.1680008038178; Tue, 28 Mar 2023 05:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680008038; cv=none; d=google.com; s=arc-20160816; b=0IT0XIlZJy+iV/TgZQMWOoVTOay10jE8teaQaCBNnbYC0Kk1CnqGklOuDVX537E1oT wsnrTz1a1JffjrXuml6WShiIzz8JWmgBWQ6WUPOINIR3BAMYTc6j4bAYy1YEVOX/gK3n Wws9otvDuMBSYMk3hOShAInvVR4aB562ilAEGW/jheVe2XvPxjbdFijVab+TrRSMai6q pjyuCnsWJso6BmYSaucUWfc41fSWfO3/u1/5q/7OB0oPgOzjGL4YwBRPM3ghu0DPh47H IaobS5BV0Myc0pXG54Z5MDmn3rV8VWNOSPoTkX7O7uJy7e/vCESHhMFRQQHFJCZYlnyR iXOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+VUczrl0KAxI7EZN7FCXQRJ3Opnej6HpZXA3PfYYOIY=; b=ILE1GUcRNYHmYek4JkyVzNMIsH4U22DhNb+LHFPv+f8Alq25ORJmK67e7AKfMLiqYv GS2B/H2ukKw4TcwPEnXmOIjaJi+PIHoc1gTspeN5gI9E00HGGbYtuqXWlZXad2CcOvhq FSqYKvKjPfxOVPAkEHnCtX5duZZTrR+bcyKV4OA8we5TxxJnCJQQ83rsyYaAI7i8guVm re7ZzgyO+b/xuPogv3Z2qwluWpEIEQyVTLHrJuYoKWjenKl9GxJZsdjSwrn8JVP8pqaQ CqptzvScJJFH4j7mVkd3flIcsK++Pzz7VId7hPcB0ZTcyilLkYjWEL+arZyuEh8To7Uh wotQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rgFMGzQU; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a056a0002a600b005a8ee84ba02si28480472pfs.310.2023.03.28.05.53.46; Tue, 28 Mar 2023 05:53:58 -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=@suse.com header.s=susede1 header.b=rgFMGzQU; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232621AbjC1Mx2 (ORCPT + 99 others); Tue, 28 Mar 2023 08:53:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbjC1Mw4 (ORCPT ); Tue, 28 Mar 2023 08:52:56 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0662B446; Tue, 28 Mar 2023 05:52:33 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A88C421A1C; Tue, 28 Mar 2023 12:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680007925; h=from:from:reply-to: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=+VUczrl0KAxI7EZN7FCXQRJ3Opnej6HpZXA3PfYYOIY=; b=rgFMGzQUiwPIo9UZ0Tt9qM0SwjsEFRZmQbwj5nHSIzv70eyH18ICVfJP+j9ZsGEz+BloqC 8G9ulxvsFiJl0olk6pP0HZr1QSE06eXGfaq4a62OOa0OcOYyp33r4+vqW2VGvz5x2tSi/l YHkncyrlf/3M71M3IURyyFKNDtK0RWQ= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 474132C141; Tue, 28 Mar 2023 12:52:05 +0000 (UTC) Date: Tue, 28 Mar 2023 14:52:02 +0200 From: Petr Mladek To: John Ogness 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 Message-ID: References: <20230302195618.156940-1-john.ogness@linutronix.de> <20230302195618.156940-6-john.ogness@linutronix.de> <87y1nip3a1.fsf@jogness.linutronix.de> <87cz4tus9d.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87cz4tus9d.fsf@jogness.linutronix.de> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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 Tue 2023-03-28 11:48:06, John Ogness wrote: > 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). Makes sense and looks good to me. Best Regards, Petr