From patchwork Wed Jul 2 13:20:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 4465411 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 A09C7BEEAA for ; Wed, 2 Jul 2014 13:21:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4E932034B for ; Wed, 2 Jul 2014 13:21:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFA8F202F8 for ; Wed, 2 Jul 2014 13:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753270AbaGBNVB (ORCPT ); Wed, 2 Jul 2014 09:21:01 -0400 Received: from mga11.intel.com ([192.55.52.93]:26015 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751297AbaGBNU7 (ORCPT ); Wed, 2 Jul 2014 09:20:59 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 02 Jul 2014 06:20:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,588,1400050800"; d="scan'208";a="556406013" Received: from smile.fi.intel.com ([10.237.72.73]) by fmsmga001.fm.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-00050x-0r; 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 5/6] staging: rtl8192e: re-use string_escape_mem() Date: Wed, 2 Jul 2014 16:20:28 +0300 Message-Id: <1404307229-19186-6-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. Signed-off-by: Andy Shevchenko --- drivers/staging/rtl8192e/rtllib.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 83f5f57..cb99160 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -2956,7 +2957,6 @@ extern inline int rtllib_get_scans(struct rtllib_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 (rtllib_is_empty_essid(essid, essid_len)) { @@ -2965,15 +2965,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; }