This patch is fixing the following compiler warning when compiling with
-Wformat-truncation:

fs/dlm/debug_fs.c:1031:50: warning: '_queued_asts' directive output may
be truncated writing 12 bytes into a region of size between 8 and 72

We simple increase the additional amount of bytes to 13 because
_queued_asts does not fit into 8 bytes when the whole lockspace name
length is being used.

Fixes: 541adb0d4d10 ("fs: dlm: debugfs for queued callbacks")
Signed-off-by: Alexander Aring <aahri...@redhat.com>
---
 fs/dlm/debug_fs.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 5aabcb6f0f15..698d6b7a20f8 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -20,6 +20,7 @@
 #include "lock.h"
 #include "ast.h"
 
+#define DLM_DEBUG_NAME_LEN (DLM_LOCKSPACE_LEN + 13)
 #define DLM_DEBUG_BUF_LEN 4096
 static char debug_buf[DLM_DEBUG_BUF_LEN];
 static struct mutex debug_buf_lock;
@@ -973,7 +974,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_DEBUG_NAME_LEN];
 
        /* format 1 */
 
@@ -986,7 +987,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
        /* format 2 */
 
        memset(name, 0, sizeof(name));
-       snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_locks", ls->ls_name);
+       snprintf(name, DLM_DEBUG_NAME_LEN, "%s_locks", ls->ls_name);
 
        ls->ls_debug_locks_dentry = debugfs_create_file(name,
                                                        0644,
@@ -997,7 +998,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
        /* format 3 */
 
        memset(name, 0, sizeof(name));
-       snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_all", ls->ls_name);
+       snprintf(name, DLM_DEBUG_NAME_LEN, "%s_all", ls->ls_name);
 
        ls->ls_debug_all_dentry = debugfs_create_file(name,
                                                      S_IFREG | S_IRUGO,
@@ -1008,7 +1009,7 @@ void dlm_create_debug_file(struct dlm_ls *ls)
        /* format 4 */
 
        memset(name, 0, sizeof(name));
-       snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_toss", ls->ls_name);
+       snprintf(name, DLM_DEBUG_NAME_LEN, "%s_toss", ls->ls_name);
 
        ls->ls_debug_toss_dentry = debugfs_create_file(name,
                                                       S_IFREG | S_IRUGO,
@@ -1017,7 +1018,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_DEBUG_NAME_LEN, "%s_waiters", ls->ls_name);
 
        ls->ls_debug_waiters_dentry = debugfs_create_file(name,
                                                          0644,
@@ -1028,7 +1029,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_DEBUG_NAME_LEN, "%s_queued_asts", ls->ls_name);
 
        ls->ls_debug_queued_asts_dentry = debugfs_create_file(name,
                                                              0644,
-- 
2.31.1

Reply via email to