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=-19.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 612CFC433EF for ; Mon, 6 Sep 2021 11:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4386B60F45 for ; Mon, 6 Sep 2021 11:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238955AbhIFLxJ (ORCPT ); Mon, 6 Sep 2021 07:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238741AbhIFLxI (ORCPT ); Mon, 6 Sep 2021 07:53:08 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EAE1C061575 for ; Mon, 6 Sep 2021 04:52:04 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id p15so10960003ljn.3 for ; Mon, 06 Sep 2021 04:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=cNdWdE9zckeK0P4G8eZT1h84dDVanfximzzDa+p2Hjc=; b=KYhSOQG18JjAbN5qQ+S1nwOavgQfQYe3Bcx6vZFJqcnn+bCMwr8n6YN5OOpzPlvlnA ZTf6QabKYStvwp8SL8zfsKRcmTiFqnswRqzbASjRfJTL5IGUoHPGpLL2zHI1vPjcdM95 LqnOjq9ZkBH30XmOeL50M/09OddRKL0PFIKWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cNdWdE9zckeK0P4G8eZT1h84dDVanfximzzDa+p2Hjc=; b=tPlPeDQ/zYQt1P29sNeEP7SMta4Y1M5giQxcsn/GlVfpnhf2OKUJYuIuc4lotleHWG cdt6JVHgHX4uNQ+uJxMaCPAVc4pMYlFW8Wa1msXwe4MWqXh4dbdvive5KJXasSen7npJ Viqi1irKerqB+XJkpU0TZ2f5geH26b8a5LHhMeXHcbrzRebVSklSruob/m812UZmXkjW f0d/y83WkEAKL5cXgVSt26HRi1zpH1V74XIndp227nTo7i7/+C3P6e/4jrhiTguo7KFo QhTQiVm3t2doXLJRQmiEAkgFtrVEO3fg0GVYJDZWBIDAEP7wgmbAoHdLDGKWuoNGpLOZ M+SA== X-Gm-Message-State: AOAM530uEiXuvvHL2/Xm1sEyCKGbN2Sxxzy81PUL1fG7vLjqJtQuDANC hFci/DVvkleK86WQIJh1QUCMIQ== X-Google-Smtp-Source: ABdhPJzjf3SxyBbYMwgiN7/Hol83iAhEfGDBi6kG4p76C7Bivt8ICcoLzUG8YNPJ6wi0G3AE8m0UQw== X-Received: by 2002:a05:651c:1593:: with SMTP id h19mr10508572ljq.117.1630929122409; Mon, 06 Sep 2021 04:52:02 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id y32sm723896lfa.171.2021.09.06.04.52.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Sep 2021 04:52:01 -0700 (PDT) Subject: Re: [PATCH v2 1/2] lib: add sputchar() helper To: Yury Norov , Petr Mladek , Andrew Morton , Andy Shevchenko , Bartosz Golaszewski , Chris Down , Gilles Muller , Ingo Molnar , Jacob Keller , Joe Perches , Julia Lawall , Michal Marek , Nicolas Palix , Peter Zijlstra , Sergey Senozhatsky , Stephen Boyd , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr References: <20210904231020.331185-1-yury.norov@gmail.com> <20210904231020.331185-2-yury.norov@gmail.com> From: Rasmus Villemoes Message-ID: <04164ecc-ba60-a0c6-1975-694b2d02c4ae@rasmusvillemoes.dk> Date: Mon, 6 Sep 2021 13:51:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210904231020.331185-2-yury.norov@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2021 01.10, Yury Norov wrote: > There are 47 occurrences of the code snippet like this: > if (buf < end) > *buf = ' '; > ++buf; > > This patch adds a helper function sputchar() to replace opencoding. > It adds a lot to readability, and also saves 43 bytes of text on x86. > > v2: cleanup cases discovered with coccinelle script. > > Signed-off-by: Yury Norov > --- > include/linux/kernel.h | 8 ++ Sorry, but 47 cases, mostly in one .c file, is not enough justification for adding yet another piece of random code to the-dumping-ground-which-is-kernel.h, especially since this helper is very specific to the needs of the vsnprintf() implementation, so extremely unlikely to find other users. I'm also not a fan of the sputchar name - it's unreadable at first glance, and when you figure out it's "a _s_tring version of putchar", that doesn't help, because its semantics are nothing like the stdio putchar. Rasmus