Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4657687rwb; Mon, 8 Aug 2022 05:08:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR4VFGnE0/jK5Fsz65HeklXV5Cww7HVY1ABns7CNcSMtR+Jr6AlAVtbtCnBvIEwuuBv33ran X-Received: by 2002:a17:90b:4b4c:b0:1f4:da77:3f80 with SMTP id mi12-20020a17090b4b4c00b001f4da773f80mr20133415pjb.55.1659960520030; Mon, 08 Aug 2022 05:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659960520; cv=none; d=google.com; s=arc-20160816; b=xKVpUd7SipKEIneOL1J5qmyt+/K5lesqRtTsEPSCoFS2dZUFZEg/OK/6guErPNWS6Z WFy5AOv9Vbyb+dNAdelU3uc1hVL8AfkA1dk5TKTxIrnizW5Zpjin16SDn9iE072Y6eel fTSl4PuOPvg6PoKVD8Sb5TEHaZKX5qd0TAEQQmUi0AFnxKZ+74pNqQbzmRHdMxUFEQon GqFRfCwjIgLBAfV+Wn1CoXOr4MRjGnky/VDn0JZO9Y4Cv+5NvuFUw0lvhwPCvfwTMc7Y QMA6fq+QTV63VYYq2vaqA1ytWVnV4wzib8BqQxBQtRlGoCs1ZGdXcMRmTPcPc+Hnittw fnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ERavs2OZuaSZotSZxpUy6MvIXcD6G78fPlu5KuS1KfQ=; b=H9dNyVhN57hTpNoi4K3maL9I0iDJWqkJGMpWlXAlkSQi00MiC0PetHYQbs9w2YQKuB mbIYnpVCT6ijIbvUINXsX5ShCbRA2n/8fFYLZwLFIWCMLXNd9ymcDLVjTusyeUkdXa1n yih7TuiTZCdqlX9uSSFAtiOtZXWNXF1jukup7pADz7KvI1h3uO5eUtt6ftkprn2gOoSF sFFwxu4Kaf1CG0nggNA7ClantbJvqtsDwKITHFYucvkkc4tnSTYdAVCi2Yd7LCDhMKjO nSyHZvYutq70EAE3BAGR9tys7pnghaiWVvDwzMW4HuMMK39Zl8DwZZENaAxwTvF705hk GqCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qAGmUoMz; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a170902f71100b001708d35bb67si6341129plo.463.2022.08.08.05.08.23; Mon, 08 Aug 2022 05:08:40 -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=@gmail.com header.s=20210112 header.b=qAGmUoMz; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234435AbiHHMDn (ORCPT + 99 others); Mon, 8 Aug 2022 08:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbiHHMDm (ORCPT ); Mon, 8 Aug 2022 08:03:42 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E2916177 for ; Mon, 8 Aug 2022 05:03:40 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id o3so4910774qkk.5 for ; Mon, 08 Aug 2022 05:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=ERavs2OZuaSZotSZxpUy6MvIXcD6G78fPlu5KuS1KfQ=; b=qAGmUoMzYkkG51PGZWvUoHKzC2nH4OP0h46jDDHfdKVPj9c4FOhPoXserkrZ6Wkvk+ o61vsVsS67bNxw0NSRAOgr/8UGNxyBNAVCs5OKDTqIPe1e2GqkSGz6aOD8TONkiPBEoT GO08RiMUZkOocK3KmaR4Pu6lMz/EUWBJsyguC6AHgeV/H7W1984eH8XtJFlpSsSvJj9O N8DK7UGQGG+BwLAAeub2dcmRuoU6ND+LA7czafWoRKKB2s9SSRUF+q9lm5K4X0YNpJZn kOZRYHe7LB9r1HM1tyLA8tS1OV+I28XEK94VU5LQf4oRQrm3GKdc6NYwGByaLXYNN6se mp5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=ERavs2OZuaSZotSZxpUy6MvIXcD6G78fPlu5KuS1KfQ=; b=KVefmVI8CVjdNMhADpiZakyzcalCloymu4y371Why4l1F2+PZYZ0xo1BtmRSHdA8xC MgnFZgsapon+H+UMIWnGOfyx2vB3vkEjatOUhxk+Rvki7TgN8NeC7wp1fh8lGLiDqCXF nw4ELzCxGVS+ytsEje1YNnPm8qNXUzUaSMuLbQV4DmaT54Uhx00av9O08Fm7D6getMA0 nT19v8WCxoiMUccYTXhPee/4nWjCOjAr4sjNA4LcqmC5spJyx0pIyBir+vmwaojO7MVT fDwQ8p7LxOdocfSKWXR93URPLRVfdwHokQ27i5flCd91jid8Z2jBylgmV8HsGbA5RGr0 JrRw== X-Gm-Message-State: ACgBeo0QUIzN4ZtnxSAFC/y9kTkidVnENacQflz+A31aAr3zfdBLd4Oo k+/BnIosFJ7YwuvQg7Y2/XAGwwZMPxgm5McZ93E= X-Received: by 2002:a05:620a:288a:b0:6b8:fcfe:db02 with SMTP id j10-20020a05620a288a00b006b8fcfedb02mr13874753qkp.504.1659960219392; Mon, 08 Aug 2022 05:03:39 -0700 (PDT) MIME-Version: 1.0 References: <20220808024128.3219082-1-willy@infradead.org> <20220808024128.3219082-3-willy@infradead.org> In-Reply-To: <20220808024128.3219082-3-willy@infradead.org> From: Andy Shevchenko Date: Mon, 8 Aug 2022 14:03:02 +0200 Message-ID: Subject: Re: [PATCH v5 02/32] lib/string_helpers: Convert string_escape_mem() to printbuf To: "Matthew Wilcox (Oracle)" Cc: Linux Kernel Mailing List , Petr Mladek , Kent Overstreet , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Aug 8, 2022 at 4:41 AM Matthew Wilcox (Oracle) wrote: > > From: Kent Overstreet > > Like the upcoming vsprintf.c conversion, this converts string_escape_mem > to prt_escaped_string(), which uses and outputs to a printbuf, and makes > string_escape_mem() a smaller wrapper to support existing users. > > The new printbuf helpers greatly simplify the code. ... > struct device; > struct file; > struct task_struct; > +struct printbuf; Keep it ordered? ... > @@ -71,6 +74,7 @@ static inline int string_escape_mem_any_np(const char *src, size_t isz, > return string_escape_mem(src, isz, dst, osz, ESCAPE_ANY_NP, only); > } > > + > static inline int string_escape_str(const char *src, char *dst, size_t sz, > unsigned int flags, const char *only) > { Stray change. ... > if (!(is_append || in_dict) && is_dict && > - escape_passthrough(c, &p, end)) > + escape_passthrough(out, c)) That (a bit strange) indentation is on purpose. Can we keep it? > continue; ... Not sure if the below was in the original text, but maybe it makes sense to amend. > + * Description: > + * The process of escaping byte buffer includes several parts. They are applied a byte in the buffer (?) > + * in the following sequence. > + * > + * 1. The character is not matched to the one from @only string and thus > + * must go as-is to the output. > + * 2. The character is matched to the printable and ASCII classes, if asked, > + * and in case of match it passes through to the output. > + * 3. The character is matched to the printable or ASCII class, if asked, > + * and in case of match it passes through to the output. > + * 4. The character is checked if it falls into the class given by @flags. > + * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any > + * character. Note that they actually can't go together, otherwise > + * %ESCAPE_HEX will be ignored. > + * > + * Caller must provide valid source and destination pointers. Be aware that > + * destination buffer will not be NULL-terminated, thus caller have to append the caller has > + * it if needs. The supported flags are:: if needed. -- With Best Regards, Andy Shevchenko