Hello *,

On Mon, 24 Feb 2025 10:22:35 +0100, Peter Seiderer <ps.rep...@gmx.net> 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.rep...@gmx.net>

Actual missing the rev-by Simon Horman given for the v5 version of the
patch set (see [1]) and indicated in the change description v5->v6...

Regards,
Peter

[1] https://lore.kernel.org/netdev/20250216135748.gd1615...@kernel.org/

> ---
> Changes v6 -> v7
>   - rebased on actual net-next/main
>   - no changes
>
> Changes v5 -> v6
>   - adjust to dropped patch ''net: pktgen: use defines for the various
>     dec/hex number parsing digits lengths'
>   - add rev-by Simon Horman
>   - fix line break (suggested by Simon Horman)
>
> 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()')
> ---
>  net/core/pktgen.c | 38 ++++++++++++++++++++------------------
>  1 file changed, 20 insertions(+), 18 deletions(-)
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 55064713223e..cd6b6c0dc0dc 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -746,10 +746,11 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
>  }
>
>
> -static int hex32_arg(const char __user *user_buffer, unsigned long maxlen,
> -                  __u32 *num)
> +static ssize_t hex32_arg(const char __user *user_buffer, size_t maxlen,
> +                      __u32 *num)
>  {
> -     int i = 0;
> +     size_t i = 0;
> +
>       *num = 0;
>
>       for (; i < maxlen; i++) {
> @@ -768,10 +769,9 @@ 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)
>  {
> -     int i;
> +     size_t i;
>
>       for (i = 0; i < maxlen; i++) {
>               char c;
> @@ -793,10 +793,10 @@ static int count_trail_chars(const char __user * 
> user_buffer,
>       return i;
>  }
>
> -static long num_arg(const char __user *user_buffer, unsigned long maxlen,
> -                             unsigned long *num)
> +static ssize_t num_arg(const char __user *user_buffer, size_t maxlen,
> +                    unsigned long *num)
>  {
> -     int i;
> +     size_t i;
>       *num = 0;
>
>       for (i = 0; i < maxlen; i++) {
> @@ -812,9 +812,9 @@ static long num_arg(const char __user *user_buffer, 
> unsigned long maxlen,
>       return i;
>  }
>
> -static int strn_len(const char __user * user_buffer, unsigned int maxlen)
> +static ssize_t strn_len(const char __user *user_buffer, size_t maxlen)
>  {
> -     int i;
> +     size_t i;
>
>       for (i = 0; i < maxlen; i++) {
>               char c;
> @@ -844,9 +844,9 @@ static int strn_len(const char __user * user_buffer, 
> unsigned int maxlen)
>  static ssize_t get_imix_entries(const char __user *buffer,
>                               struct pktgen_dev *pkt_dev)
>  {
> -     const int max_digits = 10;
> -     int i = 0;
> -     long len;
> +     const size_t max_digits = 10;
> +     size_t i = 0;
> +     ssize_t len;
>       char c;
>
>       pkt_dev->n_imix_entries = 0;
> @@ -895,9 +895,9 @@ static ssize_t get_imix_entries(const char __user *buffer,
>  static ssize_t get_labels(const char __user *buffer, struct pktgen_dev 
> *pkt_dev)
>  {
>       unsigned int n = 0;
> +     size_t i = 0;
> +     ssize_t len;
>       char c;
> -     ssize_t i = 0;
> -     int len;
>
>       pkt_dev->nr_labels = 0;
>       do {
> @@ -956,7 +956,8 @@ static ssize_t pktgen_if_write(struct file *file,
>  {
>       struct seq_file *seq = file->private_data;
>       struct pktgen_dev *pkt_dev = seq->private;
> -     int i, max, len;
> +     size_t i, max;
> +     ssize_t len;
>       char name[16], valstr[32];
>       unsigned long value = 0;
>       char *pg_result = NULL;
> @@ -1883,7 +1884,8 @@ static ssize_t pktgen_thread_write(struct file *file,
>  {
>       struct seq_file *seq = file->private_data;
>       struct pktgen_thread *t = seq->private;
> -     int i, max, len, ret;
> +     size_t i, max;
> +     ssize_t len, ret;
>       char name[40];
>       char *pg_result;
>


Reply via email to