Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp826801imm; Mon, 21 May 2018 15:15:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqUeRxlHvqTTChKn0Wetz8qyYl91DguZdyQ80iXQWokpC3KlPZPoR3pKLgCcCDkH7cswKcJ X-Received: by 2002:a63:69c4:: with SMTP id e187-v6mr17064281pgc.415.1526940922671; Mon, 21 May 2018 15:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526940922; cv=none; d=google.com; s=arc-20160816; b=bMjcHDpypGz/wB4FdlYFyoDYuLOfMmiRwajxlhfIlSfmZrk7N28JLQZ6RoK9XVmDud vQbjDjjXFlg4SW2PBc6oEFh2KjFnHJnkx+k8CR5+hWjjYWeSPnX2ebR9GDt0UHhhHFlf +xgHce/NrtZwwt0B17Qx7o/kWQDOVYeypvZfs5cnUPmZPfJ/U8TrRHRYtryyvbNxFUrf GmXj+CHb+i+8uMyY7J+ZNWLx9jmSTMzQmWpR9fzmvFEnU8NzsKMxcVWUwi/L8uxnMPFp y6FTnhniMLLhecqrBemkx94KU+7o4/z+/h4Vu1C22ImByh050b4Ra91uPQ9fuIuBU560 YfRQ== 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=GVNc43dlKr9Ow/SFO1TH7/LHqBU2gouqzLiEgHs/Rns=; b=D7XCfCfvFVejBEpX7UETEVqtjWSNTqlwRg/1GKMlbo5INL5NLDp0r337TSC1B8yYTK jFZaVLEcb0fGwlQ0SuUMrQHWPxhCvdO2OghKLkTCLUsojf8bxhq0/SINdzojybNTxlu9 csd9EAdNlzKTfWHreHML3vCSSsebZSJI024+trGkSRlyWf1U0G5K5oOAEp7nWflNvTM8 Jr/EnK2xhtaQzlq4lwxXlvYcTO4lVj54o0qARHCxSjq1ImvtQR04sc7ctVn9mI7lsi41 D38g6VZrStYbd4bRcVyA978lfpfcdJtaMK6CWFo6nr5bVO0iu2/MQY3wJLxwcSRi9h2h kSSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YE4a2AP6; 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 p3-v6si14984015pld.408.2018.05.21.15.15.08; Mon, 21 May 2018 15:15:22 -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=YE4a2AP6; 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 S1753458AbeEUWOB (ORCPT + 99 others); Mon, 21 May 2018 18:14:01 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34051 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752707AbeEUWN5 (ORCPT ); Mon, 21 May 2018 18:13:57 -0400 Received: by mail-qk0-f194.google.com with SMTP id p186-v6so13065991qkd.1 for ; Mon, 21 May 2018 15:13:57 -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=GVNc43dlKr9Ow/SFO1TH7/LHqBU2gouqzLiEgHs/Rns=; b=YE4a2AP6Ee5XsTnjCdX7JNuQtEp30LDL6yhAzanDMn87Nxkw5XqvxFcY2Jmrmallqn Gbf3lN8QIjALtrRA2rJsPY+u/f31Wv0DeuSSXZ1jyyInQUw3yjW1lR7AGouywEkeI0TG U1c2pnB7CSQRn82gapcdiYsO7pVvfaKB9H3jRW2nWCr5ePdopgksi1MmL/CjSKPDZ66h 4BnxGIvju5h+Va5jG++P538Ck0OAsLkoOpQADKeqwwkvwyvG0T8iDbXf7B4lIzRJrnoo GJ+sYaZvZNAQHC//3ONBGmwS8pF2cei7OdnBDGfm8/SoY8sJz7EfIlOTJ76jUQEHUvyU Iu5w== 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=GVNc43dlKr9Ow/SFO1TH7/LHqBU2gouqzLiEgHs/Rns=; b=G+7PyHjBHthhR20/gHAZdQD8qCfdc9W11BLcbnvhSEkKFO3Z1bMEsufcvjFp3/Zi4n DN9uIB5QHZ6Vn5WDC6LMyX0ucBHIsgKzxcaN3WXmQ590R0IJ9eEUhmFBuradLXH5pqtO acDD/dNfpq6sWkv1wn3hP/XbFKXUyOeZT3dfUpSihJW269+y84pfs5kZ44ZMkdLiptu2 S2rgPP2kcRHd98h2iW732eGqXfsYgVnFtjyELCGC1lIv7gLz9Q5a/t2FXzecO8ZK2FV+ LC13GOSHsSg+isevEVZitCPmKQDt+C/Hn4u2IY/EQi42zZSCQ83DjtR5b0Ow2LKMXVfA 31Ww== X-Gm-Message-State: ALKqPwdwi6Czl6aYlXl7PO3AjKfWw8Tf8YtDW2VQjd82RIGmEPr6iWaJ OUVJ0JAbeAk+rq3AEn+B32cgxvuoyNDZBGqA3Hc= X-Received: by 2002:a37:cbc1:: with SMTP id u62-v6mr18004557qkl.83.1526940836744; Mon, 21 May 2018 15:13:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Mon, 21 May 2018 15:13:56 -0700 (PDT) In-Reply-To: <1526903890-35761-28-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-28-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 22 May 2018 01:13:56 +0300 Message-ID: Subject: Re: [PATCH 27/33] 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 Mon, May 21, 2018 at 2:58 PM, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used intead of open coded variant. > > Cc: Ingo Molnar > Cc: Peter Zijlstra > Signed-off-by: Yisheng Xie > --- > kernel/sched/debug.c | 20 +++++++++----------- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > index 15b10e2..9e34499 100644 > --- a/kernel/sched/debug.c > +++ b/kernel/sched/debug.c > @@ -111,16 +111,14 @@ 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) { Why not 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); > } > } > > @@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp) > inode_lock(inode); > i = sched_feat_set(cmp); > inode_unlock(inode); > - if (i == __SCHED_FEAT_NR) > + if (i < 0) > return -EINVAL; Now it would be if (i < 0) return i; -- With Best Regards, Andy Shevchenko