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 4/6] staging: wlan-ng: re-use string_escape_mem()
Date: Wed,  2 Jul 2014 16:20:27 +0300	[thread overview]
Message-ID: <1404307229-19186-5-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1404307229-19186-1-git-send-email-andriy.shevchenko@linux.intel.com>

This is a generic function to escape strings by given criteria. Let's use it
instead of custom approach.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/staging/wlan-ng/prism2sta.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 209e4db..1e44c09 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -61,6 +61,7 @@
 #include <linux/workqueue.h>
 #include <linux/byteorder/generic.h>
 #include <linux/ctype.h>
+#include <linux/string_helpers.h>
 
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -81,27 +82,6 @@
 #include "hfa384x.h"
 #include "prism2mgmt.h"
 
-/* Create a string of printable chars from something that might not be */
-/* It's recommended that the str be 4*len + 1 bytes long */
-#define wlan_mkprintstr(buf, buflen, str, strlen) \
-{ \
-	int i = 0; \
-	int j = 0; \
-	memset(str, 0, (strlen)); \
-	for (i = 0; i < (buflen); i++) { \
-		if (isprint((buf)[i])) { \
-			(str)[j] = (buf)[i]; \
-			j++; \
-		} else { \
-			(str)[j] = '\\'; \
-			(str)[j+1] = 'x'; \
-			(str)[j+2] = hex_asc_hi((buf)[i]); \
-			(str)[j+3] = hex_asc_lo((buf)[i]); \
-			j += 4; \
-		} \
-	} \
-}
-
 static char *dev_info = "prism2_usb";
 static wlandevice_t *create_wlan(void);
 
@@ -862,8 +842,11 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev)
 	result = hfa384x_drvr_getconfig(hw, HFA384x_RID_NICSERIALNUMBER,
 					snum, HFA384x_RID_NICSERIALNUMBER_LEN);
 	if (!result) {
-		wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN,
-				pstr, sizeof(pstr));
+		result = string_escape_mem(snum,
+				HFA384x_RID_NICSERIALNUMBER_LEN,
+				pstr, sizeof(pstr), ESCAPE_HEX | ESCAPE_NP,
+				NULL);
+		pstr[result] = '\0';
 		netdev_info(wlandev->netdev, "Prism2 card SN: %s\n", pstr);
 	} else {
 		netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n");
-- 
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 ` Andy Shevchenko [this message]
2014-07-02 13:20 ` [PATCH 5/6] staging: rtl8192e: re-use string_escape_mem() Andy Shevchenko
2014-07-02 13:35   ` Joe Perches
2014-07-02 14:11     ` Andy Shevchenko
2014-07-02 13:20 ` [PATCH 6/6] staging: rtl8192u: " Andy Shevchenko

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-5-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.