From: Takashi Iwai Subject: Re: [PATCH v4] ucm: add cset-tlv Date: Wed, 13 Apr 2016 12:02:34 +0200 Message-ID: References: <1460528817-25598-1-git-send-email-hychao@chromium.org> <20160413085740.GK2274@localhost> 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 (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 39B16260870 for ; Wed, 13 Apr 2016 12:02:36 +0200 (CEST) In-Reply-To: <20160413085740.GK2274@localhost> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Vinod Koul Cc: alsa-devel@alsa-project.org, Hsin-Yu Chao List-Id: alsa-devel@alsa-project.org On Wed, 13 Apr 2016 10:57:40 +0200, Vinod Koul wrote: > > On Wed, Apr 13, 2016 at 02:26:57PM +0800, Hsin-Yu Chao wrote: > > + sz_read = read(fd, *res, sz); > > + if (sz_read < 0 || (size_t)sz_read != sz) { > > + err = -EIO; > > + free(*res); > > + *res = NULL; > > + } > > + /* Check if the tlv file specifies valid size. */ > > + tlv = (unsigned int *)(*res); > > + if (tlv[1] + 2 * sizeof(unsigned int) != sz) { > > why not use snd_ctl_tlv(), my assumption is that you are expecting a type, > length and values in the buffer Actually this implicitly checks the endianess of the read data. Takashi