[PATCH v7 03/14] ASoC: Intel: catpt: Add IPC message handlers

Rojewski, Cezary cezary.rojewski at intel.com
Tue Sep 22 13:56:02 CEST 2020


On 2020-09-22 1:30 PM, Andy Shevchenko wrote:
> On Tue, Sep 22, 2020 at 02:29:10PM +0300, Andy Shevchenko wrote:
>> On Tue, Sep 22, 2020 at 11:04:31AM +0000, Rojewski, Cezary wrote:
>>> On 2020-09-22 11:04 AM, Andy Shevchenko wrote:
>>>> On Mon, Sep 21, 2020 at 08:48:12PM +0000, Rojewski, Cezary wrote:
...

>>>> And here basically enough check is info against NULL, right?
>>>> Just try to look at different possibilities how to make code simpler and neater.
>>>>
>>>>> Didn't compile this, some typecheck fixes might be in order and so on.
>>>>
>>>
>>> What you meant is:
>>> 	if (i == 4 && !info) // instead of 'info < eof'
>>>
>>> right?
>>
>> Simply if (!info)...
> 
> 	if (info)
> 		memcpy();
> 
> of course, otherwise it will crash.
> 

Indeed, sorry about the typo.

>>> If 4th space is last char in this string then info would end up being
>>> non-NULL and equal to 'eof' and thus memcpy() would get invoked with
>>> size=eof-info=0.
>>
>> ...which is not a problem.
> 

And what about the case where 1st space is the last char?
We quit the loop afterward, 'info' will not be NULL, 'i' on the other
hand certainly won't be 4.
TLDR: without checking 'i' how am I sure about whether or not cursor is
actually at 5th segment?

Czarek



More information about the Alsa-devel mailing list