Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5584790rwl; Tue, 11 Apr 2023 07:26:32 -0700 (PDT) X-Google-Smtp-Source: AKy350ZoNahLjAvnGf8c+lu3hGGldnL0DdMAQQHCCSh15rXd7D1pR3l5QnoBIuLbIJ0b4DWGXz/C X-Received: by 2002:a17:90b:1e44:b0:23f:635e:51e5 with SMTP id pi4-20020a17090b1e4400b0023f635e51e5mr3995102pjb.36.1681223192354; Tue, 11 Apr 2023 07:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681223192; cv=none; d=google.com; s=arc-20160816; b=rrNbapsZ5pj/UgwmgY3Gb95Ax6b/oBzNc3sj/ob7pNg4icN1LpHLMKWuRLBVj8czCi 2uea8ugWDtzbrK8KjqfXRsYQnJdMThwjmkTvQlOSp7/m0DNdVTxSFf3DXZC3KoHVjFi0 2digOb7XdxwK/IDIhaRBRsReWOEBBf2g5HSs46qhH6pY9ieyaDrMct6zduqTXf3gBreu 5gEEkUih3kLGc2NqVyjtf43rFt+/4mORCs2bhohiu0iRhHhgO50KrqogM2LfJy0IYedV MLXdukuIsREXXWe/rIP8zoSdK4qgYR7UkZm8ea62zfBvOELzSz3owneDzJTF9SU/whys TOSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YuqZygU4tRUa0+59OIoTV2tHh2kbQKZU77mYLmKYsuY=; b=NrkbrQ7WO+NHF9NVdW6Dk/C3qe847soJF54C3Rj/FOncs8DY2rPqq/+zK1m/m10dXF fllVwLIDkYnSzIO4A0OkCdhlMP+yHspt/DjUJIIv+1l7qRlwvqlv5Rpc2WYFq6Ei5baj sXc0igtH6jkPZH+s5cbycMHEi8wUKvawtKILMk5CH6FEJ92ZXzSbCunTHMFHL3OgOPSR x6SP03vkjZcOg0bREtZMG3b3XGPBmmDvwYepJIIF7AKBWMXHmC85ZcmN4dEkePETLGWR mzLxCAuD39ANeCqaOPGUchU67GlyKYY88bBbsZzpDFOz+oVdhp2s+rILC2ENW/tvsO+p Kbog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cOYyZmT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h184-20020a636cc1000000b0050b51e62c19si13588354pgc.825.2023.04.11.07.26.18; Tue, 11 Apr 2023 07:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cOYyZmT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjDKOYe (ORCPT + 99 others); Tue, 11 Apr 2023 10:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229581AbjDKOYd (ORCPT ); Tue, 11 Apr 2023 10:24:33 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759251703 for ; Tue, 11 Apr 2023 07:24:32 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id y11-20020a17090a600b00b0024693e96b58so7017448pji.1 for ; Tue, 11 Apr 2023 07:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681223072; x=1683815072; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YuqZygU4tRUa0+59OIoTV2tHh2kbQKZU77mYLmKYsuY=; b=cOYyZmT7p7sBTBSsPuRPgIJvl79HL5HwqAgWnpojVt+pL3XSl7wEASJM/ByNzQPj6P qUeqONFbntS8FrqTecjkrlXQRtWgMus+nXHD67Hd+7aPf05fJAg9UnO+8YUSmfGB7ldZ sg7m/Xr3WIblDsKbKSx/nnuXCJjFZT9vOe8yc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681223072; x=1683815072; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YuqZygU4tRUa0+59OIoTV2tHh2kbQKZU77mYLmKYsuY=; b=Ry0+5V/g+fYU/M3qEoKj1Tmuj7c6SL7+qJRqhmO8CxE88llnlkq9fF2wt7iBuQHPDY O4ESmU16D/K7oePuB4hCM18PliBHj5r7Rg3pX0s6dHh3kY+iJlNw4hJFBMFOWVn/hXpI aF44pj1XJF/lisWRq/xQVAwQl3u/Xy0SVmyDHGTd6oJ73muQTu1FJp6z/GY0ExwiKRQJ JfRcRAINC4zeHZz1+LPVVFxDudgx2cINOnXcocpdYG3DdrqFx/SUZC7owgcy/L2HvTTX TmHzZ3tf8FFDK4GFus7oxCT4hNYeduMoCKEDqhUzCRfUF+sDwfJ8H2chHmrSdMM2IcNi VPyw== X-Gm-Message-State: AAQBX9cDGO1/y7GeOfdlvGI/lg1ADVQkGdyc1htfSd/DtGwF+RDjZHhm 5eHSrMiRXbUh5xbsWYIywXBK0Q== X-Received: by 2002:a17:90b:33d2:b0:240:973d:b436 with SMTP id lk18-20020a17090b33d200b00240973db436mr3392657pjb.49.1681223071888; Tue, 11 Apr 2023 07:24:31 -0700 (PDT) Received: from google.com (KD124209188001.ppp-bb.dion.ne.jp. [124.209.188.1]) by smtp.gmail.com with ESMTPSA id m7-20020a17090a4d8700b00233b18e6fb3sm4782398pjh.1.2023.04.11.07.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 07:24:31 -0700 (PDT) Date: Tue, 11 Apr 2023 23:24:27 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org Subject: Re: [PATCH] seq_buf: add seq_buf_printk() helper Message-ID: <20230411142427.GB25053@google.com> References: <20230411025556.751349-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (23/04/11 14:14), Petr Mladek wrote: > We might want to somehow distinguish that this is actually > printing (reading) the context of the buffer. > > The name is similar to seq_buf_printf() and seq_buf_vprintf() > whose are wrinting into the buffer. > > What about the following? > > + seq_buf_printf_seq() like the existing seq_buf_print_seq() > + seq_buf_to_printk() like the existing seq_buf_to_user() > > I personally prefer seq_buf_to_printk() because it looks more > selfexplaining to me. I like seq_buf_to_printk(). > > +{ > > + const char *start, *lf; > > + int len; > > + > > + if (s->size == 0) > > + return; > > + > > + start = s->buffer; > > + while ((lf = strchr(start, '\n'))) { > > We should rather use strnchr(). It seems that the trailing '\0' is > not guaranteed. For example, seq_buf_putc() just adds the given > character at the end. Good point.