[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1404308150.14624.73.camel@joe-AO725>
Date: Wed, 02 Jul 2014 06:35:50 -0700
From: Joe Perches <joe@...ches.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: "John W. Linville" <linville@...driver.com>,
Johannes Berg <johannes@...solutions.net>,
devel@...verdev.osuosl.org, linux-wireless@...r.kernel.org,
linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 5/6] staging: rtl8192e: re-use string_escape_mem()
On Wed, 2014-07-02 at 16:20 +0300, Andy Shevchenko wrote:
> Let's use kernel's library function to escape a buffer.
[]
> diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
[]
> @@ -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);
I'd've probably used
d += string_escape_mem(essid, essid_len, d, ...
or
d = escaped + string_escap_mem(essid, essid_len, escaped, ...
so there's some relation between the thing being added to
> *d = '\0';
or maybe not used d at all with
escaped[1 + string_escape_mem(etc...)] = 0;
> return escaped;
> }
Unrelated but this isn't a thread safe or multiple instance
safe function.
It seems it's used only in debugging message output though.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists