Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1082196pxx; Tue, 27 Oct 2020 07:53:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkokjxpOJ8KI75ekoMFC/KGnIg0wyqXFq4HWmBsNAv7VS/ao9bqmxU58m97KR2atZb6Kfm X-Received: by 2002:aa7:cb1a:: with SMTP id s26mr2635439edt.219.1603810425064; Tue, 27 Oct 2020 07:53:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603810425; cv=none; d=google.com; s=arc-20160816; b=IVH0hTtnT65BTPyJ+2w5KUIP9nCa0270G9wYoxhJMvSk2ydEz7hh7jwINbLEOxtP7x AvnaW2uKBbkElklDhNOC8GvfnYL8VcZOf6PDwQJulHui7AExZlEHm4m13YSmI7FkChNN KK3nKyONn7O/mNL51BrW7T3oljKQSgipQeERfKVtc85Exj/FzvaDl07Ibw0p+Pu7V+jd ZHn/P9yU2vUnpA0+ElK8Jwe8v04Z7U6TKer0pqYSNQstikLqSJfcVc/ET73ihSH9oIbY qQj+zucHRxFSK+oK2lD303RxXpNIX8yx27LQ2bdxB2o2p5yUejNfwyHveDWTgNOdiUYc +utg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4EFLj/J1EJj39vih/eBzcfDmNN3V792Qx1rI7lakAJ0=; b=wm+ets+rqCxSVTAdBfhliWApbRf2Ekc0DTqs01x+LyXNUw8uTe2whuWnenEU7ZLZkg OlN2b4SSW4GlMifzeYVGclMgfbuLPoQ3LC6FIyAgzeoG4rBIpqHKZ93zok10TKo0C7TH RwRtnMsYvAQ4q3zPWYWG+n8eTpEDfg6U92OZHoDGk3bOwDqgly/p0HDoLD2FB/4R0fvr GU6066PbfgQ/uPZ/fdxfOWk3PEkHrmleN1tiqYIVcu4ipP6+N/geQJzNlj71C0EWp4ZJ W704hKPe3j4crFdEhcJ29Q7dsduFKnx5ZTa8ujaJA0A8Cvn8/KDRiygXN0lcGUZy4/fI E3xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HwuK+hsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ny22si1125161ejb.518.2020.10.27.07.53.23; Tue, 27 Oct 2020 07:53:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HwuK+hsJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbgJ0NYG (ORCPT + 99 others); Tue, 27 Oct 2020 09:24:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:33586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752084AbgJ0NYE (ORCPT ); Tue, 27 Oct 2020 09:24:04 -0400 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9DB4420878; Tue, 27 Oct 2020 13:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603805043; bh=PECefxcOMLV7c0hbn8cf+aIW/r03dKBQ9nlsRb5VdDs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HwuK+hsJVCPMgJJnDVgBSy8reRpMrmqfsm9gO5+fbKq6F2XSpBQSROVY3juBqE4Nu H5Yst+NRh57BsdJz98NHJCoNBp87/Qn0YRuoRJC+edQJNMpnwjSYZD1XNb61xd/4R8 NoOIHVXudUnL6JZ2eLTaTsIIIK+wa/E51N7WHr24= Received: by mail-qv1-f48.google.com with SMTP id s17so598765qvr.11; Tue, 27 Oct 2020 06:24:03 -0700 (PDT) X-Gm-Message-State: AOAM530Xwk6peIpP4HoI7x/ahCRJAOZPJ3Ow9zFDP1jqs0hxPVlCMI+d EGlQFMban8fXlYET2laLcEagwTqPE50QrcIjjcE= X-Received: by 2002:a0c:c187:: with SMTP id n7mr2303412qvh.19.1603805042676; Tue, 27 Oct 2020 06:24:02 -0700 (PDT) MIME-Version: 1.0 References: <20201026213040.3889546-1-arnd@kernel.org> <20201027035558.16864-1-xie.he.0141@gmail.com> In-Reply-To: From: Arnd Bergmann Date: Tue, 27 Oct 2020 14:23:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning To: Xie He Cc: Chas Williams <3chas3@gmail.com>, Nathan Chancellor , Nick Desaulniers , "David S. Miller" , linux-atm-general@lists.sourceforge.net, Linux Kernel Network Developers , LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 27, 2020 at 5:02 AM Xie He wrote: > > On Mon, Oct 26, 2020 at 8:56 PM Xie He wrote: > > > > > - for (mem = (HDW *) memmap; mem < (HDW *) (memmap + 1); ++mem) > > > + for (mem = (HDW *) memmap; mem < (HDW *) ((uintptr_t)memmap + 1); ++mem) > > > > Note that these two lines are semantically different. In the first line, > > "+ 1" moves the pointer by (sizeof memmap) bytes. However in the second > > line, "+ 1" moves the pointer by only 1 byte. > > Correction: in the first line "+ 1" moves the pointer by (sizeof *memmap) bytes. Ah, of course. I had looked up the types but mixed up the memmap and HDW definitions, but then got confused trying to understand the logic in wr_mem() that operates on bytes but expands them into multiples of 4. I've modified it as below now, will resend along with the other patches if you think this makes sense. Arnd --- a/drivers/atm/horizon.c +++ b/drivers/atm/horizon.c @@ -1815,7 +1815,7 @@ static int hrz_init(hrz_dev *dev) int buff_count; - HDW * mem; + uintptr_t offset; cell_buf * tx_desc; cell_buf * rx_desc; @@ -1841,8 +1841,8 @@ static int hrz_init(hrz_dev *dev) printk (" clearing memory"); - for (mem = (HDW *) memmap; mem < (HDW *) (memmap + 1); ++mem) - wr_mem (dev, mem, 0); + for (offset = 0; offset < sizeof(struct MEMMAP); offset++) + wr_mem (dev, (HDW *)offset, 0); printk (" tx channels");