From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] ALSA: pcm: Mostly constify constraints Date: Thu, 05 Jul 2012 11:55:36 +0200 Message-ID: References: <1341423313-9561-1-git-send-email-broonie@opensource.wolfsonmicro.com> <20120705092841.GI4111@opensource.wolfsonmicro.com> 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 EB92524493 for ; Thu, 5 Jul 2012 11:55:38 +0200 (CEST) In-Reply-To: <20120705092841.GI4111@opensource.wolfsonmicro.com> 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: Mark Brown Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 5 Jul 2012 10:28:42 +0100, Mark Brown wrote: > > On Thu, Jul 05, 2012 at 09:06:30AM +0200, Takashi Iwai wrote: > > Mark Brown wrote: > > > > There is no need for the constraints to be modified while being > > > applied > > > Many drivers pass the local instance to rule->private, and it's not > > always guaranteed to be const. For example, you can imagine some > > state modified kept in the struct while it's modified via rules. > > > In short: you'd have seen many compile warnings for non-ASoC drivers > > if you run make once with this patch ;) > > Well, that's trivial to fix. > > > As a safe side fix, how about just adding const to > > snd_pcm_hw_constraint_list() & co, and expclitly cast to non-const > > later? > > My inclination for something like this is to put the casts with the > users since that way we get the type safety through most of the code and > we can see that dropping the const is safe since we're just getting back > our own data. If we can see the APIs immediately dropping the const I'd > expect we'd get people spending time on code review trying to figure out > if it's safe. The rule->private pointer isn't designed to be always const. The data purely depends on each rule function, thus whether it can be const or not also depends on the rule, too. For simple rules like list take indeed the constant list. But more complex rules may take a struct containing variables changed on the fly (e.g. the max rate set by user via control API). Takashi