Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp219699pxb; Fri, 16 Apr 2021 04:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJm/6bjYmdK6MJorYRG7O0kJq0+CF9aV2Pg4VrdMkds4VQxOY20QYOjD5cfGKF7F02rikA X-Received: by 2002:a63:f317:: with SMTP id l23mr7449788pgh.173.1618571052194; Fri, 16 Apr 2021 04:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618571052; cv=none; d=google.com; s=arc-20160816; b=l9/et5cfg49O1aL6B1Hgs8zTNDEc3eJFJSJl2iKDn0gfUwbS1qJ1S/iXvWZaI2Uxut M+q/gO88yuxslewmT4dAx/WWQTYCwwLYoIebyKW+gO16+5X1bOqH69+htzwh0Hk/b1ni UbVB6UB5+ehEzZmwjeLD7FnsZxxV7IAd1bfwfvpB0tII4sJPcOu0Iap/vVM6ksskhoVB jYfgzOvrt0TYanAtYF1RCdL1UJxSZT9CVW5mNZxI79ysC6pHNx7pi6ybaQmXY+c1csVf fcUqp3Ra4ZZfHyw5YfFGj3thXHtTxN142vKWt/TdH+ywMzOY3menwBD6rKfiyofLsyt5 vhuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=jdW6mg93jAQnZreJLgEXLGxZIs9bL9joJyqvwbtTO5o=; b=rZvLaYoWvDs4Ho1byvWfda17AEi/TXjIlLyUeohgjvp49Yf+17aNrROZ7Gvol+G1AY yxsZEDj6DwEBzz2tDwpvTZ8Wzg09w1LlD/V4TpiF8OMEyIF4oOpBx4cYkkaDb0XokpTY 9oJh3MXCMnXsiBhBEGWGupbteJWjrHIzlfAd1282hD3hK7fuEzKncPTiILY/GsYGfTFZ QeNNyfmiqwitDG8CyviE/pm+L+8e3+5gCfYUYbC7wWLNNfSUE1rEzFDb4XM4C4fKR1XW Ld58aVk1T30Q117m6y/o2rsS5Jk2Elx9fkgUmDf+hixyJdgXoshHLlHeqLQScb+Zg90J MLgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si6833035plx.202.2021.04.16.04.03.59; Fri, 16 Apr 2021 04:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242481AbhDPKtO (ORCPT + 99 others); Fri, 16 Apr 2021 06:49:14 -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