From patchwork Tue Nov 7 15:31:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 835345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Tlnk9MfK"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yWYQQ4wknz9t2M for ; Wed, 8 Nov 2017 02:34:53 +1100 (AEDT) Received: from localhost ([::1]:54008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5tq-0008HZ-RM for incoming@patchwork.ozlabs.org; Tue, 07 Nov 2017 10:34:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5tF-0008Fv-6Z for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:34:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC5tA-0007vw-7d for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:34:13 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:51903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eC5tA-0007vX-1V for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:34:08 -0500 Received: by mail-pf0-x244.google.com with SMTP id n14so10571281pfh.8 for ; Tue, 07 Nov 2017 07:34:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dA+V+al4HqRQlV7rLr+0cHW6/213m2GU4GsdP8d67hA=; b=Tlnk9MfKEUpZVu7O1gcHBnablxs/zTCeI+BUQlm2d/2aQALpV9DtuEd7cjZXqr0PXp NvzyZSeTcXlPqy/BGvWXH5aaehrl8993wcePcxuYygqYJ+O8KVh8v7wG/294OZboahWv ozVRmpxoyoxo39vjJ9LnNJOJO1heYUi98jv0V2NWUyssk4XYE/cpdMcLudY9hsx7CGJu /qqd3lL7ZUt+esz6aYa6gFxGJngcFofIDh/Nh5WjIlbEBuluwJW7qujM4gJWVdQSdQ/c CbYHqwNdXxt5/l9HTG/HieoVzr8gP0QmNbrtpqbIgl2go1d+K/r7gYzJirIcoyEYifhx uZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dA+V+al4HqRQlV7rLr+0cHW6/213m2GU4GsdP8d67hA=; b=n/Bapy5Tcn81BT7jKKqJl73HX1hQ2hk8z5ZnAo3HuzsUjco9H7rWlv6itkQIrRT+b7 Y0bfPtUE0dJ9/1PwJx4dcNcfindduzQNrTk8gNJ4b8Zt1MDodLwN3tYR+EExYVXhVyv/ ZwFhqW+jejNChlckJhzTBbnqYbvWD1ZfH6UFx3h1SfZBsC6+wdrtcvD0WbR3Rgi0ca+l oggiiqFPOlK71kgWplGVxNmGQBRvuQ1eQwCjg+aUbCQIjgLtRPgSFmm4RM1R5QoeduxS CUbEj93lOo22tMspFpwsL7+Gdfw4FFfZCMT8RsRL9nwn5Sb6I97GfYEZszMP0u9L4EHK tVDQ== X-Gm-Message-State: AMCzsaVu9iNQF0E+NZwa4qPCvyQ9QLXP3PjZrkAzcsIANYrXcHvmHFbZ wqwD0osuyZUWuIvzhpH5O2A= X-Google-Smtp-Source: ABhQp+Szk2BQq4QGxuB14Xq8ax8BWLpcA61EV2jQyPuaEjdyUPTSgq0ka8IH8NuMX9jJDSBEEnHpmg== X-Received: by 10.99.179.74 with SMTP id x10mr18868762pgt.336.1510068846295; Tue, 07 Nov 2017 07:34:06 -0800 (PST) Received: from danjae.aot.lge.com ([59.12.60.183]) by smtp.gmail.com with ESMTPSA id z13sm3416330pgc.29.2017.11.07.07.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 07:34:05 -0800 (PST) From: Namhyung Kim To: Stefan Hajnoczi Date: Wed, 8 Nov 2017 00:31:34 +0900 Message-Id: <20171107153136.19426-1-namhyung@gmail.com> X-Mailer: git-send-email 2.14.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 1/3] trace: Simplify find_debugfs() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The return vale of find_debugfs() is 1 if it could find a mount point of debugfs. It can be saved in the while loop instead of checking it again. Signed-off-by: Namhyung Kim --- trace/ftrace.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trace/ftrace.c b/trace/ftrace.c index 7de104deba..bfa38e71f0 100644 --- a/trace/ftrace.c +++ b/trace/ftrace.c @@ -19,6 +19,7 @@ static int find_debugfs(char *debugfs) { char type[100]; FILE *fp; + int ret = 0; fp = fopen("/proc/mounts", "r"); if (fp == NULL) { @@ -28,15 +29,13 @@ static int find_debugfs(char *debugfs) while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", debugfs, type) == 2) { if (strcmp(type, "debugfs") == 0) { + ret = 1; break; } } fclose(fp); - if (strcmp(type, "debugfs") != 0) { - return 0; - } - return 1; + return ret; } bool ftrace_init(void)