From patchwork Wed Feb 23 04:16:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12756280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E790C433EF for ; Wed, 23 Feb 2022 04:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234607AbiBWERL (ORCPT ); Tue, 22 Feb 2022 23:17:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231274AbiBWERK (ORCPT ); Tue, 22 Feb 2022 23:17:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B6B19C1C for ; Tue, 22 Feb 2022 20:16:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5DFB960AD3 for ; Wed, 23 Feb 2022 04:16:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74932C340E7; Wed, 23 Feb 2022 04:16:41 +0000 (UTC) Date: Tue, 22 Feb 2022 23:16:39 -0500 From: Steven Rostedt To: Linux Trace Devel Cc: Beau Belgrave Subject: [PATCH] libtracefs: Use tracefs_warning() for tracefs_user_event_record() errors Message-ID: <20220222231639.3ccfe44e@rorschach.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" Instead of hard coding fprintf() into the library, allow the application to control the output, and use tracefs_warning() instead. Also switch the setting of the errno, as tracefs_warning() will add a perror() to the message. Signed-off-by: Steven Rostedt (Google) --- src/tracefs-userevents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tracefs-userevents.c b/src/tracefs-userevents.c index ccd511b3045d..7da6aa35bf12 100644 --- a/src/tracefs-userevents.c +++ b/src/tracefs-userevents.c @@ -504,13 +504,13 @@ int tracefs_user_event_record(struct tracefs_user_event *event, return writev(e->group->fd, head, used); bad_length: - fprintf(stderr, "Bad user_event item length at index %d\n", - used - 1); errno = EINVAL; + tracefs_warning("Bad user_event item length at index %d\n", + used - 1); return -1; bad_count: - fprintf(stderr, "Too many user_event items passed\n"); errno = E2BIG; + tracefs_warning("Too many user_event items passed\n"); return -1; }