From patchwork Wed Jul 2 13:20:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4465441 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4B202BEEAA for ; Wed, 2 Jul 2014 13:21:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E32A202F8 for ; Wed, 2 Jul 2014 13:21:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CB21203DA for ; Wed, 2 Jul 2014 13:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753850AbaGBNVq (ORCPT ); Wed, 2 Jul 2014 09:21:46 -0400 Received: from mga02.intel.com ([134.134.136.20]:11278 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753658AbaGBNVo (ORCPT ); Wed, 2 Jul 2014 09:21:44 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Jul 2014 06:21:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,588,1400050800"; d="scan'208";a="567258223" 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 1X2KSe-000512-8q; Wed, 02 Jul 2014 16:20:32 +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 6/6] staging: rtl8192u: re-use string_escape_mem() Date: Wed, 2 Jul 2014 16:20:29 +0300 Message-Id: <1404307229-19186-7-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 Let's use kernel's library function to escape a buffer instead of custom code. Signed-off-by: Andy Shevchenko --- 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 #include #include +#include #include #include @@ -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; }