From patchwork Tue Apr 14 01:44:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11486511 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E2F2913 for ; Tue, 14 Apr 2020 01:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0048D2076D for ; Tue, 14 Apr 2020 01:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403849AbgDNBqN (ORCPT ); Mon, 13 Apr 2020 21:46:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403848AbgDNBqM (ORCPT ); Mon, 13 Apr 2020 21:46:12 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E34D20768 for ; Tue, 14 Apr 2020 01:46:12 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.93) (envelope-from ) id 1jOAeR-004H4a-DM for linux-trace-devel@vger.kernel.org; Mon, 13 Apr 2020 21:46:11 -0400 Message-Id: <20200414014611.295310002@goodmis.org> User-Agent: quilt/0.65 Date: Mon, 13 Apr 2020 21:44:05 -0400 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/2] trace-cmd: Optimize check_file_exists() References: <20200414014403.968063641@goodmis.org> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (VMware)" if (dir && !S_ISDIR(st.st_mode)) return false; if (!dir && S_ISDIR(st.st_mode)) return false; return true; Is the same as: return !dir == !S_ISDIR(st.st_mode); Micro-optimize the logic! Signed-off-by: Steven Rostedt (VMware) --- lib/tracefs/tracefs-instance.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/tracefs/tracefs-instance.c b/lib/tracefs/tracefs-instance.c index a8729406b9fc..012a867038b7 100644 --- a/lib/tracefs/tracefs-instance.c +++ b/lib/tracefs/tracefs-instance.c @@ -263,12 +263,7 @@ static bool check_file_exists(struct tracefs_instance *instance, if (ret < 0) return false; - if (dir && !S_ISDIR(st.st_mode)) - return false; - if (!dir && S_ISDIR(st.st_mode)) - return false; - - return true; + return !dir == !S_ISDIR(st.st_mode); } /**