xiaoxiang781216 commented on code in PR #6998:
URL: https://github.com/apache/incubator-nuttx/pull/6998#discussion_r962964317


##########
fs/smartfs/smartfs_smart.c:
##########
@@ -657,6 +675,18 @@ static ssize_t smartfs_write(FAR struct file *filep, const 
char *buffer,
 
   DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
 
+#ifdef CONFIG_DEBUG_FS_INFO
+  finfo("Writing %lu bytes:", (uint32_t)buflen);
+  for (uint32_t i = 0; i < buflen; ++i)
+    {
+      if ((i & 0x0f) == 0) printf("\n    ");
+
+      printf("%02x, ", buffer[i]);

Review Comment:
   kernel shouldn't call printf



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -45,6 +45,10 @@
 
 #include "smartfs.h"
 
+#ifdef CONFIG_DEBUG_FS_INFO
+#  include <stdio.h>

Review Comment:
   remove, you can't call printf inside kernel



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -528,6 +532,8 @@ static ssize_t smartfs_read(FAR struct file *filep, char 
*buffer,
 
   DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
 
+  finfo("Reading %u bytes\n", (unsigned) buflen);

Review Comment:
   ```
   finfo("Reading %zu bytes\n", buflen);
   ```
   



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -941,6 +971,8 @@ static ssize_t smartfs_write(FAR struct file *filep, const 
char *buffer,
 
   ret = byteswritten;
 
+  finfo("Wrote %u bytes\n", (unsigned) byteswritten);

Review Comment:
   ```
   finfo("Reading %zu bytes\n", byteswritten);
   ```
   



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -852,7 +882,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const 
char *buffer,
           /* Copy the new sector to the old one and chain it */
 
           header = (struct smartfs_chain_header_s *) sf->buffer;
-          *((uint16_t *) header->nextsector) = (uint16_t) ret;
+          SMARTFS_SET_NEXTSECTOR(header, (uint16_t) ret);

Review Comment:
   let's move all cast to SMARTFS_SET_NEXTSECTOR macro



##########
fs/smartfs/smartfs_smart.c:
##########
@@ -633,6 +639,18 @@ static ssize_t smartfs_read(FAR struct file *filep, char 
*buffer,
 
   /* Return the number of bytes we read */
 
+#ifdef CONFIG_DEBUG_FS_INFO
+  finfo("Read %lu bytes:", bytesread);
+  for (uint32_t i = 0; i < bytesread; ++i)
+    {
+      if ((i & 0x0f) == 0) printf("\n    ");
+
+      printf("%02x, ", buffer[i]);

Review Comment:
   ditto



-- 
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