[0/3] fs: dlm: Fix some issues related to a buffer in dlm_create_debug_file()

Message ID cover.1695403360.git.christophe.jaillet@wanadoo.fr
Headers
Series fs: dlm: Fix some issues related to a buffer in dlm_create_debug_file() |

Message

Christophe JAILLET Sept. 22, 2023, 5:31 p.m. UTC
  The goal of this serie is to remove a warning when building with W=1.
(details in patch 2)

Patch 1 is a preparation step. It is a no-op. The generated code is the same.
Patch 2 is the real fix.
Patch 3 is an additionnal clean-up.

Christophe JAILLET (3):
  fs: dlm: Simplify buffer size computation in dlm_create_debug_file()
  fs: dlm: Fix the size of a buffer in dlm_create_debug_file()
  fs: dlm: Remove some useless memset()

 fs/dlm/debug_fs.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
  

Comments

Alexander Aring Sept. 22, 2023, 8:03 p.m. UTC | #1
Hi,

On Fri, Sep 22, 2023 at 1:38 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> 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 <christophe.jaillet@wanadoo.fr>

there is a similar patch [0] already in the queue for dlm.

- Alex

[0] https://lore.kernel.org/gfs2/20230906143153.1353077-5-aahringo@redhat.com/T/#u