denser error handling style

This commit is contained in:
Henry Eklind 2016-07-20 11:08:43 +02:00
parent 19a80bb8a8
commit c404968f8c
No known key found for this signature in database
GPG key ID: D90EA149CDA76654

View file

@ -18,11 +18,10 @@ type VorbisComment struct {
// parseVorbisComment reads and parses the body of an VorbisComment metadata
// block.
func (block *Block) parseVorbisComment() error {
func (block *Block) parseVorbisComment() (err error) {
// 32 bits: vendor length.
var x uint32
err := binary.Read(block.lr, binary.LittleEndian, &x)
if err != nil {
if err = binary.Read(block.lr, binary.LittleEndian, &x); err != nil {
return unexpected(err)
}
@ -37,8 +36,7 @@ func (block *Block) parseVorbisComment() error {
// Parse tags.
// 32 bits: number of tags.
err = binary.Read(block.lr, binary.LittleEndian, &x)
if err != nil {
if err = binary.Read(block.lr, binary.LittleEndian, &x); err != nil {
return unexpected(err)
}
if x < 1 {
@ -47,8 +45,7 @@ func (block *Block) parseVorbisComment() error {
comment.Tags = make([][2]string, x)
for i := range comment.Tags {
// 32 bits: vector length
err = binary.Read(block.lr, binary.LittleEndian, &x)
if err != nil {
if err = binary.Read(block.lr, binary.LittleEndian, &x); err != nil {
return unexpected(err)
}