xiaoxiang781216 commented on code in PR #3130:
URL: https://github.com/apache/nuttx-apps/pull/3130#discussion_r2214853980
##########
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);
Review Comment:
remove the unnecessary log
##########
examples/mtdpart/mtdpart_main.c:
##########
@@ -133,8 +133,7 @@ int main(int argc, FAR char *argv[])
FAR struct mtd_dev_s *part[CONFIG_EXAMPLES_MTDPART_NPARTITIONS + 1];
FAR struct mtd_geometry_s geo;
FAR uint32_t *buffer;
Review Comment:
need zero
##########
examples/mtdpart/mtdpart_main.c:
##########
@@ -179,22 +179,12 @@ int main(int argc, FAR char *argv[])
* interesting.
*/
- ret = ftl_initialize(0, master);
+ ret = register_mtddriver("/dev/mtd0", master, 0775, NULL);
if (ret < 0)
{
- printf("ERROR: ftl_initialize /dev/mtdblock0 failed: %d\n", ret);
- fflush(stdout);
- exit(2);
- }
-
- /* Now create a character device on the block device */
-
- ret = bchdev_register("/dev/mtdblock0", "/dev/mtd0", false);
- if (ret < 0)
- {
- printf("ERROR: bchdev_register /dev/mtd0 failed: %d\n", ret);
- fflush(stdout);
- exit(3);
+ printf("ERROR: register_mtddriver /dev/mtd0 failed: %d\n", ret);
+ status = 2;
+ goto errout;
Review Comment:
goto err_mtd
##########
examples/mtdpart/mtdpart_main.c:
##########
@@ -280,8 +257,8 @@ int main(int argc, FAR char *argv[])
if (!buffer)
{
printf("ERROR: failed to allocate a sector buffer\n");
- fflush(stdout);
- exit(7);
+ status = 6;
+ goto errout;
Review Comment:
goto err_buf
##########
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:
need zero at line 132, please fix ALL warning before submit your change.
##########
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)
Review Comment:
remove the check
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]