mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-13 11:51:32 +00:00
ALSA: info: Small refactoring and a sanity check in snd_info_get_line()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
0d861ac238
commit
0bc0ec903c
@ -700,25 +700,20 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
|
||||
{
|
||||
int c = -1;
|
||||
|
||||
if (snd_BUG_ON(!buffer || !buffer->buffer))
|
||||
return 1;
|
||||
if (len <= 0 || buffer->stop || buffer->error)
|
||||
return 1;
|
||||
while (--len > 0) {
|
||||
c = buffer->buffer[buffer->curr++];
|
||||
if (c == '\n') {
|
||||
if (buffer->curr >= buffer->size)
|
||||
buffer->stop = 1;
|
||||
break;
|
||||
}
|
||||
*line++ = c;
|
||||
if (buffer->curr >= buffer->size) {
|
||||
buffer->stop = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (c != '\n' && !buffer->stop) {
|
||||
while (!buffer->stop) {
|
||||
c = buffer->buffer[buffer->curr++];
|
||||
if (buffer->curr >= buffer->size)
|
||||
buffer->stop = 1;
|
||||
if (c == '\n')
|
||||
break;
|
||||
if (len) {
|
||||
len--;
|
||||
*line++ = c;
|
||||
}
|
||||
}
|
||||
*line = '\0';
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user