[PATCH v2 0/2] Use memcpy_and_pad for jset_entry_log->d init

Roxana Nicolescu posted 2 patches 8 months, 3 weeks ago
fs/bcachefs/btree_trans_commit.c | 3 ++-
fs/bcachefs/btree_update.c       | 8 +++-----
2 files changed, 5 insertions(+), 6 deletions(-)
[PATCH v2 0/2] Use memcpy_and_pad for jset_entry_log->d init
Posted by Roxana Nicolescu 8 months, 3 weeks ago
This replaces the depracated usage of strncpy with memcpy_and_pad when
used for initializing the d buffer of the struct jset_entry_log.

The other 2 usage of memcpy were also replaced by memcpy_and_pad.

Changes since v1:
- since the dest buffer is not required to be NULL-terminated,
  memcpy_and_pad is used instead of strscpy. This adds zeros at the end
  of the buffer if there's extra room.
- the same mechanism was done before in both __bch2_fs_log_msg() and
bch2_trans_log_msg by zero-ing out the src buffer. The second patch
replaces that logic with memcpy_and_pad to provide uniformity.

Roxana Nicolescu (2):
  bcachefs: replace strncpy() with memcpy_and_pad in
    journal_transaction_name
  bcachefs: replace memcpy with memcpy_and_pad for jset_entry_log->d
    buff

 fs/bcachefs/btree_trans_commit.c | 3 ++-
 fs/bcachefs/btree_update.c       | 8 +++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.34.1
Re: [PATCH v2 0/2] Use memcpy_and_pad for jset_entry_log->d init
Posted by Kent Overstreet 8 months, 3 weeks ago
On Thu, Mar 27, 2025 at 02:49:58PM +0000, Roxana Nicolescu wrote:
> This replaces the depracated usage of strncpy with memcpy_and_pad when
> used for initializing the d buffer of the struct jset_entry_log.
> 
> The other 2 usage of memcpy were also replaced by memcpy_and_pad.
> 
> Changes since v1:
> - since the dest buffer is not required to be NULL-terminated,
>   memcpy_and_pad is used instead of strscpy. This adds zeros at the end
>   of the buffer if there's extra room.
> - the same mechanism was done before in both __bch2_fs_log_msg() and
> bch2_trans_log_msg by zero-ing out the src buffer. The second patch
> replaces that logic with memcpy_and_pad to provide uniformity.
> 
> Roxana Nicolescu (2):
>   bcachefs: replace strncpy() with memcpy_and_pad in
>     journal_transaction_name
>   bcachefs: replace memcpy with memcpy_and_pad for jset_entry_log->d
>     buff
> 
>  fs/bcachefs/btree_trans_commit.c | 3 ++-
>  fs/bcachefs/btree_update.c       | 8 +++-----
>  2 files changed, 5 insertions(+), 6 deletions(-)

Thanks, series is applied.