Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1506372rdb; Sat, 20 Jan 2024 01:42:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpbNKsG63dEIAZ+UMMuXROSdIFJ8kcxnyYD/lEd4Bkgk9dtquIkJApb719ycjvDCTpZ9zJ X-Received: by 2002:a92:d4cb:0:b0:361:a8f3:ed99 with SMTP id o11-20020a92d4cb000000b00361a8f3ed99mr1434311ilm.42.1705743761330; Sat, 20 Jan 2024 01:42:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705743761; cv=pass; d=google.com; s=arc-20160816; b=x9RvlzUZuo9sCJnoYAcAZbijqyTgXOc2dPJVafPzdAAFOy0BkCTu3Z6r2S+r0kz15R AzKIf/X7mjBNkuA9XfoECckjhJIYKtd5GF7fx35uaM+lYZtB4lliEYqAYvLCYcQ3GowU CQzWtKPPJhahrpuWYKeyqpV7uj+8gTmB1WLk2D+Ag0Hn7c/rBe5qSc8xnj78wDKQouEb wu3+6MwU7TshalWO+Y5nvhljetQc4wNI5QCJfRt2YzCGkmevKeIE6aNVMW97d1XoPuXb hwjLHNKlU1g5nqSIdwYvKSBV4hyXNE+ESqgEWzUNDS/4d4iOIoF9T5sb4+7vYSHE7DnC 1WHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=jqkuByAneJ1tG1xwrZ5rETs0q0pFU+XkKF5W5mqRRsk=; fh=ZOaT7PcMnisf8XLVJdx1+1HsWx9nR/HHK+qI6tHQ9vQ=; b=kO13X+LCS3yPj0j3dZ61Ky0r4I0apxKF5mhilh5Bl7rS5AEGSUWegThtm3LyIqg2QF 5Sbm/i6PEQ+SMesDLULZVqrkslwQs1Rvck2yPchgNpTi+AZcTgl0LpE2fzA4UnQOipfG 1SWD2zLugfsyvV0ADbfT3Qc1a7E45y18NRZEzBNnmW/0h9EHVOzip6U1VZjsJ/gmbDNh s1P7d1V1EL+2544fIa1Lq2R12ssrp9YSaoPd6kwk5ucT+n6oyswNEYOTXMhuSJkaZguo DJpqczBrW3wxkO5zeLuulodTNx4AW+CvtyZbUhii4TwJ3uGAZZGlBZdBl5VBNxBxn/5g ocWg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kUTgD7yL; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-31749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y37-20020a634965000000b005c1b30b1b65si4896293pgk.648.2024.01.20.01.42.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 01:42:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kUTgD7yL; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-31749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31749-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7289CB22369 for ; Sat, 20 Jan 2024 09:42:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E045DC8C7; Sat, 20 Jan 2024 09:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="kUTgD7yL" Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCA11D507 for ; Sat, 20 Jan 2024 09:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705743747; cv=none; b=rCe65xUwjY8DU0t9FW3jc+UVC4DzYU1GQ6quBWn9OI9SqPU4G0ymEM/SZPJ0X1ongg9hlaV8VLjXwV9GFcQjqtRYJ9H4A5m5givTxEUk3nbA0GfmuxgcXwR2yzFu0c/IHE50US0iE0cA4UWUGQivHo9uDRXysXhQe4UvyqXNQyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705743747; c=relaxed/simple; bh=1+N3YmtcT/VrFLO1mZria8sCoBSPBU080hcNWd3hcB8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=b58VqIdGK4cxMQDUBIaW0JJ746e8+VCFZx6V2XnQzxROTq5U/nRRRFV1QV/uz+ue41L7V7GBM2OD/9kQdZec45NV6JJU0Mq6j7ujUoz5U6LcQUbvHLSXADLkCgLgu7F2bPwFbRdfaZcBGPTv92bQ3E9dHvyRt9ckEaOHnptgU+I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=kUTgD7yL; arc=none smtp.client-ip=80.12.242.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id R7rirLBJA6LbeR7rjrquA5; Sat, 20 Jan 2024 10:42:15 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1705743735; bh=jqkuByAneJ1tG1xwrZ5rETs0q0pFU+XkKF5W5mqRRsk=; h=From:To:Cc:Subject:Date; b=kUTgD7yLyeXMn4n1wcBXLPiynU/tLOC2Nv9PXTX52BE35qxpILX+MwppzmzvxZDW+ WZf7sAn5wNb7FHfuKvYgyEvZDAQ8lMyqX/qlRl1wu98svDV626XGe61Zk4Aajn3PKK 7y+3mDMw5nlqJ2xqs+YQI+Y3Ei/Rm72tbnnni0Cjy5IbHm2kt5PRGEYDWPpnVii5EZ T/H93MbpVy+lWZrC7OSzJYFkxtzPbOIwg3ZyrEtSo/awvqmP1cb+saNd8QRLbrD6H5 +xOImqeUeLjEPHnW1Lq30gZ/7WSSPRYeyU+W613E6EpgJZv/ljs5b0UxMDQZVUe9e9 THA+q/8Zs8YwQ== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 20 Jan 2024 10:42:15 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Jaroslav Kysela , Takashi Iwai Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-sound@vger.kernel.org Subject: [PATCH] ALSA: synth: Save a few bytes of memory when registering a 'snd_emux' Date: Sat, 20 Jan 2024 10:42:12 +0100 Message-ID: <9e7b94c852a25ed4be5382e5e48a7dd77e8d4d1a.1705743706.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit snd_emux_register() calls pass a string literal as the 'name' parameter. So kstrdup_const() can be used instead of kfree() to avoid a memory allocation in such cases. Signed-off-by: Christophe JAILLET --- include/sound/emux_synth.h | 2 +- sound/synth/emux/emux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sound/emux_synth.h b/include/sound/emux_synth.h index 1cc530434b97..3f7f365ed248 100644 --- a/include/sound/emux_synth.h +++ b/include/sound/emux_synth.h @@ -103,7 +103,7 @@ struct snd_emux { int ports[SNDRV_EMUX_MAX_PORTS]; /* The ports for this device */ struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS]; int used; /* use counter */ - char *name; /* name of the device (internal) */ + const char *name; /* name of the device (internal) */ struct snd_rawmidi **vmidi; struct timer_list tlist; /* for pending note-offs */ int timer_active; diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 0006c3ddb51d..a82af9374852 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -85,7 +85,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch return -EINVAL; emu->card = card; - emu->name = kstrdup(name, GFP_KERNEL); + emu->name = kstrdup_const(name, GFP_KERNEL); emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), GFP_KERNEL); if (emu->name == NULL || emu->voices == NULL) @@ -140,7 +140,7 @@ int snd_emux_free(struct snd_emux *emu) snd_emux_delete_hwdep(emu); snd_sf_free(emu->sflist); kfree(emu->voices); - kfree(emu->name); + kfree_const(emu->name); kfree(emu); return 0; } -- 2.43.0