mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #20595 from Teufelchen1/fix/vfs_cmd
shell/vfs: Handle print failure in genfile cmd gracefully
This commit is contained in:
commit
5409364222
@ -742,11 +742,19 @@ static char _get_char(unsigned i)
|
|||||||
static void _write_block(int fd, unsigned bs, unsigned i)
|
static void _write_block(int fd, unsigned bs, unsigned i)
|
||||||
{
|
{
|
||||||
char block[bs];
|
char block[bs];
|
||||||
char *buf = block;
|
|
||||||
|
|
||||||
buf += snprintf(buf, bs, "|%03u|", i);
|
int size_wanted = snprintf(block, bs, "|%03u|", i);
|
||||||
|
|
||||||
|
if (size_wanted < 0) {
|
||||||
|
assert(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only memset the buffer, if there is space left in the buffer */
|
||||||
|
if ((unsigned) size_wanted < bs) {
|
||||||
|
memset(&block[size_wanted], _get_char(i), bs - size_wanted);
|
||||||
|
}
|
||||||
|
|
||||||
memset(buf, _get_char(i), &block[bs] - buf);
|
|
||||||
block[bs - 1] = '\n';
|
block[bs - 1] = '\n';
|
||||||
|
|
||||||
vfs_write(fd, block, bs);
|
vfs_write(fd, block, bs);
|
||||||
|
Loading…
Reference in New Issue
Block a user