Skip to content

Commit

Permalink
net: pktgen: fix mix of int/long
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Peter Seiderer authored and Paolo Abeni committed Mar 4, 2025
1 parent 05ec5c0 commit 90b856a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,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++) {
Expand All @@ -766,10 +767,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;
Expand All @@ -791,10 +791,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++) {
Expand All @@ -810,9 +810,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;
Expand Down Expand Up @@ -842,9 +842,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;
Expand Down Expand Up @@ -893,9 +893,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 {
Expand Down Expand Up @@ -954,7 +954,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;
Expand Down Expand Up @@ -1881,7 +1882,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;

Expand Down

0 comments on commit 90b856a

Please sign in to comment.