[PATCH 6/6] sample: RFC: Assert validity of sample_spec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2016-08-18 at 18:17 +0200, Peter Meerwald-Stadler wrote:
> passing an invalid sample_spec to
> pa_sample_size_of_format(),
> pa_frame_size(),
> pa_bytes_per_second(),
> pa_bytes_to_usec(),
> pa_usec_to_bytes()
> currently gives a result of 0
> 
> this is problematic as
> (a) it leads to many potential divide-by-zero issues flagged by Coverity,
> (b) pa_sample_spec_valid() is called often and the mostly unnecessary validation
> of the sample_spec cannot be optimized away due to pa_return_val_if_fail()
> (c) nobody checks the result for 0 and the behaviour is not documented
> 
> this patch replaces pa_return_val_if_fail() with pa_assert()
> 
> note that this commit changes the API!
> note that pa_return_val_if_fail() strangely logs an assertion, but then happily
> continues...
> 
> fixes numerious CIDs
> ---
>  src/pulse/sample.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

Since the behaviour is undocumented, I think it's fine to use asserts.
Looks good to me.

-- 
Tanu


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux