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_1 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 961EBC43460 for ; Fri, 16 Apr 2021 10:48:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60A1661003 for ; Fri, 16 Apr 2021 10:48:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235352AbhDPKtP (ORCPT ); Fri, 16 Apr 2021 06:49:15 -0400 Received: from angie.orcam.me.uk ([157.25.102.26]:38984 "EHLO angie.orcam.me.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240598AbhDPKtI (ORCPT ); Fri, 16 Apr 2021 06:49:08 -0400 Received: by angie.orcam.me.uk (Postfix, from userid 500) id 478BF92009C; Fri, 16 Apr 2021 12:48:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 4041792009B; Fri, 16 Apr 2021 12:48:42 +0200 (CEST) Date: Fri, 16 Apr 2021 12:48:42 +0200 (CEST) From: "Maciej W. Rozycki" To: Joe Perches cc: Khalid Aziz , "James E.J. Bottomley" , "Martin K. Petersen" , Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 1/5] scsi: BusLogic: Fix missing `pr_cont' use In-Reply-To: <787aae5540612555a8bf92de2083c8fa74e52ce9.camel@perches.com> Message-ID: References: <787aae5540612555a8bf92de2083c8fa74e52ce9.camel@perches.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Apr 2021, Joe Perches wrote: > In patch 2, vscnprintf should probably be used to make sure it's > 0 terminated. Why? C99 has this[1]: "The vsnprintf function is equivalent to snprintf, with the variable argument list replaced by arg, which shall have been initialized by the va_start macro (and possibly subsequent va_arg calls)." and then[2]: "The snprintf function is equivalent to fprintf, except that the output is written into an array (specified by argument s) rather than to a stream. If n is zero, nothing is written, and s may be a null pointer. Otherwise, output characters beyond the n-1st are discarded rather than being written to the array, and a null character is written at the end of the characters actually written into the array." therefore output from `vsnprintf' is always null-terminated. > And while it's a lot more code, I'd prefer a solution that looks more > like the other commonly used kernel logging extension mechanisms > where adapter is placed before the format, ... in the argument list. I agree having `adapter' as the second argument seems weird, so that is fine with me as a follow-up cleanup. However as a user-visible change I think the fix I propose here ought to be applied first (and backported as suitable). Then any internal clean-ups can follow, applied to trunk only. > And there's a simple addition of a blogic_cont macro and extension > to blogic_msg to simplify the logic and obviousness of the logging > extension lines too. I did this first actually, before I realised a simpler change suitable for backporting could be done. I'm not sure if that complex message routing via `blogic_msg' is worth having even, rather than calling `printk' or suitable variants directly. References: [1] "Programming languages -- C", INTERNATIONAL STANDARD, ISO/IEC 9899, Second edition, 1999-12-01, Section 7.19.6.12 "The vsnprintf function", p.293 [2] same, 7.19.6.5 "The snprintf function", p.289 Maciej