<div dir="ltr">This looks ok. I will push it.<div><br></div><div>Coverity is run up 1215 am and 1215 pm my time (910am now) so we should have feedback in a few hours.</div><div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 16, 2023 at 7:04 PM <<a href="mailto:aaron.nyholm@unfoldedeffective.com">aaron.nyholm@unfoldedeffective.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Aaron Nyholm <<a href="mailto:aaron.nyholm@southerninnovation.com" target="_blank">aaron.nyholm@southerninnovation.com</a>><br>
<br>
Coverity #1530126<br>
Coverity #1530125<br>
---<br>
cpukit/libmisc/shell/main_flashdev.c | 27 ++++++++++-----------------<br>
1 file changed, 10 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/cpukit/libmisc/shell/main_flashdev.c b/cpukit/libmisc/shell/main_flashdev.c<br>
index 495373235f..ca2454b33c 100644<br>
--- a/cpukit/libmisc/shell/main_flashdev.c<br>
+++ b/cpukit/libmisc/shell/main_flashdev.c<br>
@@ -78,6 +78,15 @@ static int rtems_flashdev_shell_main( int argc, char *argv[] ) {<br>
<br>
for (i = 1; i < argc; ++i) {<br>
if (argv[i][0] == '-') {<br>
+ /*<br>
+ * Check that a path to flashdev has been provided before running<br>
+ * command.<br>
+ */<br>
+ if (dev_path == NULL) {<br>
+ printf("Please input FLASH_DEV_PATH before instruction\n");<br>
+ return 1;<br>
+ }<br>
+ /* Run command */<br>
switch (argv[i][1]) {<br>
case ('r'):<br>
/* Read */<br>
@@ -112,7 +121,6 @@ static int rtems_flashdev_shell_main( int argc, char *argv[] ) {<br>
printf(rtems_flashdev_shell_usage);<br>
break;<br>
}<br>
-<br>
} else if (dev_path == NULL) {<br>
dev_path = argv[i];<br>
} else {<br>
@@ -145,10 +153,6 @@ int flashdev_shell_read(<br>
printf("Missing argument\n");<br>
return -1;<br>
}<br>
- if (dev_path == NULL) {<br>
- printf("Please input FLASH_DEV_PATH before instruction\n");<br>
- return 1;<br>
- }<br>
<br>
/* Get arguments */<br>
errno = 0;<br>
@@ -181,6 +185,7 @@ int flashdev_shell_read(<br>
buffer = calloc((bytes + bytes%4), 1);<br>
if (buffer == NULL) {<br>
printf("Failed to allocate read buffer\n");<br>
+ close(fd);<br>
return -1;<br>
}<br>
<br>
@@ -230,10 +235,6 @@ int flashdev_shell_write(<br>
printf("Missing argument\n");<br>
return -1;<br>
}<br>
- if (dev_path == NULL) {<br>
- printf("Please input FLASH_DEV_PATH before instruction\n");<br>
- return 1;<br>
- }<br>
<br>
/* Get arguments */<br>
errno = 0;<br>
@@ -337,10 +338,6 @@ int flashdev_shell_erase(<br>
printf("Missing argument\n");<br>
return -1;<br>
}<br>
- if (dev_path == NULL) {<br>
- printf("Please input FLASH_DEV_PATH before instruction\n");<br>
- return 1;<br>
- }<br>
<br>
/* Get arguments */<br>
errno = 0;<br>
@@ -546,10 +543,6 @@ static int flashdev_shell_page(<br>
printf("Missing argument\n");<br>
return -1;<br>
}<br>
- if (dev_path == NULL) {<br>
- printf("Please input FLASH_DEV_PATH before instruction\n");<br>
- return 1;<br>
- }<br>
<br>
/* Get arguments */<br>
errno = 0;<br>
-- <br>
2.25.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>