[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241003151312.ewo3dpadnjmv3beu@skbuf>
Date: Thu, 3 Oct 2024 18:13:12 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: Jacob Keller <jacob.e.keller@...el.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: Re: [PATCH net-next v2 04/10] lib: packing: add pack() and unpack()
wrappers over packing()
On Wed, Oct 02, 2024 at 02:51:53PM -0700, Jacob Keller wrote:
> From: Vladimir Oltean <vladimir.oltean@....com>
>
> Geert Uytterhoeven described packing() as "really bad API" because of
> not being able to enforce const correctness. The same function is used
> both when "pbuf" is input and "uval" is output, as in the other way
> around.
>
> Create 2 wrapper functions where const correctness can be ensured.
> Do ugly type casts inside, to be able to reuse packing() as currently
> implemented - which will _not_ modify the input argument.
>
> Also, take the opportunity to change the type of startbit and endbit to
> size_t - an unsigned type - in these new function prototypes. When int,
> an extra check for negative values is necessary. Hopefully, when
> packing() goes away completely, that check can be dropped.
>
> My concern is that code which does rely on the conditional directionality
> of packing() is harder to refactor without blowing up in size. So it may
> take a while to completely eliminate packing(). But let's make alternatives
> available for those who do not need that.
>
> Link: https://lore.kernel.org/netdev/20210223112003.2223332-1-geert+renesas@glider.be/
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
> ---
Reviewed-by: Vladimir Oltean <vladimir.oltean@....com>
Powered by blists - more mailing lists