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>,
Joe Perches <joe@perches.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 10/10] staging: rtl8192u: use %*pEn to escape buffer
Date: Mon, 7 Jul 2014 18:21:52 +0300 [thread overview]
Message-ID: <1404746512-12749-11-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1404746512-12749-1-git-send-email-andriy.shevchenko@linux.intel.com>
Let's use kernel's native specifier to escape a buffer.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/staging/rtl8192u/ieee80211/ieee80211.h | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 1040bab..1a265f9 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -2576,25 +2576,13 @@ 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)) {
memcpy(escaped, "<hidden>", sizeof("<hidden>"));
return escaped;
}
- essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
- while (essid_len--) {
- if (*s == '\0') {
- *d++ = '\\';
- *d++ = '0';
- s++;
- } else {
- *d++ = *s++;
- }
- }
- *d = '\0';
+ snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
return escaped;
}
--
2.0.1
prev parent reply other threads:[~2014-07-07 15:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 15:21 [PATCH v2 00/10] lib: introduce string_escape_mem an %*pE specifier Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 01/10] lib / string_helpers: move documentation to c-file Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 02/10] lib / string_helpers: refactoring the test suite Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 03/10] lib / string_helpers: introduce string_escape_mem() Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 04/10] lib/vsprintf: add %*pE[achnops] format specifier Andy Shevchenko
2014-07-07 16:25 ` Joe Perches
2014-07-08 8:50 ` Andy Shevchenko
2014-07-07 16:50 ` Joe Perches
2014-07-08 8:24 ` Andy Shevchenko
2014-07-08 16:35 ` Joe Perches
2014-07-07 15:21 ` [PATCH v2 05/10] wireless: libertas: print esaped string via %*pE Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 06/10] wireless: ipw2x00: print SSID " Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 07/10] lib80211: remove unused print_ssid() Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 08/10] staging: wlan-ng: use %*pEhp to print SN Andy Shevchenko
2014-07-07 15:21 ` [PATCH v2 09/10] staging: rtl8192e: use %*pEn to escape buffer Andy Shevchenko
2014-07-07 15:21 ` 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=1404746512-12749-11-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=joe@perches.com \
--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 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).