From: Takashi Iwai Subject: Re: [PATCH 3/3] ALSA: core: set kcontrol's count field correctly Date: Wed, 24 Aug 2011 08:18:25 +0200 Message-ID: References: <20110824031234.5279.46501.stgit@localhost6.localdomain6> <20110824031243.5279.93859.stgit@localhost6.localdomain6> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 670AE2455A for ; Wed, 24 Aug 2011 08:18:25 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Lu Guanqun Cc: ALSA , clemens@ladisch.de List-Id: alsa-devel@alsa-project.org At Wed, 24 Aug 2011 08:06:34 +0200, Takashi Iwai wrote: > > At Wed, 24 Aug 2011 11:12:43 +0800, > Lu Guanqun wrote: > > > > I don't see how info's owner field relates to kcontrol's count field. It should > > assign to info's count instead. > > > > Let's assume this scenario: > > > > 1. user reads the control element from kernel (the owner field is set) > > 2. user changes some values > > 3. user issues 'SNDRV_CTL_IOCTL_ELEM_REPLACE' ioctl. > > > > With the original code, 'kctl' here gets a large count number due to its > > non-empty owner field. Therefore it fails on subsequent call snd_ctl_new(). > > In IOCTL_ELEM_ADD and REPLACE, count and owner struct fields have > different meanings from others. The count contains the array size, > not the number of identical elements. And the owner contains the > number of elements to be created. Correction: the count field means same as others. The info.count specifies the array size in IOCTL_ELEM_INFO, too. The only difference is an (ab)use of owner field. Takashi