[oss-devel] ossxmix patch to ignore empty mixer groups

Zakhar Levchenko zlevchenko at gmail.com
Fri Jun 6 21:34:19 EEST 2008


Since in the case when parent value is out of bounds parentrec is always
zero and not zero if parent value is in the range [0..n-1],

while(parent >= 0 && parent < n &&...  structure is fully equivalent to
while(parentrec &&...

The only difference between previous and current version is that previously
parentrec might potentially be an invalid pointer. Yes, no data was accessed
by this pointer (check for parent value in the loop condition prevented
this), but I hate to have invalid pointers even if they are not used. I hope
this explains why I've changed code a bit.

Regards,
          Zakhar Levchenko

On 6/6/08, Yair K. <cesium2 at gmail.com> wrote:
>
> >Zakhar Levchenko wrote:
> >1. This check is used only to prevent potential crashes if a buggy driver
> >reports invalid values for parents, just in case. It does not affect
> >algorithm logic in any way. That's why I called it paranoidal. It may be
> >totally excluded provided that all parent values are in the range
> [0..n-1].
> >Maybe I missed something, but I can't see any problems here. Can you see
> any
> >problems if suppose there's no such check at all?
>
> In the previous version (by email) the check was done at the loop
> condition. I'm saying that there's no advantage for doing it where it's at
> now, and that I'm not certain falling back to 0 is always correct.
>
>
> >2. What is the advantage of calloc? In my opinion malloc(n*m) is
> equivalent
> >to calloc(n,m) (not fully though since calloc initializes all bits to
> zero,
> >but is this advantage?).
>
> There's no real advantage save for less code (current code is equivalent
> since it zeros the array anyway).
> (completely irrelevant trivia: This is a tiny difference - n*m can
> overflow. Paranoid OpenBSD switched malloc(n*m) calls to calloc(n, m)).
>
>
> Yours,
>         Yair K.
> _______________________________________________
> oss-devel mailing list
> oss-devel at mailman.opensound.com
> http://mailman.opensound.com/mailman/listinfo/oss-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.opensound.com/pipermail/oss-devel/attachments/20080606/f1e170f2/attachment-0001.htm 


More information about the oss-devel mailing list