From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Jaroslav Kysela <perex@perex.cz>,
Kees Cook <keescook@chromium.org>, Takashi Iwai <tiwai@suse.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/4] ALSA: emux: Improve a size determination in two functions
Date: Wed, 09 Aug 2017 08:02:57 +0000 [thread overview]
Message-ID: <3354241b-cb2e-3d91-5dca-5e3ea427ee03@users.sourceforge.net> (raw)
In-Reply-To: <412aa3a5-c8b6-c1fe-febb-0d62927dacc2@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 9 Aug 2017 09:11:26 +0200
Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/synth/emux/emux_seq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index 53820f75ba3e..12acf18c5be4 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -149,7 +149,8 @@ snd_emux_create_port(struct snd_emux *emu, char *name,
snd_printk(KERN_ERR "no memory\n");
return NULL;
}
- p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL);
+ p->chset.channels = kcalloc(max_channels, sizeof(*p->chset.channels),
+ GFP_KERNEL);
if (p->chset.channels = NULL) {
snd_printk(KERN_ERR "no memory\n");
kfree(p);
@@ -371,7 +372,7 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card)
if (emu->midi_ports <= 0)
return 0;
- emu->vmidi = kcalloc(emu->midi_ports, sizeof(struct snd_rawmidi *), GFP_KERNEL);
+ emu->vmidi = kcalloc(emu->midi_ports, sizeof(*emu->vmidi), GFP_KERNEL);
if (emu->vmidi = NULL)
return -ENOMEM;
--
2.13.4
next prev parent reply other threads:[~2017-08-09 8:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 8:00 [PATCH 0/4] ALSA: emux: Adjustments for four function implementations SF Markus Elfring
2017-08-09 8:01 ` [PATCH 1/4] ALSA: emux: Adjust one function call together with a variable assignment SF Markus Elfring
2017-08-09 8:02 ` SF Markus Elfring [this message]
2017-08-09 8:03 ` [PATCH 3/4] ALSA: emux: Adjust four checks for null pointers SF Markus Elfring
2017-08-09 8:04 ` [PATCH 4/4] ALSA: emux: Delete two error messages for a failed memory allocation in snd_emux_create_ SF Markus Elfring
2017-08-10 15:55 ` [PATCH 0/4] ALSA: emux: Adjustments for four function implementations Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3354241b-cb2e-3d91-5dca-5e3ea427ee03@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox