* [PATCH] net/irda/parameters.c: Trivial fixes
@ 2007-11-24 20:44 Richard Knutsson
2007-11-26 9:17 ` Samuel Ortiz
0 siblings, 1 reply; 3+ messages in thread
From: Richard Knutsson @ 2007-11-24 20:44 UTC (permalink / raw)
To: samuel, davem; +Cc: linux-kernel, Richard Knutsson
Make a single va_start() -> va_end() path + fixing:
CHECK /home/kernel/src/net/irda/parameters.c
/home/kernel/src/net/irda/parameters.c:466:2: warning: Using plain integer as NULL pointer
/home/kernel/src/net/irda/parameters.c:520:2: warning: Using plain integer as NULL pointer
/home/kernel/src/net/irda/parameters.c:573:2: warning: Using plain integer as NULL pointer
Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
---
Compile-tested on i386 with allyesconfig and allmodconfig.
diff --git a/net/irda/parameters.c b/net/irda/parameters.c
index 2627dad..bf19071 100644
--- a/net/irda/parameters.c
+++ b/net/irda/parameters.c
@@ -368,10 +368,11 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+ int retval = 0;
va_start(args, fmt);
- for (p = fmt; *p != '\0'; p++) {
+ for (p = fmt; *p != '\0' && retval == 0; p++) {
switch (*p) {
case 'b': /* 8 bits unsigned byte */
buf[n++] = (__u8)va_arg(args, int);
@@ -392,13 +393,12 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
break;
#endif
default:
- va_end(args);
- return -1;
+ retval = -1;
}
}
va_end(args);
- return 0;
+ return retval;
}
EXPORT_SYMBOL(irda_param_pack);
@@ -411,10 +411,11 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+ int retval = 0;
va_start(args, fmt);
- for (p = fmt; *p != '\0'; p++) {
+ for (p = fmt; *p != '\0' && retval == 0; p++) {
switch (*p) {
case 'b': /* 8 bits byte */
arg.ip = va_arg(args, __u32 *);
@@ -436,14 +437,13 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
break;
#endif
default:
- va_end(args);
- return -1;
+ retval = -1;
}
}
va_end(args);
- return 0;
+ return retval;
}
/*
@@ -463,7 +463,7 @@ int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len,
int n = 0;
IRDA_ASSERT(buf != NULL, return ret;);
- IRDA_ASSERT(info != 0, return ret;);
+ IRDA_ASSERT(info != NULL, return ret;);
pi_minor = pi & info->pi_mask;
pi_major = pi >> info->pi_major_offset;
@@ -517,7 +517,7 @@ static int irda_param_extract(void *self, __u8 *buf, int len,
int n = 0;
IRDA_ASSERT(buf != NULL, return ret;);
- IRDA_ASSERT(info != 0, return ret;);
+ IRDA_ASSERT(info != NULL, return ret;);
pi_minor = buf[n] & info->pi_mask;
pi_major = buf[n] >> info->pi_major_offset;
@@ -570,7 +570,7 @@ int irda_param_extract_all(void *self, __u8 *buf, int len,
int n = 0;
IRDA_ASSERT(buf != NULL, return ret;);
- IRDA_ASSERT(info != 0, return ret;);
+ IRDA_ASSERT(info != NULL, return ret;);
/*
* Parse all parameters. Each parameter must be at least two bytes
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net/irda/parameters.c: Trivial fixes
2007-11-26 9:17 ` Samuel Ortiz
@ 2007-11-26 2:59 ` Richard Knutsson
0 siblings, 0 replies; 3+ messages in thread
From: Richard Knutsson @ 2007-11-26 2:59 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: davem, linux-kernel, irda-users
Samuel Ortiz wrote:
> Hi Richard,
>
> On Sat, Nov 24, 2007 at 09:44:05PM +0100, Richard Knutsson wrote:
>
>> Make a single va_start() -> va_end() path + fixing:
>>
> Ok, this should be 2 separate patches then.
>
Thought about it, but they were so simple, I believed they would better
be merged...
> The warning fixes are all good, but I fail to see the point of the va_end()
> one. That doesn't seem to bring any sort of improvement while adding one
> variable to the stack and one loop test. Any explanation here ?
>
Not really. Many seem to like a single return and since this made it one
va_end() to every va_start(), I thought it would be appropriate. But if
not, then I will only filter this hit out from the
va_start()->va_end()-testing and get going.
> I'll push the warning fix for now, thanks.
>
Alright, thank you.
> Cheers,
> Samuel.
>
>
cu
Richard Knutsson
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/irda/parameters.c: Trivial fixes
2007-11-24 20:44 [PATCH] net/irda/parameters.c: Trivial fixes Richard Knutsson
@ 2007-11-26 9:17 ` Samuel Ortiz
2007-11-26 2:59 ` Richard Knutsson
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Ortiz @ 2007-11-26 9:17 UTC (permalink / raw)
To: Richard Knutsson; +Cc: davem, linux-kernel, irda-users
Hi Richard,
On Sat, Nov 24, 2007 at 09:44:05PM +0100, Richard Knutsson wrote:
> Make a single va_start() -> va_end() path + fixing:
Ok, this should be 2 separate patches then.
The warning fixes are all good, but I fail to see the point of the va_end()
one. That doesn't seem to bring any sort of improvement while adding one
variable to the stack and one loop test. Any explanation here ?
I'll push the warning fix for now, thanks.
Cheers,
Samuel.
> CHECK /home/kernel/src/net/irda/parameters.c
> /home/kernel/src/net/irda/parameters.c:466:2: warning: Using plain integer as NULL pointer
> /home/kernel/src/net/irda/parameters.c:520:2: warning: Using plain integer as NULL pointer
> /home/kernel/src/net/irda/parameters.c:573:2: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Richard Knutsson <ricknu-0@student.ltu.se>
> ---
> Compile-tested on i386 with allyesconfig and allmodconfig.
>
>
> diff --git a/net/irda/parameters.c b/net/irda/parameters.c
> index 2627dad..bf19071 100644
> --- a/net/irda/parameters.c
> +++ b/net/irda/parameters.c
> @@ -368,10 +368,11 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
> va_list args;
> char *p;
> int n = 0;
> + int retval = 0;
>
> va_start(args, fmt);
>
> - for (p = fmt; *p != '\0'; p++) {
> + for (p = fmt; *p != '\0' && retval == 0; p++) {
> switch (*p) {
> case 'b': /* 8 bits unsigned byte */
> buf[n++] = (__u8)va_arg(args, int);
> @@ -392,13 +393,12 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
> break;
> #endif
> default:
> - va_end(args);
> - return -1;
> + retval = -1;
> }
> }
> va_end(args);
>
> - return 0;
> + return retval;
> }
> EXPORT_SYMBOL(irda_param_pack);
>
> @@ -411,10 +411,11 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
> va_list args;
> char *p;
> int n = 0;
> + int retval = 0;
>
> va_start(args, fmt);
>
> - for (p = fmt; *p != '\0'; p++) {
> + for (p = fmt; *p != '\0' && retval == 0; p++) {
> switch (*p) {
> case 'b': /* 8 bits byte */
> arg.ip = va_arg(args, __u32 *);
> @@ -436,14 +437,13 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
> break;
> #endif
> default:
> - va_end(args);
> - return -1;
> + retval = -1;
> }
>
> }
> va_end(args);
>
> - return 0;
> + return retval;
> }
>
> /*
> @@ -463,7 +463,7 @@ int irda_param_insert(void *self, __u8 pi, __u8 *buf, int len,
> int n = 0;
>
> IRDA_ASSERT(buf != NULL, return ret;);
> - IRDA_ASSERT(info != 0, return ret;);
> + IRDA_ASSERT(info != NULL, return ret;);
>
> pi_minor = pi & info->pi_mask;
> pi_major = pi >> info->pi_major_offset;
> @@ -517,7 +517,7 @@ static int irda_param_extract(void *self, __u8 *buf, int len,
> int n = 0;
>
> IRDA_ASSERT(buf != NULL, return ret;);
> - IRDA_ASSERT(info != 0, return ret;);
> + IRDA_ASSERT(info != NULL, return ret;);
>
> pi_minor = buf[n] & info->pi_mask;
> pi_major = buf[n] >> info->pi_major_offset;
> @@ -570,7 +570,7 @@ int irda_param_extract_all(void *self, __u8 *buf, int len,
> int n = 0;
>
> IRDA_ASSERT(buf != NULL, return ret;);
> - IRDA_ASSERT(info != 0, return ret;);
> + IRDA_ASSERT(info != NULL, return ret;);
>
> /*
> * Parse all parameters. Each parameter must be at least two bytes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-26 3:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-24 20:44 [PATCH] net/irda/parameters.c: Trivial fixes Richard Knutsson
2007-11-26 9:17 ` Samuel Ortiz
2007-11-26 2:59 ` Richard Knutsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).