From patchwork Wed Feb 11 10:37:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 5811891 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E23B9BF440 for ; Wed, 11 Feb 2015 10:38:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C2F52022A for ; Wed, 11 Feb 2015 10:38:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E17FF20212 for ; Wed, 11 Feb 2015 10:38:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EAB832625ED; Wed, 11 Feb 2015 11:38:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id BF3F92605CE; Wed, 11 Feb 2015 11:37:51 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D7D5E2619E7; Wed, 11 Feb 2015 11:37:49 +0100 (CET) Received: from smtp303.phy.lolipop.jp (smtp303.phy.lolipop.jp [210.157.22.87]) by alsa0.perex.cz (Postfix) with ESMTP id AC6742605CE for ; Wed, 11 Feb 2015 11:37:39 +0100 (CET) Received: from smtp303.phy.lolipop.lan (HELO smtp303.phy.lolipop.jp) (172.17.1.87) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp303.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Wed, 11 Feb 2015 19:37:35 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp303.phy.lolipop.jp (LOLIPOP-Fsecure); Wed, 11 Feb 2015 19:37:33 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Wed, 11 Feb 2015 19:37:25 +0900 Message-Id: <1423651052-19593-2-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423651052-19593-1-git-send-email-o-takashi@sakamocchi.jp> References: <1423651052-19593-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 1/8] ALSA: control: change type from long due to the definition of sizeof operator X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The sizeof() operator returns 'unsigned' value, while it's assigned to 'long'. And in this case, the value is not so large. This commit change the type of assigned value to 'unsigned int'. Additonally, rename local variable assigned to the value. Signed-off-by: Takashi Sakamoto --- sound/core/control.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 35324a8..ea49abc 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1007,7 +1007,7 @@ struct user_element { struct snd_ctl_elem_info info; struct snd_card *card; void *elem_data; /* element data */ - unsigned long elem_data_size; /* size of element data in bytes */ + unsigned int elem_data_size; /* size of element data in bytes */ void *tlv_data; /* TLV data */ unsigned long tlv_data_size; /* TLV data size */ void *priv_data; /* private data (like strings for enumerated type) */ @@ -1164,7 +1164,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, struct snd_card *card = file->card; struct snd_kcontrol kctl, *_kctl; unsigned int access; - long private_size; + unsigned int elem_data_size; struct user_element *ue; int idx, err; @@ -1204,42 +1204,42 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, switch (info->type) { case SNDRV_CTL_ELEM_TYPE_BOOLEAN: case SNDRV_CTL_ELEM_TYPE_INTEGER: - private_size = sizeof(long); + elem_data_size = sizeof(long); if (info->count > 128) return -EINVAL; break; case SNDRV_CTL_ELEM_TYPE_INTEGER64: - private_size = sizeof(long long); + elem_data_size = sizeof(long long); if (info->count > 64) return -EINVAL; break; case SNDRV_CTL_ELEM_TYPE_ENUMERATED: - private_size = sizeof(unsigned int); + elem_data_size = sizeof(unsigned int); if (info->count > 128 || info->value.enumerated.items == 0) return -EINVAL; break; case SNDRV_CTL_ELEM_TYPE_BYTES: - private_size = sizeof(unsigned char); + elem_data_size = sizeof(unsigned char); if (info->count > 512) return -EINVAL; break; case SNDRV_CTL_ELEM_TYPE_IEC958: - private_size = sizeof(struct snd_aes_iec958); + elem_data_size = sizeof(struct snd_aes_iec958); if (info->count != 1) return -EINVAL; break; default: return -EINVAL; } - private_size *= info->count; - ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL); + elem_data_size *= info->count; + ue = kzalloc(sizeof(struct user_element) + elem_data_size, GFP_KERNEL); if (ue == NULL) return -ENOMEM; ue->card = card; ue->info = *info; ue->info.access = 0; ue->elem_data = (char *)ue + sizeof(*ue); - ue->elem_data_size = private_size; + ue->elem_data_size = elem_data_size; if (ue->info.type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) { err = snd_ctl_elem_init_enum_names(ue); if (err < 0) {