shell: use amount of bytes returned from mufs_read()

This commit is contained in:
S.J.R. van Schaik 2017-10-23 13:38:25 +02:00
parent d1457e8be6
commit 6fb626d601

View file

@ -159,6 +159,7 @@ int shell_cat(struct console *con, size_t argc, const char **argv)
{
char data[256];
struct mufs_file *file;
size_t ret;
if (argc < 1) {
fprintf(con->fp, "usage: mufs cat <path>\n");
@ -175,8 +176,8 @@ int shell_cat(struct console *con, size_t argc, const char **argv)
return -1;
}
while (mufs_read(file, data, sizeof data) != 0) {
fwrite(data, sizeof *data, sizeof data, con->fp);
while ((ret = mufs_read(file, data, sizeof data)) != 0) {
fwrite(data, sizeof *data, ret, con->fp);
}
mufs_close(file);