Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1292875rdb; Sun, 8 Oct 2023 00:25:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6VV+iY1saOqQTYLsoHtVb9ABndfevYZ48aUoQgaJWF3MtUx5WuzpI0gnVB5zAqFTsl8Et X-Received: by 2002:a17:90a:db8a:b0:274:945b:6979 with SMTP id h10-20020a17090adb8a00b00274945b6979mr11147782pjv.16.1696749911900; Sun, 08 Oct 2023 00:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696749911; cv=none; d=google.com; s=arc-20160816; b=nKNB/m9tzjvjcsUDqgXZ6Nnz8UCI+9AD8M4b/nT0UKTfA6p04begnpEbg66MDHaGWo 35LwS6sfre4deFDN17uRYUNfS39nq3TJyQED2NHEwgpBuhwiCxXTUJoaFymVmwRzSlBD JqprU3J7BtkbR+ax5uK3iJDL92BGEOGP3FGwCxo5oF03dDGNfZS4TKADTV+3tXTXZWdG F+NyblJ8KhuQemOYwUHI+HDuKHeLeGo+55hN40BNbb7+2iIbGPvkDguXVltx/e2N5kdB D/BDUU6ild5zhklgSWYJGfymgyi48GR10IrpusVfNkaatfq2I9EsI51ulLUDHycRjiH4 Czng== 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 :message-id:date:subject:cc:to:from; bh=bWUioEfiB/2TJ2EtCq76N4CJXFYJd497RGA2drm22L0=; fh=1/WWFQbaHGnWfhTQyDj/slLim+4/8pKOOIVyLD6UxP4=; b=iNGwk1Plm7WvbzGhlRm6J7nNuIrdPuTfeWX91UyFcifK4756EXfufmcg+jt9zBI2F+ ZHzpKdljflyzp+8dSv+k+b5UfDzrjtmUj2zHUHHfwsfkAWH1leE626Zn9g6YVx0oBNEm H9yuDdz+iMhpJ9BED75H+VcfAVK8VSE6MuNz6HHtCIvzUkOZdTP7qa8L0Le803pSo0Tr +jqHbUrvWxdBJoLuNNDVb4OP4xd1xO96ux7BUPg8EcqVwEcyoJkd+lgznEKCM1yl3Cuv wHKWz5vgvU6h+Wwh5bEshfovJ//kXq0bLKRGi8sfjH6GZqx8IjhryHMgJK/+g4upl2dq 2vMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ga4-20020a17090b038400b00271af83a25asi9446433pjb.59.2023.10.08.00.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 00:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9C49980AA26E; Sun, 8 Oct 2023 00:25:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344487AbjJHHYx (ORCPT + 99 others); Sun, 8 Oct 2023 03:24:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJHHYw (ORCPT ); Sun, 8 Oct 2023 03:24:52 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 9B5F6B9; Sun, 8 Oct 2023 00:24:49 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 4F7A9604A87F9; Sun, 8 Oct 2023 15:24:35 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: ccaulfie@redhat.com, teigland@redhat.com Cc: Su Hui , gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] fs: dlm: silence truncated string warning Date: Sun, 8 Oct 2023 15:24:24 +0800 Message-Id: <20231008072423.556591-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 08 Oct 2023 00:25:09 -0700 (PDT) X-Spam-Level: ** Using gcc and W=1 option, there are some warning like these: fs/dlm/debug_fs.c: In function ‘dlm_create_debug_file’: fs/dlm/debug_fs.c:1020:51: 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:2: 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:43: 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); | ^~~~~~~~~~~~ The length of 'ls->ls_name' is 'DLM_LOCKSPACE_LEN + 1'. So string "%s_waiters" can up to 'DLM_LOCKSPACE_LEN + 9' and string "%s_queued_asts" can up to 'DLM_LOCKSPACE_LEN + 13'. Signed-off-by: Su Hui --- fs/dlm/debug_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c index 5aabcb6f0f15..d0b34b9fbdaf 100644 --- a/fs/dlm/debug_fs.c +++ b/fs/dlm/debug_fs.c @@ -973,7 +973,7 @@ void dlm_delete_debug_comms_file(void *ctx) void dlm_create_debug_file(struct dlm_ls *ls) { - char name[DLM_LOCKSPACE_LEN + 8]; + char name[DLM_LOCKSPACE_LEN + 13]; /* format 1 */ @@ -1017,7 +1017,7 @@ void dlm_create_debug_file(struct dlm_ls *ls) &format4_fops); memset(name, 0, sizeof(name)); - snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name); + snprintf(name, DLM_LOCKSPACE_LEN + 9, "%s_waiters", ls->ls_name); ls->ls_debug_waiters_dentry = debugfs_create_file(name, 0644, @@ -1028,7 +1028,7 @@ void dlm_create_debug_file(struct dlm_ls *ls) /* format 5 */ memset(name, 0, sizeof(name)); - snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name); + snprintf(name, DLM_LOCKSPACE_LEN + 13, "%s_queued_asts", ls->ls_name); ls->ls_debug_queued_asts_dentry = debugfs_create_file(name, 0644, -- 2.30.2