From patchwork Wed Jul 2 13:20:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4465431 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F4B69F36A for ; Wed, 2 Jul 2014 13:21:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB22F202F2 for ; Wed, 2 Jul 2014 13:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3F86202F8 for ; Wed, 2 Jul 2014 13:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753670AbaGBNVV (ORCPT ); Wed, 2 Jul 2014 09:21:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:15960 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753606AbaGBNVU (ORCPT ); Wed, 2 Jul 2014 09:21:20 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 02 Jul 2014 06:15:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,588,1400050800"; d="scan'208";a="567258217" Received: from smile.fi.intel.com ([10.237.72.73]) by orsmga002.jf.intel.com with ESMTP; 02 Jul 2014 06:20:33 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1X2KSd-00050s-P5; Wed, 02 Jul 2014 16:20:31 +0300 From: Andy Shevchenko To: "John W. Linville" , Johannes Berg , devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton Cc: Andy Shevchenko Subject: [PATCH 4/6] staging: wlan-ng: re-use string_escape_mem() Date: Wed, 2 Jul 2014 16:20:27 +0300 Message-Id: <1404307229-19186-5-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1404307229-19186-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1404307229-19186-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a generic function to escape strings by given criteria. Let's use it instead of custom approach. Signed-off-by: Andy Shevchenko --- 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 #include #include +#include #include #include @@ -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");