Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp543246lqo; Wed, 8 May 2024 07:38:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDv0T07pl63uB/ewIz8KdDL2KNa4V6MkVM9jrm9STVcthBFhRdkMY5JAAD0LEk7FUjQ0PS3Q+yQVDjXT1R8lG/OQOcodkuFfNIaNFxTQ== X-Google-Smtp-Source: AGHT+IEMySScPK1z2TqwzmFpmIGdRfzIA/oAaV4V5tPoYQOiLgRIOMANhYeCsE7RkGGk/f0+GKOk X-Received: by 2002:ac8:7f16:0:b0:43a:f577:ea11 with SMTP id d75a77b69052e-43dbf3da66bmr31560991cf.25.1715179108571; Wed, 08 May 2024 07:38:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715179108; cv=pass; d=google.com; s=arc-20160816; b=iUOqqOwYohNdmE0flRw1ZK80JWLrMd7MsPgHNRAZtAjC6LDdVH6uw+9DGILs/QZD9G rKWxHI5iIlvGvK0e6EzJtSc1XVpDQvhL1QNDGQhXYVJ93c6eO4fisORWNebw0Gdto73A GlmasWqzUxOHUcuqXWn4ptO6NeAJEwNoAGCSW4ygNtio7RyWX5CLOGoc+zg7GqUsS7ml HTcEq+U2dzOw1ng+FM6ZHM+MpRL2pJbQ8T05PpsS35sIktwjZYOvlLQyk2WsLVFi7BUF KjUDJTBGvHM898U/IF1A2UC56gRGJCNzG0a1M2RVg+7PrGB1F/iMt16GKSwUxdckyNZe 1djg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=siRVx/snUNjFKCrOeXvo0bmHNPIKe0N1mufovHth3gA=; fh=smGGFd0om1nHV06S9f0UtWcA937lJWB6dHMjNLCWXUM=; b=fvqSGjkRmg1ITlJamMG/BDtC4mdLFmhndJw6RoV56EJ0N2bxsXa1tueTU1Ksear3Hv +wDu18mWZ/uhsqltUON+DTcFwACFY6Me150jfEIcH02U48BZuKMHlVnPWqsgyVhLt069 s8woc8Uyu0/e2oQqQGytr2rC2F6ytdXwplxzzD6xavbiREWB8DCETZ6ZmU9Dysdjn6nw RONj8VEglmhfPY+6sWNNUz5ToLWbED5/uJVTJke02M8Fw8t0vLVktQ5DRDsBvezhktcp FaJW+U8+NDrBJkpugjnED6ibY5qgqc1vuUkX2CmGuLmQYU1SOVJD3nbHGdcuZRUVPYlA H3jQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tk+36egP; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-173416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v12-20020ac8578c000000b0043a904e3a55si14620240qta.85.2024.05.08.07.38.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 07:38:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tk+36egP; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-173416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C6A01C240F7 for ; Wed, 8 May 2024 14:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75D908625B; Wed, 8 May 2024 14:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Tk+36egP" Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0696D12FF99 for ; Wed, 8 May 2024 14:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715178886; cv=none; b=uK+IqUDcSBPlQDxtFtGKHGXHndU9BtcylMk+kGficuNqQ56cerhwLUPAW3PH6TTyvUXdgsKCwrd/eNlgU/TwtGnYvlWHdwV8TuMs2+m7XW6feHsmV9wE+9prpqKTlINEEpgESf/nIhtu/0Hh1TQ0C5w6F47y+uZAYRxV6QapjVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715178886; c=relaxed/simple; bh=yDTHGWifoYnCGHAM/Y88fZXygAlEP5oTp5WSlDuAQIE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IppcFwpcAw+Ap+CrNoQno9vgmBBsR0sePKYcy4mZS5mBoohNtoJoMPfxf8STYVIFRUifyrjlgohgZOPHhT3gZGAbrTIKLEyXbuAFRTWPeuvKGJJ0LZU2pBF7H1TlNSqNvYIZaKg6Atpx6bsR5CcJXP2LotqeTkO+U5FbZIV64Mk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Tk+36egP; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3c989d4e838so318992b6e.1 for ; Wed, 08 May 2024 07:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715178884; x=1715783684; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=siRVx/snUNjFKCrOeXvo0bmHNPIKe0N1mufovHth3gA=; b=Tk+36egPwrdCTfCWyCWZ2q38hd4CFboyCElCt8hTcaiwWCnrbhuVJAKcutD99x4bcS dSzPAYVoJO4z7W1YPIMmcoPw4+xxXXgj8GVM8RIu/bkyVKdLIX3btfwDrfreo4s44Ieq eeWYL+UTH9hS7kGDSiu4k+DyLk4dq08wKANf1lLxQa5MVwp4wXfc2eHWDOyTnM4KnMFa GO1H3NOpK13Ovaa82aEThPOZP8MTpLLF5IM7/XdMc1VhZYHiAzuwMOWCA/R4cWMmMu0p Qx18wJJn0i6F6/Y5fJuzwi46O0L0Zw5UdcLZKxI0ReZaexk94qSxmouigld4P7lUiuE7 Z2dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715178884; x=1715783684; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=siRVx/snUNjFKCrOeXvo0bmHNPIKe0N1mufovHth3gA=; b=P6WubIHucvPV99shvAJ13TgGgwepkQBo0HBEfQYk7rNFlOZZXrdi0mh+qcMJUxWsq9 tUeSfNsC89EBkzhfJYqi5U/9Gl7t6x1QIlYjySbnBRygmn/vu/zP63caf1GACvpJyKqQ iv0fQhnQByJJG9SfUEwZYMNngCHsOOSYhnnUVGOKEjvNhOe4UebAOj6tRcq3fOfCtTYt vDhwdTnqEjJkGcMhNDMwew5DyPjRWH7i09mjPxia/CrTZqmFygzp+Y6QWtRqeVFn/Y98 bdlk64f5mtExUjqDeLHCSeeWYzrras588FerdJ5tORVeET00vXDi/lWC1IgxFkSXKuSe vwBg== X-Forwarded-Encrypted: i=1; AJvYcCUIqRFUU0NFF3UD77CWVxG3I/rTPA2rRYO1fd7wmU0Ldh4xhS3fsfX6rGvqaAjtJdEDeant/jk553xWl3A4UOsvv8ZGsBzxDtxqVBVS X-Gm-Message-State: AOJu0YzG/yiWqxKijMV2LiLWP9BMHpclKrtUQv6/P5aSWpGzU6wgEH3u aiPXWr0cqW5AnlnDNpVKKtO92JiJgxnIk6wHk9g0LGZuHPRht7emClQOXjrnczbe8OwAFEeI7iL uVMttaQ2MrRAAHuFcScfWtHzpuSl/wvWXrA7AOA== X-Received: by 2002:a05:6808:124e:b0:3c9:73a2:6862 with SMTP id 5614622812f47-3c9852c5e01mr3076178b6e.31.1715178884096; Wed, 08 May 2024 07:34:44 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503075619.394467-1-mpe@ellerman.id.au> In-Reply-To: <20240503075619.394467-1-mpe@ellerman.id.au> From: Naresh Kamboju Date: Wed, 8 May 2024 20:04:31 +0530 Message-ID: Subject: Re: [PATCH v2 1/2] powerpc/io: Avoid clang null pointer arithmetic warnings To: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, arnd@arndb.de, linux-kernel@vger.kernel.org, nathan@kernel.org Content-Type: text/plain; charset="UTF-8" On Fri, 3 May 2024 at 13:26, Michael Ellerman wrote: > > With -Wextra clang warns about pointer arithmetic using a null pointer. > When building with CONFIG_PCI=n, that triggers a warning in the IO > accessors, eg: > > In file included from linux/arch/powerpc/include/asm/io.h:672: > linux/arch/powerpc/include/asm/io-defs.h:23:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > 23 | DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port), pio, port) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ... > linux/arch/powerpc/include/asm/io.h:591:53: note: expanded from macro '__do_inb' > 591 | #define __do_inb(port) readb((PCI_IO_ADDR)_IO_BASE + port); > | ~~~~~~~~~~~~~~~~~~~~~ ^ > > That is because when CONFIG_PCI=n, _IO_BASE is defined as 0. > > Although _IO_BASE is defined as plain 0, the cast (PCI_IO_ADDR) converts > it to void * before the addition with port happens. > > Instead the addition can be done first, and then the cast. The resulting > value will be the same, but avoids the warning, and also avoids void > pointer arithmetic which is apparently non-standard. > > Reported-by: Naresh Kamboju > Closes: https://lore.kernel.org/all/CA+G9fYtEh8zmq8k8wE-8RZwW-Qr927RLTn+KqGnq1F=ptaaNsA@mail.gmail.com > Signed-off-by: Michael Ellerman Tested-by: Linux Kernel Functional Testing -- Linaro LKFT https://lkft.linaro.org