Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2709C77B7C for ; Sun, 7 May 2023 17:57:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2E8C11494; Sun, 7 May 2023 19:56:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2E8C11494 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1683482243; bh=NftW72aG7EF1e8QXIijtMlzK3kG6ZNmJvbtW5mkAWH0=; h=From:To:In-Reply-To:References:Subject:Date:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=UDe+4fdYqfvtY9GJfO8p5t20RRl0st8OkcAkifuS+JbxFkQmj12vnucumlPdbJK6v oxryhipPYtCoe6hkkI+XWIfT1aRyo4/oMXYPUBkvjdOQCUMuCUN8D5GKeT2VvD5ciu AyhqXK1uKDNoxszfetEJWpZLfcJowwGHB1xi9fzA= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 2A775F8053B; Sun, 7 May 2023 19:55:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 75E9DF8053B; Sun, 7 May 2023 19:55:53 +0200 (CEST) Received: from webhooks-bot.alsa-project.org (vmi242170.contaboserver.net [207.180.221.201]) by alsa1.perex.cz (Postfix) with ESMTP id 1842FF8032D for ; Sun, 7 May 2023 19:55:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1842FF8032D MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: GitHub issues - edited To: alsa-devel@alsa-project.org In-Reply-To: <1683482152080006838-webhooks-bot@alsa-project.org> References: <1683482152080006838-webhooks-bot@alsa-project.org> Subject: Bug: premature stringification in SND_DLSYM_BUILD_VERSION produces wrong results for alsa-plugins. Message-Id: <20230507175553.75E9DF8053B@alsa1.perex.cz> Date: Sun, 7 May 2023 19:55:53 +0200 (CEST) Message-ID-Hash: RGJG4UV3VFAHXRI5T3RNFUMJXIPVUQVJ X-Message-ID-Hash: RGJG4UV3VFAHXRI5T3RNFUMJXIPVUQVJ X-MailFrom: github@alsa-project.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: alsa-project/alsa-lib issue #316 was edited from MIvanchev: [The macro](https://github.com/alsa-project/alsa-lib/blob/master/include/global.h#L80): ``` #define SND_DLSYM_BUILD_VERSION(name, version) \ static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \ void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \ void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \ snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \ } ``` should actually be ``` #define SND_DLSYM_NAME(name) #name #define SND_DLSYM_BUILD_VERSION(name, version) \ static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \ void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \ void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = SND_DLSYM_NAME(name) \ __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \ snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \ } ``` This is because for instance [this code](https://github.com/alsa-project/alsa-plugins/blob/master/pulse/ctl_pulse.c#LL823C1-L823C30) `SND_CTL_PLUGIN_SYMBOL(pulse);` expands to ``` SND_DLSYM_BUILD_VERSION(SND_CTL_PLUGIN_ENTRY(pulse), SND_CONTROL_DLSYM_VERSION); ``` and this expands to ``` ... __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # SND_CTL_PLUGIN_ENTRY(pulse) ... ``` but the C preprocessor doesn't expand stringified tokens so the value of `dlsym_name` is actually `"SND_CTL_PLUGIN_ENTRY(pulse)"`. Issue URL : https://github.com/alsa-project/alsa-lib/issues/316 Repository URL: https://github.com/alsa-project/alsa-lib