Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6725396rwr; Tue, 25 Apr 2023 02:49:16 -0700 (PDT) X-Google-Smtp-Source: AKy350andyy+9vrSEMkD8jSDmUCs8TCjSkTB5lgzgJODGkTsNBJt80Y0pU+UhSfQ78o4INfhH8fI X-Received: by 2002:a17:90a:c793:b0:23c:fef0:d441 with SMTP id gn19-20020a17090ac79300b0023cfef0d441mr16239405pjb.33.1682416156229; Tue, 25 Apr 2023 02:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682416156; cv=none; d=google.com; s=arc-20160816; b=bVcvOBPdL1uo+TF4SLj0t+HpgcBDRkuFkB8zynxhtBh7cfeMfg9/dgtVku5ymch3F5 AFjBoCXGveOsKs9D9ce8zQkhSvRtrowNiMY29WijKQqPAb1aVHLB5jHlUZCH1EtEAV13 WlIAy6C7zeBujckRVevBChbFaknE0iryr+0H+QZAjifGGu3Dtz8VnVYScTqEWynbE3q4 Te6pOOXeU7S4ZccqssaKTJG6Hr6vcD2Uu3pZxfNn0gzqejvk4+mBrg7YkOpgumTJ+x1F cbD4Xk255kb5HYt/PKpqk1RfYLOkH4h0gONokd/H9Ld7D4x1vxxMGAC6QVwlDmvQKism Eujg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BHW6lOjF2/MreJruUAvsHwDdg1hNEm0hYuqgSYNZ7rU=; b=09/jPstL7Js50aAs/icqLIEvlvtGxzs5WSH63MoeM4QGq2Qrdwfzu9qyllTU737SX6 EG0hfHuA7Fubl4YX+GCZE9AyAryqktHqu6Ioa+Jmz7s/YPGIn3mV6EbJx4AJL8NKs0d1 4rHpjNYJNbcrNN4kYRk8b9SIa629ufmbamrJyHZEVVK1/hmTzbZMt7xuvFoPb2g/DkR/ wioKn/4E1agNLL5cLYjhPwoihQWvm8uy7w1D2cuZg7OdMSSbZoHpRNizOYjEjgU0HcIw +aeIbcA2nQ0MULJYptZXAcBF9+GT4EawrUDdczKVzWedJx821Vmq9WW8rKsKOZAkAJNX kiVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=kylie header.b=QUX1v0aE; 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=crudebyte.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e126-20020a636984000000b00524eef20da6si8824165pgc.642.2023.04.25.02.49.02; Tue, 25 Apr 2023 02:49:16 -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=@crudebyte.com header.s=kylie header.b=QUX1v0aE; 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=crudebyte.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbjDYJs4 (ORCPT + 99 others); Tue, 25 Apr 2023 05:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233701AbjDYJsq (ORCPT ); Tue, 25 Apr 2023 05:48:46 -0400 X-Greylist: delayed 1776 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 25 Apr 2023 02:48:21 PDT Received: from kylie.crudebyte.com (kylie.crudebyte.com [5.189.157.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1C712CAD; Tue, 25 Apr 2023 02:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=BHW6lOjF2/MreJruUAvsHwDdg1hNEm0hYuqgSYNZ7rU=; b=QUX1v0aEYSHcAuCErNP/NsH6Zu OdQ8annen0W4z5oS4TbLmKIdNMEffyzuWY+661xeEOsUsEVkT4M1POGHTgDHAH2ZaE86X3oZY/ewW 9AUxge9cp54U/J8CWCB9F0OFQ2RTMg8X/o/jalfWDTSgjOr+H4vb4RQ+fLqUcd2rIUHp8LfD/Wbke Q+iOsYy06AmdZWSheK/KEI9iJSBEzIVOYaDquz1aSyx1WDfFi++iVtmPVqlDr+PkKqPO8wrcC+xC1 IOrA6xMvLXZmPPrkxP1LLZOK3cj90RNsXvmmzBSgeSM3oMYtZ3o8wN+t/VVlPcA3iREIYb2xZyExR sCqEeC2vxSuC/0WQeO7rtCE6ZX//xG+X9/Uh8FSIUrQOZSmnJYCh+3aVbmxYHNElqL4lgG/ABGQLZ V9mTSYcwfeRs3No47N0QxVjjcLcUuhd9GuAtoUfT/9vT7ZwMJ0p7twyMqgKuNWGjnXvt2+u338UoB UCHK4ntPBn3LSGVze0rAlIzrUHoi+u49+bx9KoumTaNyILIqyGmBkMDX6qVywYOthAnR+L5kMLtsF xHwj1pvQ0xMonhBwuyOUI7Qt6t7kWJYKNToBQpzonqP0WDAhVZV1YeU8LRYSby+AwIky463GyjR5p mc2BK8SNERlDBxVa538t8/mcKpdvrr2gm7CIdQ4F4=; From: Christian Schoenebeck To: Christophe JAILLET , Dominique Martinet Cc: Eric Van Hensbergen , Latchesar Ionkov , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, v9fs@lists.linux.dev Subject: Re: [PATCH] fs/9p: Fix a datatype used with V9FS_DIRECT_IO Date: Tue, 25 Apr 2023 11:18:37 +0200 Message-ID: <2755033.v0V8SJffbf@silver> In-Reply-To: References: <80bae984fd5ca49b691bb35f2fd8f345f8bb67f1.1682405206.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tuesday, April 25, 2023 9:08:39 AM CEST Dominique Martinet wrote: > Christophe JAILLET wrote on Tue, Apr 25, 2023 at 08:47:27AM +0200: > > The commit in Fixes has introduced some "enum p9_session_flags" values > > larger than a char. > > Such values are stored in "v9fs_session_info->flags" which is a char only. > > > > Turn it into an int so that the "enum p9_session_flags" values can fit in > > it. > > Good catch, thanks! Indeed! Reviewed-by: Christian Schoenebeck > I'm surprised W=1 doesn't catch this... and now I'm checking higher > (noisy) W=, or even clang doesn't seem to print anything about e.g. > 'v9ses->flags & V9FS_DIRECT_IO is never true' or other warnings I'd have > expected to come up -- out of curiosity how did you find this? Both gcc and clang only trigger an implicit conversion warning if the value of the expression can be evaluated at compile time (i.e. all operands are constant), then compiler realizes that the compile-time evaluated constant value is too big for the assignment destination and triggers the warning. However as soon as any variable is involved in the expression, like in this code, then the final value of the expression cannot be evaluated at compile- time. Small operands (e.g. `char` types) in the expression are auto-promoted to `int`, hence no warning at this stage, and finally you have an assignment with unknown `int` value. This could certainly be improved by carrying along the information that an expression evaluates to at least x bits at runtime (when the compiler reduces the expression). > Would probably be interesting to run some form of the same in our > automation. If there is any ATM? I als tried this issue with clang's undefined behaviour sanitizer and with the clang static analyzer. Both did not detect it. > > > Fixes: 6deffc8924b5 ("fs/9p: Add new mount modes") > > (Not a problem per se: but note this commit hasn't been merged yet, so > using commit IDs is a bit dangerous. Might want to remark this in the > free comment section so Eric pays attention to not break that when applying) > > > Signed-off-by: Christophe JAILLET > > Reviewed-by: Dominique Martinet > >