aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/packing_test.c
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2024-10-02 14:51:53 -0700
committerJakub Kicinski <kuba@kernel.org>2024-10-03 15:32:04 -0700
commit7263f64e16d90ded44ce211381b2def83db32fd9 (patch)
tree589cfefc8d36ede3a731bd7a4256fe32aab70184 /lib/packing_test.c
parentlib: packing: remove kernel-doc from header file (diff)
downloadwireguard-linux-7263f64e16d90ded44ce211381b2def83db32fd9.tar.xz
wireguard-linux-7263f64e16d90ded44ce211381b2def83db32fd9.zip
lib: packing: add pack() and unpack() wrappers over packing()
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@nxp.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20241002-packing-kunit-tests-and-split-pack-unpack-v2-4-8373e551eae3@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'lib/packing_test.c')
0 files changed, 0 insertions, 0 deletions