Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp905136imm; Tue, 5 Jun 2018 06:22:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK9Z2R0ibunBLFeXV/1nRJ2BODOB/cA3w8xbFeeVKxRngDh8kFqGjVV6DH6gJUNEEKC/4US X-Received: by 2002:a17:902:b195:: with SMTP id s21-v6mr20589677plr.202.1528204943084; Tue, 05 Jun 2018 06:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528204943; cv=none; d=google.com; s=arc-20160816; b=k+vHg2AdOYusjGLxYMUvKSaYPNUugdbFWCacN5Y69q3q1C8qVwNxXtO50e7yfpSz5r hzUOZm1E7HM63DA0gVR/Se6kT84LQ0uGPg9QOZaWONyUJ68PHs29GH0jxhnRoxVH6h1j 3eGvc4A/nDL4kAGbGr90TzzZDypO0EBu4hQkaXlrM+VTPK1tz4Pb9uYNhwweUS7ZOtD/ qI+9rRJ2zN0/8JxO8Lz4DzvXW9Ncuj4LdGlekVjzk17R3/q5IYBgsOx1Jnx9W06LcEbU OJ0qiHonblJstbw5msnf1FO8lmiO36WLZwwi02C18O50jX26R5KPxtZyGopoBIdq15Ko dLMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=8tI4DRjx965b2hjECwpQyOSv3r3oVsJ1xitpcceGWi4=; b=MH3MenmZzlfP6FjaWf9X1kBHoOxIIp5hTGD6ia+bh/yoMXb6vdDDn3/EOhxt3d3Jte vbG9/CDP10BD6FXTYylc0FVl6mYrdEdoK//Ql72eXhbZES11bRAf4OeFpTEfcGdyAq+/ 3zEWup95E6kEV+MeoiJ59LzGp4kINI70x78jVDwfRuLR2C8UE9/tlKOKphXpe38Na9/O SMym7s/14robq+Q/nlig4WIEvOcdIPd9twbuIFB6/uiEYWQ9RW+1LR620xvdSts0PiX9 YWtFMzvoRgNoBMZeDlThD0f0ANEHUDAtbgNTCw/abHNyiZ13hYrMnuybxWicMLnrlviV o6Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UlDn5Lw2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2-v6si7935178pfn.271.2018.06.05.06.22.08; Tue, 05 Jun 2018 06:22:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UlDn5Lw2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbeFENV3 (ORCPT + 99 others); Tue, 5 Jun 2018 09:21:29 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:45501 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeFENV2 (ORCPT ); Tue, 5 Jun 2018 09:21:28 -0400 Received: by mail-qk0-f193.google.com with SMTP id c198-v6so1430955qkg.12 for ; Tue, 05 Jun 2018 06:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8tI4DRjx965b2hjECwpQyOSv3r3oVsJ1xitpcceGWi4=; b=UlDn5Lw20E/y8SMuSuqJEMDjTvMCNXvKB4mn1BBeCZgpqOPSDBNSxv/tRMs/2Bz60v ockyoXR2a8DyXgX/M6ueEOFXtIrGPnJEUM0bDB8YpTuOvEFS/bf+1zKicBdnvKEipxVo 8rUdFA0Tud8ub06H/8q1DCSL1lnI1yaB/o+DZsRCosuZfrvxltZFtgTALT+wZqI+4wW7 RTaswPSleSZYMJgJJ1O+rsJ0fk7wI4Cua7gR8eD71HtNfxjQuIYFvgGnCz3vpEjo+gE+ 7GFzvIK9MoLpbRgByKGcN8D49S61lkxc/YHPu4D/1nViYZLgHTPFoBBQt3XWEQrtenfm bThg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8tI4DRjx965b2hjECwpQyOSv3r3oVsJ1xitpcceGWi4=; b=r5MdIt/sdY4r/heJgy/dPeU3EgZXc9+rUf/tSlM4qDQI5nunjuLoz4OFrEp0UH6cmV Uofiqe+mDGoVITX1lZ03nmHLGrB/APrgUBZR4VQQdHu8jX5PL0ZpQWJ+wWtZlDBj0muk SZTYnYVOV2iN0ZK5xK0+qM+NTZeg/B0Iz1uKMH2i433eCZywg+S6vPureJz18S7ad5MC a1yKJHJq+US6QMYYPKZmn5cqtW+NPoHfbBIXK8kuOPzzjXbhytnn6UEfOpOSww4aEFFL /sfx0ZKr38nyrAtlHHH6ycg1SL6r71Ub9rQRHC7WGDTXCiTWipRGB4YwEzu5lUmo4UyH 2Emw== X-Gm-Message-State: APt69E1Cx+qkn9DHQy9DYIxeeLUpImtygBL/VPmkoBzS1kzzsGmzGpHA j4zhHV2vBDyGfdjgnbp8H7H+u3bMyuK6QqedzJQ= X-Received: by 2002:a37:ddce:: with SMTP id u75-v6mr22335975qku.147.1528204887347; Tue, 05 Jun 2018 06:21:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 06:21:26 -0700 (PDT) In-Reply-To: <1527765086-19873-15-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-15-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 16:21:26 +0300 Message-ID: Subject: Re: [PATCH v2 14/21] sched/debug: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Ingo Molnar , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > FWIW, Reviewed-by: Andy Shevchenko > Cc: Ingo Molnar > Cc: Peter Zijlstra > Signed-off-by: Yisheng Xie > --- > v2: > - rename i to ret to show the change in returned value meaning - per Andy > > kernel/sched/debug.c | 31 +++++++++++++++---------------- > 1 file changed, 15 insertions(+), 16 deletions(-) > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > index 15b10e2..5591147 100644 > --- a/kernel/sched/debug.c > +++ b/kernel/sched/debug.c > @@ -111,20 +111,19 @@ static int sched_feat_set(char *cmp) > cmp += 3; > } > > - for (i = 0; i < __SCHED_FEAT_NR; i++) { > - if (strcmp(cmp, sched_feat_names[i]) == 0) { > - if (neg) { > - sysctl_sched_features &= ~(1UL << i); > - sched_feat_disable(i); > - } else { > - sysctl_sched_features |= (1UL << i); > - sched_feat_enable(i); > - } > - break; > - } > + i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp); > + if (i < 0) > + return i; > + > + if (neg) { > + sysctl_sched_features &= ~(1UL << i); > + sched_feat_disable(i); > + } else { > + sysctl_sched_features |= (1UL << i); > + sched_feat_enable(i); > } > > - return i; > + return 0; > } > > static ssize_t > @@ -133,7 +132,7 @@ static int sched_feat_set(char *cmp) > { > char buf[64]; > char *cmp; > - int i; > + int ret; > struct inode *inode; > > if (cnt > 63) > @@ -148,10 +147,10 @@ static int sched_feat_set(char *cmp) > /* Ensure the static_key remains in a consistent state */ > inode = file_inode(filp); > inode_lock(inode); > - i = sched_feat_set(cmp); > + ret = sched_feat_set(cmp); > inode_unlock(inode); > - if (i == __SCHED_FEAT_NR) > - return -EINVAL; > + if (ret < 0) > + return ret; > > *ppos += cnt; > > -- > 1.7.12.4 > -- With Best Regards, Andy Shevchenko