jingfei195887 commented on code in PR #3130:
URL: https://github.com/apache/nuttx-apps/pull/3130#discussion_r2234846113


##########
examples/mtdpart/mtdpart_main.c:
##########
@@ -530,19 +507,47 @@ int main(int argc, FAR char *argv[])
             {
               printf("ERROR: Bad value %lu, expected %lu\n",
                      (long)buffer[k], (long)(~check));
-              fflush(stdout);
-              exit(27);
+              close(fd);
+              status = 23;
+              goto errout;
             }
 
           check += sizeof(uint32_t);
         }
     }
 
   close(fd);
+  status = 0;
 
   /* And exit without bothering to clean up */
 
   printf("PASS: Everything looks good\n");
+
+errout:
+
+  if (status)
+    {
+      printf("ERROR: error status %d\n", status);
+    }
+
+  if (buffer)
+    {
+      free(buffer);
+    }
+
+  if (master)

Review Comment:
   In new version of this patch, none of the variables in the main function 
need initial values. Also, during error handling, there's no need to check if 
master and buffer are null, or if fd is greater than or equal to 0.



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