From patchwork Tue Aug 15 21:11:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13354334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9AE15C001E0 for ; Tue, 15 Aug 2023 21:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=op0E87LrXQahVL20+sp7yda9spcyYXEpdDYuWya+c8k=; b=Fn/ I8TvhlZJXKdoSYOtT0DH9sVG+vdQJs3NbRu+gJYB0ONb78e4qrCNForq7MqwuX2jYeQvRRM12sj0V nKzPqE6CUKJet0UgJLPbtyRaXqPpWMLFQNOUVmndJ3NrqG7hCv3fg6blNV0375SZ9Y54kbR9XTvc1 I52kh2+NiKBPsD/E4YbOzCzFBfFC4/w4ABjoFcY/+B+HniA+8wQviY5p1AItLXroAq5leyzpmeYrX w2YeREPnrppk8bnmcvo+o/ySQpeH674YEjpADgjby9nGkBpXaqR9IEDJ4c/2/QEAJ6UoOLWRo4MJN awr4vLeQq+MbKIAg9LJoLMVHZxjjDZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qW1K0-002Vpg-1F; Tue, 15 Aug 2023 21:11:24 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qW1Jw-002Vmz-0n for linux-arm-kernel@lists.infradead.org; Tue, 15 Aug 2023 21:11:21 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58c8cbf0a0dso1331857b3.1 for ; Tue, 15 Aug 2023 14:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692133875; x=1692738675; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=3y6Izf6PWqeRPwTjJUSGtpHjQ5Xbrf4Hr6LZlxEahOk=; b=DEykWB4VPD0KGwkR1rgTEkxuGrmyMbRmPDZOUHEnPXwFaHI3rUqsojcqqySGFoopGa qtooGMRnC2iBatnU5WIMN05g0vZUnhEdJZVjk4lw6MaKHZj3uELr1pxCP5/hsgTqIrBu 1inqQgqIJZJ0VlbPAJIpm9/aWo9WsTqBaNDDVihJxzTBMBNgex/TOLHB2mYmoJOp1Kva bWeQr8NZbtkqjwq7mvqMAtaqjcOqkVBp/oDMzrZX7hqKYwQW4a6d2vnhTsoUk3GQCY2x 1lnjzzGiQr7G4wgDP1gxwsyDXBuhUnF7eiCe83f1an5ltuLTmcDWNx/do1f/T7qdFpLb btCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692133875; x=1692738675; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3y6Izf6PWqeRPwTjJUSGtpHjQ5Xbrf4Hr6LZlxEahOk=; b=ettb+pS3ON3QCBNmVmhK9p0ZWS+/NCNELBPeCdg7ruOcQdylhfD2LpWUrj9TYeHN6T ALtkTFE83AwQYvM4a8A68GOvga6xTXL0Bz6ZQ4CkWJIDb4dCHjS2Yub7gtkr0NY8SeMq tTu0OlXDnpubKw7aVkmQ1Q+iAPNpcKk04TmYNP4xlfqT91re8we3c0HeaHLYSdtH3gGr Prc/FePE1JfjKGWWozEMlZUeJbkI17SK2zQiHGgx6AQfggrR4t24k++ZqoA7hfPGqlw8 0MalT8njhUNFS7q7mIkMBvyObmuXTimOU4cboWPJ0+CiN6k6gDh5Fk0Ug1j7PTdWWQZL cImw== X-Gm-Message-State: AOJu0YyBUg1YCkbot6bD6TNF1aFIhq7bvgvPjkY4F8fFZQ7bwPZIxnqM 4tB3010bpaazFG9OnVRTGFTUrOZHmfat03htFg== X-Google-Smtp-Source: AGHT+IESHOcNCiS8o17qcx7V9DnY9/u5Ejmnxug8PTEedCECk+Qy3ouUC8CMmwLN9yzo20in9nO1So2V6LKsvaBvXA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6902:1818:b0:d08:95:76d with SMTP id cf24-20020a056902181800b00d080095076dmr2170ybb.6.1692133875480; Tue, 15 Aug 2023 14:11:15 -0700 (PDT) Date: Tue, 15 Aug 2023 21:11:12 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAO/p22QC/x2NQQrDMAwEvxJ0rsB2aVP6ldKDqeRG0CRGCibB5 O9xepuZw24FYxU2eHYVlIuYzFMTf+ngM8TpyyjUHIILV/fwNyyzEJJKYTUcF8IxZsM8bNYAzxo X+TGG0LvEfaLk79DWsnKS9f/0eu/7AWJszKR5AAAA X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1692133874; l=1857; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=HWSTPugX/6hl45mOi43ekrd154LFJ7mP03sqOaFNygg=; b=mUKhNFxwaMYAvGE8r2mEXisjetzD1WuRCSRRz8uhoZeTBBafOwti17CqjOH6uuGZ7lX7yJ56h SfAxWxpgjWqCv3/V5qSm4hMKInmpums0ZWkx3xU6Pf+KbCoMPqB90qI X-Mailer: b4 0.12.3 Message-ID: <20230815-void-drivers-mtd-maps-physmap-versatile-v1-1-ba6fc86d5e4e@google.com> Subject: [PATCH] mtd: maps: fix -Wvoid-pointer-to-enum-cast warning From: Justin Stitt To: Linus Walleij , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Justin Stitt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_141120_306319_8CD5B15D X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When building with clang 18 I see the following warning: | drivers/mtd/maps/physmap-versatile.c:209:25: warning: cast to smaller | integer type 'enum versatile_flashprot' from 'const void *' [-Wvoid-pointer-to-enum-cast] | 209 | versatile_flashprot = (enum versatile_flashprot)devid->data; This is due to the fact that `devid->data` is a void* while `enum versatile_flashprot` has the size of an int. This leads to truncation and possible data loss. Link: https://github.com/ClangBuiltLinux/linux/issues/1910 Reported-by: Nathan Chancellor Signed-off-by: Justin Stitt --- Note: There is likely no data loss occurring here due to the fact that `enum versatile_flashprot` has only a few enumerated fields, none of which are large enough to cause data loss. Nonetheless, this patch helps towards the goal of eventually enabling this warning for more builds. Signed-off-by: Justin Stitt --- drivers/mtd/maps/physmap-versatile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421 change-id: 20230815-void-drivers-mtd-maps-physmap-versatile-2270fe7fdf16 Best regards, -- Justin Stitt diff --git a/drivers/mtd/maps/physmap-versatile.c b/drivers/mtd/maps/physmap-versatile.c index a1b8b7b25f88..d65cf8833771 100644 --- a/drivers/mtd/maps/physmap-versatile.c +++ b/drivers/mtd/maps/physmap-versatile.c @@ -206,7 +206,7 @@ int of_flash_probe_versatile(struct platform_device *pdev, if (!sysnp) return -ENODEV; - versatile_flashprot = (enum versatile_flashprot)devid->data; + versatile_flashprot = (uintptr_t)devid->data; rmap = syscon_node_to_regmap(sysnp); of_node_put(sysnp); if (IS_ERR(rmap))