On Thu, Feb 13, 2025 at 12:19:13PM +0100, Peter Seiderer wrote:
Fix mix of int/long (and multiple conversion from/to) by using consequently size_t for i and max and ssize_t for len and adjust function signatures of hex32_arg(), count_trail_chars(), num_arg() and strn_len() accordingly.
Signed-off-by: Peter Seiderer ps.report@gmx.net
Changes v4 -> v5
- split up patchset into part i/ii (suggested by Simon Horman)
- instead of align to most common pattern (int) adjust all usages to size_t for i and max and ssize_t for len and adjust function signatures of hex32_arg(), count_trail_chars(), num_arg() and strn_len() accordingly
- respect reverse xmas tree order for local variable declarations (where possible without too much code churn)
- update subject line and patch description
- fix checkpatch warning '"foo * bar" should be "foo *bar"' for count_trail_chars() and strn_len()
Changes v3 -> v4
- new patch (factored out of patch 'net: pktgen: fix access outside of user given buffer in pktgen_if_write()')
Thanks Peter,
A minor nit below, but this looks good to me.
Reviewed-by: Simon Horman horms@kernel.org
...
@@ -777,10 +778,10 @@ static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, return i; } -static int count_trail_chars(const char __user * user_buffer,
unsigned int maxlen)
+static ssize_t count_trail_chars(const char __user *user_buffer,
size_t maxlen)
nit. as there will be a v2 anyway: the above can fit on one line.
{
- int i;
- size_t i;
for (i = 0; i < maxlen; i++) { char c;