Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3672918ybt; Tue, 23 Jun 2020 08:06:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUsP5N8ZUkY6gySSVQY1pZ0O5hTwe9FJ6BaBcckOnWVnhjdETFCWvQYnafLm6rOMg+hH2U X-Received: by 2002:a17:906:69c3:: with SMTP id g3mr21797264ejs.47.1592924769447; Tue, 23 Jun 2020 08:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592924769; cv=none; d=google.com; s=arc-20160816; b=h8DqrxGLfrHgkO4hhyJgz44Pr/4PIs7WcOyvdNxF5CGocOkAqTj9lPObhXsjOh0tBN sVIShRVqnOw2wTTdRTDqYri0V6I5MGBdKE79bc2Eiyp1vD+IQrg3E1RCqyalVVRF18zc z4ZvN5p5zVVn0QyIqRS8RXeUlXRWEvBOxIj7INDe+vXbYwCPrFpPeL0jma2TqhXlnQSF VfzC29g+OhqJ9i2lcjxfrt+IYtfsDhPbUginnecXnzCOLhmEeMlF/0EmgQbVwn1XZHNS mIEf4RW9oPZOuvHJo/f4naM0IiTErsLMRJs6XPm23XojuqxzT2XBQ/ndLOElgRhS0wQa gtIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=aViiKm2qN/EDqnEu6MyN1/24Jh77gNMxGTqa6474mC0=; b=EFj+y9l/5mslXuafWnvE8uFEL/LqwNCJHqQ2934YxfASrXH/6kuZxRxkkjwcLD3bTn 9nDU+w1xQRla4Q1qkLc2METnaxN+ApwA5pbOcBsqWBQpn0VBmtCehBwvZtkBeJiI/OwD Uo9Y9CabhRzM4QZnkSTY2z9D28JPgxdv1+HSEVyXuhBFEVP7qn2cWK/pk/eI4vnmIiZH ZI0zYmLQEckZL2Qs4W01EW+PMDzltMoJVwQQ1lX/pOAJ1u0NrSOuq8rfM1ZoQoZ9UcNl RIZ7CxQ75uqu/W81P1NCAmXSh+27f/+LI22noePY8DjpnEkfyKAjNvBjKx1a10hF0ThI EtYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ThcJxpJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se20si11903919ejb.165.2020.06.23.08.05.45; Tue, 23 Jun 2020 08:06:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ThcJxpJH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732925AbgFWPDs (ORCPT + 99 others); Tue, 23 Jun 2020 11:03:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:40988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732862AbgFWPDs (ORCPT ); Tue, 23 Jun 2020 11:03:48 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 288B120723; Tue, 23 Jun 2020 15:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592924628; bh=soLk9tHcyZMj32YGp0QZQRF8FQvz57n5ghu4cncgjPQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ThcJxpJHtMwx4ohRDXwXRlZjEiawns/3J+Frb7elkq760zVZ+T1l+IpRWyq6xcVhA GIsW/DAlOiki/tv17A5I7SYmAracDuGSJSbJ7DYx3ySRNhmeghbK0Os4r+h7RwGt23 kJkbPgcAXIXF3UwYz23fY/V5thCpvI+99agWnDoA= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 6497C405FF; Tue, 23 Jun 2020 12:03:45 -0300 (-03) Date: Tue, 23 Jun 2020 12:03:45 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Alexey Budankov , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v8 03/13] perf evlist: implement control command handling functions Message-ID: <20200623150345.GA26230@kernel.org> References: <0781a077-aa82-5b4a-273e-c17372a72b93@linux.intel.com> <20200623145601.GH2619137@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200623145601.GH2619137@krava> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jun 23, 2020 at 04:56:01PM +0200, Jiri Olsa escreveu: > On Wed, Jun 17, 2020 at 11:36:46AM +0300, Alexey Budankov wrote: > > SNIP > > > + memset(cmd_data, 0, data_size--); > > + > > + do { > > + err = read(evlist->ctl_fd.fd, &c, 1); > > + if (err > 0) { > > + if (c == '\n' || c == '\0') > > + break; > > + cmd_data[bytes_read++] = c; > > + if (bytes_read == data_size) > > + break; > > + } else { > > + if (err == -1) > > + pr_err("Failed to read from ctlfd %d: %m\n", evlist->ctl_fd.fd); > > + break; > > + } > > + } while (1); > > + > > + pr_debug("Message from ctl_fd: \"%s%s\"\n", cmd_data, > > + bytes_read == data_size ? "" : c == '\n' ? "\\n" : "\\0"); > > + > > + if (err > 0) { > > + if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG, > > + strlen(EVLIST_CTL_CMD_ENABLE_TAG))) { > > you could use sizeof(EVLIST_CTL_CMD_ENABLE_TAG) instead, no function call -1, as sizeof will get the \0, right? > > > + *cmd = EVLIST_CTL_CMD_ENABLE; > > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_TAG, > > + strlen(EVLIST_CTL_CMD_DISABLE_TAG))) { > > ditto > > jirka > -- - Arnaldo