From: Takashi Iwai <tiwai@suse.de>
To: Adam Miartus <amiartus@de.adit-jv.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/3] pcm_file: improve error checking in write_wav_header function
Date: Wed, 03 Jul 2019 14:21:45 +0200 [thread overview]
Message-ID: <s5hy31f2tra.wl-tiwai@suse.de> (raw)
In-Reply-To: <1561987518-2828-3-git-send-email-amiartus@de.adit-jv.com>
On Mon, 01 Jul 2019 15:25:17 +0200,
Adam Miartus wrote:
>
> previously errno would be returned even for cases where it may have
> not been populated, for example one of the write functions failing,
> or writing only partial buffer,
>
> now progress through write operations separately and report errno when
> appropriate
>
> Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com>
> Reviewed-by: Timo Wischer <twischer@de.adit-jv.com>
The code changes look OK, but just some cosmetic things:
> @@ -341,15 +343,36 @@ static int write_wav_header(snd_pcm_t *pcm)
>
> setup_wav_header(pcm, &file->wav_header);
>
> - if (write(file->fd, header, sizeof(header)) != sizeof(header) ||
> - write(file->fd, &file->wav_header, sizeof(file->wav_header)) !=
> - sizeof(file->wav_header) ||
> - write(file->fd, header2, sizeof(header2)) != sizeof(header2)) {
> - int err = errno;
> - SYSERR("%s write header failed, file data may be corrupt", file->fname);
> - return -err;
> + res = write(file->fd, header, sizeof(header));
> + if (res != sizeof(header)) {
> + goto write_error;
> + }
Please drop the unnecessary braces here (and in other lines).
We follow the Linux kernel coding style in general.
> +write_error:
> + // print real errno if available and return EIO, reason for this is to block possible
> + // EPIPE in case file->fd is a pipe. EPIPE from file->fd conflicts with EPIPE from
> + // playback stream which should be used to signal XRUN on playback devic
e
Avoid C++ comments but keep in C-style.
Also, try to keep the line in 80chars as much as possible.
thanks,
Takashi
next prev parent reply other threads:[~2019-07-03 12:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 13:25 [PATCH 0/3] pcm_file report EIO when fail to write to debug file Adam Miartus
2019-07-01 13:25 ` [PATCH 1/3] pcm_file: use EIO instead of EPIPE when failing to write output file Adam Miartus
2019-07-03 12:23 ` Takashi Iwai
2019-07-01 13:25 ` [PATCH 2/3] pcm_file: improve error checking in write_wav_header function Adam Miartus
2019-07-03 12:21 ` Takashi Iwai [this message]
2019-07-01 13:25 ` [PATCH 3/3] pcm_file: in case of failed write clear file buffer variables Adam Miartus
2019-07-03 12:23 ` Takashi Iwai
2019-07-03 12:23 ` [PATCH 0/3] pcm_file report EIO when fail to write to debug file Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hy31f2tra.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=amiartus@de.adit-jv.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox