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, URIBL_BLOCKED,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 51E70C12002 for ; Wed, 14 Jul 2021 22:13:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 311526101B for ; Wed, 14 Jul 2021 22:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236519AbhGNWQT (ORCPT ); Wed, 14 Jul 2021 18:16:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:50360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231407AbhGNWQS (ORCPT ); Wed, 14 Jul 2021 18:16:18 -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 901CC6101B; Wed, 14 Jul 2021 22:13:25 +0000 (UTC) Date: Wed, 14 Jul 2021 18:13:18 -0400 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Ingo Molnar , Andrew Morton , Chuck Lever Subject: Re: [GIT PULL] tracing: Add __string_len() and __assign_str_len() helpers Message-ID: <20210714181318.735a496b@oasis.local.home> In-Reply-To: <20210714175633.3b53346a@oasis.local.home> References: <20210713171143.7784697e@oasis.local.home> <20210714175633.3b53346a@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; 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 Wed, 14 Jul 2021 17:56:33 -0400 Steven Rostedt wrote: > That "(len)+1" adds the extra byte for the '0'. Hence, it is similar to: > > dst = kmalloc(len + 1, GFP_KERNEL); > strncpy(dst, src, len); > dst[len] = '\0'; > > Where the requirement is that you want to save len bytes of source into > dst, where len must be at least the size of src. Sorry, that should have read "len must be at most the size of src". That is, the caller knows how big src is, and is telling the trace event that all characters up to "len" exists. -- Steve