Message ID | 20230323123704.37983-4-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2884592wrt; Thu, 23 Mar 2023 05:37:46 -0700 (PDT) X-Google-Smtp-Source: AK7set8bvHhbEqoGaxnHTCzLxcsPXcTPO4B1ngaLUe178/pjhm0eZvrKC5kb6Uk+7bsGaqc8wRrF X-Received: by 2002:aa7:c152:0:b0:4fb:1fa8:da25 with SMTP id r18-20020aa7c152000000b004fb1fa8da25mr9225773edp.36.1679575065856; Thu, 23 Mar 2023 05:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679575065; cv=none; d=google.com; s=arc-20160816; b=WOOfOklDqM5RQllJOo88rizCzhI65RKphUBAmKZhVCOWKcpL1z2mBYk5XUy4Mekacm AloWXfFIMDZ1eSGE/0XEec5kdcQfNs8FdUOHuk9qGard4pfXUenk7F192IptSE+AujH0 aIn48wtHhJ+1kIfb0CeCyAhN/JEINkMV5TQssCkGnvt+BQlYGCm6bGz1r3g2Aq3KAMzR +9/cgXbb1aZoxuJMalfMU1jlmIcRlEPMjvpFXiyCRiiGnDgBvrrVE2ZsmYQPcvZv6ZGu 8SHlnh97fPlVJtjn3RPiRTavvHCHatCtsM7WnoCqADya3jRirkKdiI60DSC3Rf3SfcVa fpag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dyRJChjL9Vc/5oc5t+l1x2RE1uTtdGFuiDanwyKmj2s=; b=wkV3kH3zaDkRelUfF3j7aa/g+JK/eg+y22Ycr6jtfFKzqCHfwlD0XBKvkX+7gxuygu wDtMXPYnJ/EwXBJboNOgdPoMDIHtTxqmHlMNVoEFwTX2NQXYQlsptlRHYpP5tjqGW7yn PATSHI7QVZW07JaKm3RNDtJDwqmhZFwWbvQPoQD/nMx5BVvfqdS6tCByqGkHHb7bv7+n ftZa+u8aohAF9gDBx7y1Q2C2S0CkIx+bTGExnH3yiN+0x+JDX5LvrBJhtaYvfQZvB0wj 4fWDwMwEx67GD9SWPQntuBpO330nNOe8WYb66/kaG5URJbrklR2Ro5/x0h5uuHFhNxfP LawA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DVpEUyVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020aa7d54a000000b00501d67d24dcsi6836851edr.414.2023.03.23.05.37.22; Thu, 23 Mar 2023 05:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DVpEUyVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbjCWMgj (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Thu, 23 Mar 2023 08:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbjCWMgi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Mar 2023 08:36:38 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B071B56F; Thu, 23 Mar 2023 05:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679574984; x=1711110984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Uqba7KW+LSTrR6KDuN+F/tgiTmPx6AhRcJexGJYfzL0=; b=DVpEUyVcB9cuHQaevin9Hs+FrKfkjYEBilsuB7NZEcmJ68Q6q5r1gG31 aoUldmS7ijsb/RnEvdcQ/AGw8VWqYvT6mbmJ6cLoVQsk4OO66IizRsR+9 fn8AHZvaZmXMiEgWNtxCHFpi7wc7WMocpWf/Xj/0JxGQnz565QA0Mnj+P zrHZePsVE6HiBlKFLldJVcYA02CXlD85JCEo5fBX1YHKugzTDpCtEztlt 4Dlx6rJ5qYBKowjEn0nlMqB6bOFEQbUtxhFd/TaiD7InqMnD1Z5Gy7Vof +QYZaieWqldzU0n3Z5ZzMpOa9gz1waTZ3elG1kpxSQOv/AjfNMM09BSk6 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="404359764" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="404359764" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 05:36:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="675681050" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="675681050" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 23 Mar 2023 05:36:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3AE4C176; Thu, 23 Mar 2023 14:37:07 +0200 (EET) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Kees Cook <keescook@chromium.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Cezary Rojewski <cezary.rojewski@intel.com>, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Theodore Ts'o" <tytso@mit.edu>, Jan Kara <jack@suse.com>, Andy Shevchenko <andy@kernel.org>, "Rafael J. Wysocki" <rafael@kernel.org> Subject: [PATCH v2 3/3] kobject: Use return value of strreplace() Date: Thu, 23 Mar 2023 14:37:04 +0200 Message-Id: <20230323123704.37983-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230323123704.37983-1-andriy.shevchenko@linux.intel.com> References: <20230323123704.37983-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761162104470878027?= X-GMAIL-MSGID: =?utf-8?q?1761162104470878027?= |
Series |
lib/string_helpers et al.: Change return value of strreplace()
|
|
Commit Message
Andy Shevchenko
March 23, 2023, 12:37 p.m. UTC
Since strreplace() returns the pointer to the string itself,
we may use it directly in the code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
lib/kobject.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
From: Andy Shevchenko > Sent: 23 March 2023 12:37 > > Since strreplace() returns the pointer to the string itself, > we may use it directly in the code. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > lib/kobject.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/lib/kobject.c b/lib/kobject.c > index f79a434e1231..16d530f9c174 100644 > --- a/lib/kobject.c > +++ b/lib/kobject.c > @@ -281,8 +281,7 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, > kfree_const(s); > if (!t) > return -ENOMEM; > - strreplace(t, '/', '!'); > - s = t; > + s = strreplace(t, '/', '!'); Why do this? It just makes the code harder to read because you have to know another 'silly fact' about a function. Possibly useful return values might be: 1) The address of the first changed character. 2) The address of the last changed characher. 3) The '\0' terminator. 4) void. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/lib/kobject.c b/lib/kobject.c index f79a434e1231..16d530f9c174 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -281,8 +281,7 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, kfree_const(s); if (!t) return -ENOMEM; - strreplace(t, '/', '!'); - s = t; + s = strreplace(t, '/', '!'); } kfree_const(kobj->name); kobj->name = s;