From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753855AbbFDWbq (ORCPT ); Thu, 4 Jun 2015 18:31:46 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:55511 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbbFDWbo (ORCPT ); Thu, 4 Jun 2015 18:31:44 -0400 Date: Thu, 4 Jun 2015 23:31:43 +0100 From: Al Viro To: Rasmus Villemoes Cc: Andrew Morton , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [RFC/PATCH 4/8] lib/kobject.c: Use strreplace Message-ID: <20150604223143.GN7232@ZenIV.linux.org.uk> References: <1433410636-26812-1-git-send-email-linux@rasmusvillemoes.dk> <1433410636-26812-5-git-send-email-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433410636-26812-5-git-send-email-linux@rasmusvillemoes.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2015 at 11:37:11AM +0200, Rasmus Villemoes wrote: > There's probably not many slashes in kobj->name, but starting over > when we see one feels wrong. > > Signed-off-by: Rasmus Villemoes > --- > lib/kobject.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/lib/kobject.c b/lib/kobject.c > index 3b841b97fccd..597d962d3d4d 100644 > --- a/lib/kobject.c > +++ b/lib/kobject.c > @@ -258,7 +258,6 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, > va_list vargs) > { > const char *old_name = kobj->name; > - char *s; > > if (kobj->name && !fmt) > return 0; > @@ -270,8 +269,7 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, > } > > /* ewww... some of these buggers have '/' in the name ... */ > - while ((s = strchr(kobj->name, '/'))) > - s[0] = '!'; > + strreplace((char *)kobj->name, '/', '!'); Again, I'd rather do s = kvasprintf(GFP_KERNEL, fmt, vargs); if (!s) return -ENOMEM; strreplace(s, '/', '!'); old_name = kobj->name; kobj->name = s; kfree(old_name);