All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "John W. Linville" <linville@tuxdriver.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 6/6] staging: rtl8192u: re-use string_escape_mem()
Date: Wed,  2 Jul 2014 16:20:29 +0300	[thread overview]
Message-ID: <1404307229-19186-7-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1404307229-19186-1-git-send-email-andriy.shevchenko@linux.intel.com>

Let's use kernel's library function to escape a buffer instead of custom code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 1040bab..bb5f604 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -31,6 +31,7 @@
 #include <linux/sched.h>
 #include <linux/semaphore.h>
 #include <linux/interrupt.h>
+#include <linux/string_helpers.h>
 
 #include <linux/delay.h>
 #include <linux/wireless.h>
@@ -2576,7 +2577,6 @@ static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
 
 static inline const char *escape_essid(const char *essid, u8 essid_len) {
 	static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
-	const char *s = essid;
 	char *d = escaped;
 
 	if (ieee80211_is_empty_essid(essid, essid_len)) {
@@ -2585,15 +2585,8 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) {
 	}
 
 	essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
-	while (essid_len--) {
-		if (*s == '\0') {
-			*d++ = '\\';
-			*d++ = '0';
-			s++;
-		} else {
-			*d++ = *s++;
-		}
-	}
+	d += string_escape_mem(essid, essid_len, escaped, sizeof(escaped) - 1,
+			       ESCAPE_NULL, NULL);
 	*d = '\0';
 	return escaped;
 }
-- 
2.0.0


      parent reply	other threads:[~2014-07-02 13:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02 13:20 [PATCH 0/6] lib / string_helpers: introduce string_escape_mem Andy Shevchenko
2014-07-02 13:20 ` [PATCH 1/6] lib / string_helpers: clean up test suite Andy Shevchenko
2014-07-02 21:54   ` Andrew Morton
2014-07-03  9:34     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 2/6] lib / string_helpers: introduce string_escape_mem() Andy Shevchenko
2014-07-02 22:01   ` Andrew Morton
2014-07-03  9:53     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 3/6] lib80211: re-use string_escape_mem_any_np() Andy Shevchenko
2014-07-02 13:43   ` Joe Perches
2014-07-02 14:06     ` Andy Shevchenko
2014-07-02 16:30       ` Joe Perches
2014-07-03 10:49         ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 4/6] staging: wlan-ng: re-use string_escape_mem() Andy Shevchenko
2014-07-02 13:20 ` [PATCH 5/6] staging: rtl8192e: " Andy Shevchenko
2014-07-02 13:35   ` Joe Perches
2014-07-02 14:11     ` Andy Shevchenko
2014-07-02 13:20 ` Andy Shevchenko [this message]

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=1404307229-19186-7-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.