From patchwork Fri Sep 22 17:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 143757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp14670vqg; Fri, 22 Sep 2023 18:03:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh4qj5rIwt6HTYQ8gOSlqv4OUhLmnoyRSXIBrqOSBF2UNAH18h+CY4UoHqQVho2IUqA3c1 X-Received: by 2002:a17:90a:8a82:b0:277:1355:f9e9 with SMTP id x2-20020a17090a8a8200b002771355f9e9mr1040247pjn.22.1695431005525; Fri, 22 Sep 2023 18:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695431005; cv=none; d=google.com; s=arc-20160816; b=L8NL7IuumSWi+9OtbA96wBBIvwirC3MwPB7hylr3mB/5AE+mFnG0O91R9X7jjOi719 7qSE15ltZvOIR4V/p7ktTMPTlZGrjDnkARl0s9xtt6hTCHvJIhxqV/YLpg6yvdPt4swj DC/6ZaOR2tch3LyvE3RvUqEw02bfjdywvM74wUplagt0KHsC8xUTDrDQi50QkNj7FX3u oeeIlQuZsGsr1rVJyFjT0c6Oam+Oh/A9zpG3mbeSJ3AxZQ6+GsJEDZROVTsfk++6Db/X zS31EhGd6cJY1XZBUGqje+zoQqJdqVVisG/Gsv3YZeNdfwPgzuHaTClld0Eq1paNmi3S kAMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Mdh92zSNjb03Q7lpVvrUXLMKkbkfsGWVKmrcZV58LM=; fh=QXaw1e1gPDXT7ATLTrtpu9GySlwh+M/3gCHvQFIK2SQ=; b=n1T9TBdnq0gJDsXohSyAQ1BBR2EGzYMsilM5hX9SzFmhutCO6VM+AnsIwa5DLXBDz/ TygXhLhMGp3M7ogNiI+tmJa911kMwGid1Kci0AvTWoU8F5y3Ii20YiVMgxVWpGIwIoF7 IFHnnIoEdVJ7ke9UQBEJnD9x2wvVXEee4+d9lVFac7RzGiphNvovPcjYej40Cd1/ZLzM hbYSFB/Jf48cG1WTSPzgQ/MQJfublDMhRzb7lQfMVFmWxT40GEzXsJpfXbVpFKxSXl+q cKCHdYI17DIe4QZkZOhQCmiQzwZIsQLBekqpDO1pB12Aj7KuDJeqjbaANIdd+aT1UrRV ewIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="AZd/C7jz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x17-20020a17090a8a9100b0026d4659a4d4si6984358pjn.145.2023.09.22.18.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 18:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="AZd/C7jz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6277882A68B2; Fri, 22 Sep 2023 10:32:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233170AbjIVRcV (ORCPT + 28 others); Fri, 22 Sep 2023 13:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbjIVRcC (ORCPT ); Fri, 22 Sep 2023 13:32:02 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14AC7FB for ; Fri, 22 Sep 2023 10:31:22 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jjzlq1mvsWkeLjjztquw11; Fri, 22 Sep 2023 19:31:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695403881; bh=6Mdh92zSNjb03Q7lpVvrUXLMKkbkfsGWVKmrcZV58LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AZd/C7jzdQa8ngS7YatO0pIUnC9sf4kMD7wM3+F9BD1uFMFkcWVNsYh0f1LIt9D4Z joUYrPlswQyOQV56ZVyVwIERfHNwU4fUfhCWHUl1I4/edi36ISh9wFUgkJ0GtrLyBp 3FDS/eM5ItGXeXr8HMPwL62+CNLbog2c6azapzDX0SmDSl8PX+M7BGGN65X+IKEP5o gVQXSRuscfpeSnZBt0m7/rXpUGJpnqcwNF/bmlY0sbfTPWvOWj7+UFT5J57uyOUUcP I29cFGtpQWeE+fED1ZTviktVnCGi/ibU1bM3OU9NSl7dzla5FS0LcPWLh7ntXpA+4t hzxGrCDr3kPzw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 22 Sep 2023 19:31:21 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Christine Caulfield , David Teigland , Alexander Aring Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , gfs2@lists.linux.dev Subject: [PATCH 2/3] fs: dlm: Fix the size of a buffer in dlm_create_debug_file() Date: Fri, 22 Sep 2023 19:31:09 +0200 Message-Id: <6083c5d6e7e4eb567bf6f5cbb5bdf6b0286cee45.1695403360.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:32:32 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777784355053929556 X-GMAIL-MSGID: 1777788262192813808 8 is not the maximum size of the suffix used when creating debugfs files. Let the compiler compute the correct size, and only give a hint about the longest possible string that is used. When building with W=1, this fixes the following warnings: fs/dlm/debug_fs.c: In function ‘dlm_create_debug_file’: fs/dlm/debug_fs.c:1020:58: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 1020 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name); | ^ fs/dlm/debug_fs.c:1020:9: note: ‘snprintf’ output between 9 and 73 bytes into a destination of size 72 1020 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/dlm/debug_fs.c:1031:50: error: ‘_queued_asts’ directive output may be truncated writing 12 bytes into a region of size between 8 and 72 [-Werror=format-truncation=] 1031 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name); | ^~~~~~~~~~~~ fs/dlm/debug_fs.c:1031:9: note: ‘snprintf’ output between 13 and 77 bytes into a destination of size 72 1031 | snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 541adb0d4d10b ("fs: dlm: debugfs for queued callbacks") Signed-off-by: Christophe JAILLET --- fs/dlm/debug_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index e9726c6cbdf2..c93359ceaae6 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c @@ -973,7 +973,8 @@ void dlm_delete_debug_comms_file(void *ctx) void dlm_create_debug_file(struct dlm_ls *ls) { - char name[DLM_LOCKSPACE_LEN + 8]; + /* Reserve enough space for the longest file name */ + char name[DLM_LOCKSPACE_LEN + sizeof("_queued_asts")]; /* format 1 */ From patchwork Fri Sep 22 17:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 143631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5831453vqi; Fri, 22 Sep 2023 12:56:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEH/pCLzhXKxSzEnNHwb6J1JX4KAfSyB1Wa7TYK7K7Mlh2LSVuhfMb2vKPAeV0p1UlN98YU X-Received: by 2002:a05:6a00:13a0:b0:690:c75e:25d7 with SMTP id t32-20020a056a0013a000b00690c75e25d7mr423553pfg.18.1695412586159; Fri, 22 Sep 2023 12:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695412586; cv=none; d=google.com; s=arc-20160816; b=y1o7b08ajg4X4rsYoV06Z8Rh8O7VRRiRBIuAxRs8fuRbReZrydOxmZ3g3bbOf/uX4c 2224i2V2lu+3jdNXvbaWWQPRdWSQzUf2Z64ryx+nDFcm+PLIoi33iw6kKeWsgT9/AZV3 zffn5zD1C24KvEgy2kEIkx7/Ycdd8pCqEarpCliZbedSuz/50M8OAttRQC1URF6iyoV9 fla24H9s1GEVn8LIoka3/mZDjBpmaGhBJ4VbOXtgInfAdvIVJswy1ySbS1x1rzoz5h+w vi20u4KLPdC4n6gdcqYe8P5Q/AdjLHjySNy5JBhrDueOoXtMRLKfXCfoJ+y8DKCpwiqB +MXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V2TWwOebnSbbI2cNxOy+6tSiLTe5TgHaacu+uy4XtWI=; fh=5d5DzgLQCEotuv+RjGWAyxY8dXgdXesvIaUFZnqx0hw=; b=KRKjZUzWD0LIsDrITNM28SKiLFtluDJidjms5Z4EEGPXxKvpW2HhlpErmz2SSyUsqW BLbMe+jyoTHfqFRaKn1ocuDHOOVdixVUqwfpLQOTt2/87wLkcb6A/b5g8IbxfrgELPE/ 6w31UOKQJ/bJ07MDEzjiajHaTjB+Ck8E5OnSEquisgZ/f7/DZ4s3lIT/Sf9+DKG14zc/ H27zHNSb4HMI8H7wwVbjxsnz7UsGhnsE5u7/ouW6ttdb9qlO3+fIRAS4OeSV6ee4zHV/ 5s5coRMMUw2612iR7y6jxGXmQALV6OV1BsxUpIebveMIkYHJfJcvZZklZbYDObpU06x9 hB2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TX6zHgc9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q17-20020a056a00085100b0068bc3b540b0si4528352pfk.390.2023.09.22.12.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=TX6zHgc9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B168E82AB449; Fri, 22 Sep 2023 10:32:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233394AbjIVRcX (ORCPT + 28 others); Fri, 22 Sep 2023 13:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233083AbjIVRcC (ORCPT ); Fri, 22 Sep 2023 13:32:02 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F360394 for ; Fri, 22 Sep 2023 10:31:23 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jjzlq1mvsWkeLjjzuquw1D; Fri, 22 Sep 2023 19:31:22 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695403882; bh=V2TWwOebnSbbI2cNxOy+6tSiLTe5TgHaacu+uy4XtWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TX6zHgc928K0ZEdheeOI3LHvylT2Zk+3802M3kwf7zwKf6/tNyJV2hrS0t2QDL6zm y17PxnNEsUNJtz3rB4eIs7+J97GsfmCA5+4lBwF2d1XL7JZbnoVE985mg3NYAV3t+/ 9fGYZmwB3YwvOiUCg5Kb92t+mxWukCCCsdjVOYTFaGW2kf1SREFy6d3ijUqqWHXqrO fkdgUd3NCgOn25vktljueaiheiiN3VPmdctVP4ZnkyEo1uD/d3ouUbWfKkKBEoi/iK 7V/JJcmQnD/sTem8fmoMZoRPACWoB/qCD1N2bdsXQ3rj76jI5VJh3Hczk85olXLvOa 1mAMhDtGfhbdg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 22 Sep 2023 19:31:22 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Christine Caulfield , David Teigland Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , gfs2@lists.linux.dev Subject: [PATCH 3/3] fs: dlm: Remove some useless memset() Date: Fri, 22 Sep 2023 19:31:10 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:32:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777768948054641136 X-GMAIL-MSGID: 1777768948054641136 There is no need to clear the buffer used to build the file name. snprintf() already guarantees that it is NULL terminated and such a (useless) precaution was not done for the first string (i.e ls_debug_rsb_dentry) So, save a few LoC. Signed-off-by: Christophe JAILLET --- fs/dlm/debug_fs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index c93359ceaae6..42f332f46359 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c @@ -986,7 +986,6 @@ void dlm_create_debug_file(struct dlm_ls *ls) /* format 2 */ - memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "%s_locks", ls->ls_name); ls->ls_debug_locks_dentry = debugfs_create_file(name, @@ -997,7 +996,6 @@ void dlm_create_debug_file(struct dlm_ls *ls) /* format 3 */ - memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "%s_all", ls->ls_name); ls->ls_debug_all_dentry = debugfs_create_file(name, @@ -1008,7 +1006,6 @@ void dlm_create_debug_file(struct dlm_ls *ls) /* format 4 */ - memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "%s_toss", ls->ls_name); ls->ls_debug_toss_dentry = debugfs_create_file(name, @@ -1017,7 +1014,6 @@ void dlm_create_debug_file(struct dlm_ls *ls) ls, &format4_fops); - memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "%s_waiters", ls->ls_name); ls->ls_debug_waiters_dentry = debugfs_create_file(name, @@ -1028,7 +1024,6 @@ void dlm_create_debug_file(struct dlm_ls *ls) /* format 5 */ - memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "%s_queued_asts", ls->ls_name); ls->ls_debug_queued_asts_dentry = debugfs_create_file(name,