From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFD2AC433E7 for ; Mon, 12 Oct 2020 21:49:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D4D82076D for ; Mon, 12 Oct 2020 21:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731154AbgJLVtL (ORCPT ); Mon, 12 Oct 2020 17:49:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:52224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729273AbgJLVtL (ORCPT ); Mon, 12 Oct 2020 17:49:11 -0400 Received: from oasis.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 3A4882072D; Mon, 12 Oct 2020 21:49:10 +0000 (UTC) Date: Mon, 12 Oct 2020 17:49:08 -0400 From: Steven Rostedt To: Tom Zanussi Cc: axelrasmussen@google.com, mhiramat@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/7] tracing: Add synthetic event error logging Message-ID: <20201012174908.7ca51d0c@oasis.local.home> In-Reply-To: <20201012174240.7715df28@oasis.local.home> References: <20201012174240.7715df28@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Oct 2020 17:42:40 -0400 Steven Rostedt wrote: > On Mon, 12 Oct 2020 15:18:06 -0500 > Tom Zanussi wrote: > > > +static char last_cmd[MAX_FILTER_STR_VAL]; > > + > > +static int errpos(const char *str) > > +{ > > + return err_pos(last_cmd, str); > > +} > > + > > +static void last_cmd_set(char *str) > > +{ > > + if (!str) > > + return; > > + > > + strncat(last_cmd, str, MAX_FILTER_STR_VAL - 1); > > If I understand strncat() correctly, it will add 'n' + 1 bytes from str > to last_cmd. That is, I think you want: > > strncat(last_cmd, str, MAX_FILTER_STR_VAL - (strlen(last_cmd) + 1)); > Looking at the patch more, it only has one caller to last_cmd_set(), and one caller to synth_err_clear(). Why not just clear on set? -- Steve > > > +} > > + > > +static void synth_err(u8 err_type, u8 err_pos) > > +{ > > + tracing_log_err(NULL, "synthetic_events", last_cmd, err_text, > > + err_type, err_pos); > > +} > > + > > +static void synth_err_clear(void) > > +{ > > + last_cmd[0] = '\0'; > > +} > > +