public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: samuel@sortiz.org, davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, Richard Knutsson <ricknu-0@student.ltu.se>
Subject: [PATCH] net/irda/parameters.c: Trivial fixes
Date: Sat, 24 Nov 2007 21:44:05 +0100 (MET)	[thread overview]
Message-ID: <20071124203232.6370.65534.sendpatchset@thinktank.campus.ltu.se> (raw)

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

             reply	other threads:[~2007-11-24 20:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-24 20:44 Richard Knutsson [this message]
2007-11-26  9:17 ` [PATCH] net/irda/parameters.c: Trivial fixes Samuel Ortiz
2007-11-26  2:59   ` Richard Knutsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071124203232.6370.65534.sendpatchset@thinktank.campus.ltu.se \
    --to=ricknu-0@student.ltu.se \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel@sortiz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox