anchao commented on code in PR #16095:
URL: https://github.com/apache/nuttx/pull/16095#discussion_r2021992236


##########
libs/libc/gdbstub/lib_gdbstub.c:
##########
@@ -671,22 +671,51 @@ static int gdb_recv_ack(FAR struct gdb_state_s *state)
 static ssize_t gdb_bin2hex(FAR void *buf, size_t buf_len,
                            FAR const void *data, size_t data_len)
 {
-  FAR const char *in = data;
+  size_t skip = (uintptr_t)data % 4;
+  size_t ret = data_len * 2;
   FAR char *out = buf;
-  size_t pos;
+  size_t total;
+  uint32_t in;
 
   if (buf_len < data_len * 2)
     {
       return -EOVERFLOW; /* Buffer too small */
     }
 
-  for (pos = 0; pos < data_len; pos++)
+  if (skip != 0)
+    {
+      data = (const void *)((uintptr_t)data & ~(3));

Review Comment:
   ```suggestion
         data = (FAR const void *)((uintptr_t)data & ~3);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to