Fixed coding std violations in nsh_fsutils.h
This commit is contained in:
parent
0d74608b2c
commit
76e58d9e55
@ -102,7 +102,7 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
||||||
if(buffer == NULL)
|
if (buffer == NULL)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
nsh_error(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
nsh_error(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
||||||
@ -111,7 +111,7 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
|
|
||||||
/* And just dump it byte for byte into stdout */
|
/* And just dump it byte for byte into stdout */
|
||||||
|
|
||||||
for (;;)
|
for (; ; )
|
||||||
{
|
{
|
||||||
int nbytesread = read(fd, buffer, IOBUFFERSIZE);
|
int nbytesread = read(fd, buffer, IOBUFFERSIZE);
|
||||||
|
|
||||||
@ -129,7 +129,8 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nsh_error(vtbl, g_fmtcmdfailed, cmd, "read", NSH_ERRNO_OF(errval));
|
nsh_error(vtbl, g_fmtcmdfailed, cmd, "read",
|
||||||
|
NSH_ERRNO_OF(errval));
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ERROR;
|
ret = ERROR;
|
||||||
@ -144,7 +145,8 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
|
|
||||||
while (nbyteswritten < nbytesread)
|
while (nbyteswritten < nbytesread)
|
||||||
{
|
{
|
||||||
ssize_t n = nsh_write(vtbl, buffer + nbyteswritten, nbytesread - nbyteswritten);
|
ssize_t n = nsh_write(vtbl, buffer + nbyteswritten,
|
||||||
|
nbytesread - nbyteswritten);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
int errcode = errno;
|
int errcode = errno;
|
||||||
@ -179,18 +181,18 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE that the following NSH prompt may appear on the same line as file
|
/* NOTE that the following NSH prompt may appear on the same line as file
|
||||||
* content. The IEEE Std requires that "The standard output shall
|
* content. The IEEE Std requires that "The standard output shall
|
||||||
* contain the sequence of bytes read from the input files. Nothing else
|
* contain the sequence of bytes read from the input files. Nothing else
|
||||||
* shall be written to the standard output." Reference:
|
* shall be written to the standard output." Reference:
|
||||||
* https://pubs.opengroup.org/onlinepubs/009695399/utilities/cat.html.
|
* https://pubs.opengroup.org/onlinepubs/009695399/utilities/cat.html.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Close the input file and return the result */
|
/* Close the input file and return the result */
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user