From patchwork Mon Aug 14 22:21:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13353376 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 9CB5DC001B0 for ; Mon, 14 Aug 2023 22:22:27 +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=lS2o7PZ8pQeLK3zRRwXebWiqWq7vBeVZ7ZJ9cfXuSSY=; b=3Ek lQzWbor/xa5RWVV94X39m+U4me7dB3xwPHanulnNbOij5cHEHoYV5LDOnyHX1fMe7uWWR51X43efw 6V6RCXa9s4m40PZThzHPI844kHHn4lF67WBSiyX4xRss9LxzCIq6eFIQHqO/eyjIk4FmdmGvJl8yJ 1zJ1OblNsBqrgs2T2XnlDGPkYgJHjqk3i+OjKn+nBSAtmh7FlIWMLM39gSeDI8WsZ4WPqg7DvHLIs zS8SNa8dtzJcMEPlCafPI5bFIpgBmoETwzmSzA5fZYanP/9KgVmBD93+chdtoxPr07i95ElrF23ir BytbQF56/8NiVomI0ASAe/GEK5NTatg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVfwj-000S1h-2x; Mon, 14 Aug 2023 22:21:57 +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 1qVfwh-000S0s-1c for linux-arm-kernel@lists.infradead.org; Mon, 14 Aug 2023 22:21:57 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-586a5ac5c29so64309957b3.1 for ; Mon, 14 Aug 2023 15:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692051712; x=1692656512; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=RTWgDCbnFUgO1HWtlSj6vfjNh6uEFztFcnKIx6cL6BQ=; b=aW5BiVb0BJerVlOUuQqirDiDzgsZOv/UGtud9s1nPzNjzQMSVCZIWC96olVT8c4dzb LkNm1Un2nV5Eah5qtCvSQVtmzHVOjS51wtSCIMrXGor5zQ1o9c/H3Ldi2GRceNBh1hik /pffbkFEpqrhPoGr/TaKHqfeMWiBn18IrUyykEXvELpcY68P3h6/xa89ub5eRoXX9TpA KRX1oqhdxs3AAMAlBDwuwJlLp6Dy0qQi9PU9YFwrhAtUypZpLSYkl+UrwbWV8tdxbK6E fY4aALzUB3BTpApo6XaeosKZjR8+dahf5ULD575DA7OnVPMJlf/WRyCYYENFCFrjNL1d 2G9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692051712; x=1692656512; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RTWgDCbnFUgO1HWtlSj6vfjNh6uEFztFcnKIx6cL6BQ=; b=Tym1KccB6whdWkDY679jfGuVaicrK03u0YMsS9e0mB9mrnBMSaLH4gGxCFLJLW3W/B 7YUzNamuXzeCa0z+Fn3WcheaVxotAwpCfrgNTqbABUnAV/N/sJv/Ch2rSrmU8aw44JsH 1Tx28l1iRHXCKgTh1oFdbdAyDiDcVmTuA7XgQx2UIEd+DKi922Pj4rEqZO1zMaEwLKvT eGllhKs8KaWTVzjUuHhLsEydzdA/ILDAvMmXPzfzRnRv6qAFz7Rkk7YMpuso+NA/wBL7 jtrqLGn/2MXPsmEduaHbeaJ7air9aBzCaSLVfFD/eEYHa6ee9C8IkPlFFoE+DpzcYBN1 nreQ== X-Gm-Message-State: AOJu0YzQFZ5ceyFCW4nwM/LgPNI9eZc4gz4jw+mlgmXQSc6jsDCFiDIO FPg8NMCtlKDh/vb2VfwzyojxpFBj2UzceUsdLA== X-Google-Smtp-Source: AGHT+IGUgCbq7vkRnFlWVMmgA0rhj2KZXb4OGaK48ZEofd8nevbwEQv6l0sLR8RgIqA4jQWqYXPdgCPYAfJ7Gpvt3g== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a81:ae65:0:b0:56f:f62b:7a11 with SMTP id g37-20020a81ae65000000b0056ff62b7a11mr149484ywk.8.1692051712685; Mon, 14 Aug 2023 15:21:52 -0700 (PDT) Date: Mon, 14 Aug 2023 22:21:51 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAP6o2mQC/y2NwQqDQAxEf0VybsDdSl38ldKD7CY1F1cS2Qriv zeU3ubNg5kTjFTIYOpOUGpiUleHcOsgL/P6JpTiDLGP9z6FAVuVgkWlkRpu9UOKSkY7Njo2T/+ yMmOex0ccUsocGHzQNcvxO3u+rusLXOcftHwAAAA= X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1692051711; l=1670; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=mDCmp0Hqg8EtlQGDIRB0W9nWt/W1QOLsyus7HkWaU74=; b=tywnHn/ERnLM9VIFtrhcr3oDmTExX8AP4yrHSMg6fIibovmNBnUJxcxLIW2tk1NeK0mKTMw23 5cQft0dFY2NCIrWine0ndcJlpEkG6vXZKKtD0o/ILix3ztfjyGjRaON X-Mailer: b4 0.12.3 Message-ID: <20230814-void-drivers-power-reset-vexpress-poweroff-v1-1-c3d9b0107e5d@google.com> Subject: [PATCH] power: vexpress: fix -Wvoid-pointer-to-enum-cast warning From: Justin Stitt To: Sebastian Reichel , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-pm@vger.kernel.org, linux-arm-kernel@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-20230814_152155_539278_683CF5F3 X-CRM114-Status: GOOD ( 13.24 ) 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/power/reset/vexpress-poweroff.c:124:10: warning: cast to smaller integer type 'enum vexpress_reset_func' from 'const void *' [-Wvoid-pointer-to-enum-cast] | 124 | switch ((enum vexpress_reset_func)match->data) { This is due to the fact that `match->data` is a void* while `enum vexpress_reset_func` 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 Acked-by: Sudeep Holla --- Note: In this case, it seems unlikely that any data loss is occurring since `enum vexpress_reset_func` only has a few fields enumerated from 0. --- drivers/power/reset/vexpress-poweroff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421 change-id: 20230814-void-drivers-power-reset-vexpress-poweroff-ca762488cf1f Best regards, -- Justin Stitt diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 447ffdacddf9..17064d7b19f6 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -121,7 +121,7 @@ static int vexpress_reset_probe(struct platform_device *pdev) return PTR_ERR(regmap); dev_set_drvdata(&pdev->dev, regmap); - switch ((enum vexpress_reset_func)match->data) { + switch ((uintptr_t)match->data) { case FUNC_SHUTDOWN: vexpress_power_off_device = &pdev->dev; pm_power_off = vexpress_power_off;