[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190815.163648.1684648819390926444.davem@davemloft.net>
Date: Thu, 15 Aug 2019 16:36:48 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: sr@...x.de
Cc: netdev@...r.kernel.org, opensource@...rst.com,
daniel@...rotopia.org, sean.wang@...iatek.com, john@...ozen.org
Subject: Re: [PATCH net-next 4/4 v2] net: ethernet: mediatek: Add MT7628/88
SoC support
From: Stefan Roese <sr@...x.de>
Date: Wed, 14 Aug 2019 13:18:25 +0200
> +static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma)
> +{
> + return ((u32)dma - (u32)ring->dma) / sizeof(*dma);
> +}
This will definitely warn on 64-bit, and you should avoid that even if this
driver can not possibly be built on 64-bit platforms.
You cannot truncate a pointer to an integer which is potentially smaller
in representation size than a pointer could potentially be.
Just can avoid all of these issues by using real pointer arithmetic and
casting to (char *), or even better, (void *).
Powered by blists - more mailing lists