TheCacophonyProject / go-cptv

Go package for creating and reading Cacophony Project Thermal Video (CPTV) files
Apache License 2.0
2 stars 6 forks source link

Error if header fields are out of range #21

Open mjs opened 5 years ago

mjs commented 5 years ago

If out of range values are provided for some fields (e.g. PreviewSecs is great than 255) the value will silently wrapped around. An error should be returned instead.

VinceJnz commented 2 months ago

So do you want these functions to return an error value in addition to the value they currently return? https://github.com/TheCacophonyProject/go-cptv/blob/ae7134e91a7107a0c98be21af944f9ee74ff889d/reader.go#L137-L142

For example

func (r *Reader) PreviewSecs() (int, error) {
    secs, err := r.header.Uint8(PreviewSecs)
    return int(secs), err
}