# SDL: Fixed line wrapping for HID packet dump (98886)

**URL:** <https://discourse.libsdl.org/t/sdl-fixed-line-wrapping-for-hid-packet-dump-98886/41546>\
**Category:** SDL Commits\
**Created:** [January 3, 2023, 11:14pm UTC](https://discourse.libsdl.org/t/sdl-fixed-line-wrapping-for-hid-packet-dump-98886/41546 "2023-01-03T23:14:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [January 3, 2023, 11:14pm UTC](https://discourse.libsdl.org/t/sdl-fixed-line-wrapping-for-hid-packet-dump-98886/41546/1 "2023-01-03T23:14:21Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/988866ca4a4e4619ddf15621aad9a370f8c1deed>
>
> (cherry picked from commit e85839cd5694a79f69ac16f48a5d845cdc62f809)

```diff
From 988866ca4a4e4619ddf15621aad9a370f8c1deed Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 3 Jan 2023 15:12:47 -0800
Subject: [PATCH] Fixed line wrapping for HID packet dump

(cherry picked from commit e85839cd5694a79f69ac16f48a5d845cdc62f809)
---
 src/joystick/hidapi/SDL_hidapijoystick.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index c6d9b7651bc0..cd37de1152b9 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -103,15 +103,15 @@ void HIDAPI_DumpPacket(const char *prefix, const Uint8 *data, int size)
     char *buffer;
     size_t length = SDL_strlen(prefix) + 11 * (USB_PACKET_LENGTH / 8) + (5 * USB_PACKET_LENGTH * 2) + 1 + 1;
     int start = 0, amount = size;
+ size_t current_len;
 
     buffer = (char *)SDL_malloc(length);
- (void)SDL_snprintf(buffer, length, prefix, size);
+ current_len = SDL_snprintf(buffer, length, prefix, size);
     for (i = start; i < start + amount; ++i) {
- size_t current_len = SDL_strlen(buffer);
         if ((i % 8) == 0) {
- (void)SDL_snprintf(&buffer[current_len], length - current_len, "\n%.2d: ", i);
+ current_len += SDL_snprintf(&buffer[current_len], length - current_len, "\n%.2d: ", i);
         }
- (void)SDL_snprintf(&buffer[current_len], length - current_len, " 0x%.2x", data[i]);
+ current_len += SDL_snprintf(&buffer[current_len], length - current_len, " 0x%.2x", data[i]);
     }
     SDL_strlcat(buffer, "\n", length);
     SDL_Log("%s", buffer);

```
