Skip to content

Commit 30f5059

Browse files
committed
debugfs: take better advantage of strscpy.
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
1 parent f855f4a commit 30f5059

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

fs/orangefs/orangefs-debugfs.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,10 @@ void orangefs_debugfs_init(int debug_mask)
238238
static void orangefs_kernel_debug_init(void)
239239
{
240240
static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
241-
size_t len = strlen(kernel_debug_string);
241+
size_t len =
242+
strscpy(k_buffer, kernel_debug_string, sizeof(k_buffer) - 1);
242243

243-
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
244-
245-
if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
246-
memcpy(k_buffer, kernel_debug_string, len);
244+
if (len > 0) {
247245
k_buffer[len] = '\n';
248246
k_buffer[len + 1] = '\0';
249247
} else {
@@ -339,12 +337,10 @@ static int help_show(struct seq_file *m, void *v)
339337
static void orangefs_client_debug_init(void)
340338
{
341339
static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
342-
size_t len = strlen(client_debug_string);
343-
344-
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
340+
size_t len =
341+
strscpy(c_buffer, client_debug_string, sizeof(c_buffer) - 1);
345342

346-
if (len + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
347-
memcpy(c_buffer, client_debug_string, len);
343+
if (len > 0) {
348344
c_buffer[len] = '\n';
349345
c_buffer[len + 1] = '\0';
350346
} else {

0 commit comments

Comments
 (0)