From: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, liam.r.girdwood@linux.intel.com
Subject: [PATCH 3/3] ucm: fix inappropriate use of const
Date: Tue, 10 Feb 2015 22:42:34 +0200 [thread overview]
Message-ID: <1423600954-8751-4-git-send-email-tanu.kaskinen@linux.intel.com> (raw)
In-Reply-To: <1423600954-8751-1-git-send-email-tanu.kaskinen@linux.intel.com>
The caller is expected to free the string returned by
snd_use_case_get(), but for some reason the string is marked as const,
so the caller is forced to do type casting to get rid of compiler
warnings. I don't see any reason for using const in snd_use_case_get(),
so let's remove that.
This will cause warnings in application code, if applications
currently pass const variables to the function, which they very likely
do. I don't know if that's acceptable. If not, then it's too late to
fix this bug...
---
include/use-case.h | 2 +-
src/ucm/main.c | 24 ++++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/use-case.h b/include/use-case.h
index f30168f..28d786f 100644
--- a/include/use-case.h
+++ b/include/use-case.h
@@ -286,7 +286,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
*/
int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
- const char **value);
+ char **value);
/**
* \brief Get current - integer
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 62bc374..8fbf94f 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -40,9 +40,9 @@
* misc
*/
-static int get_value1(const char **value, struct list_head *value_list,
+static int get_value1(char **value, struct list_head *value_list,
const char *identifier);
-static int get_value3(const char **value,
+static int get_value3(char **value,
const char *identifier,
struct list_head *value_list1,
struct list_head *value_list2,
@@ -299,7 +299,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
case SEQUENCE_ELEMENT_TYPE_CSET:
case SEQUENCE_ELEMENT_TYPE_CSET_BIN_FILE:
if (cdev == NULL) {
- const char *cdev1 = NULL, *cdev2 = NULL;
+ char *cdev1 = NULL, *cdev2 = NULL;
err = get_value3(&cdev1, "PlaybackCTL",
value_list1,
value_list2,
@@ -313,7 +313,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
value_list2,
value_list3);
if (err < 0 && err != ENOENT) {
- free((char *)cdev1);
+ free(cdev1);
uc_error("cdev is not defined!");
return err;
}
@@ -327,11 +327,11 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
* before calling open_ctl()). */
if (cdev1 == NULL || cdev2 == NULL ||
strcmp(cdev1, cdev2) == 0) {
- cdev = (char *)cdev1;
- free((char *)cdev2);
+ cdev = cdev1;
+ free(cdev2);
} else {
- free((char *)cdev1);
- free((char *)cdev2);
+ free(cdev1);
+ free(cdev2);
}
}
if (ctl == NULL) {
@@ -1233,7 +1233,7 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr,
return err;
}
-static int get_value1(const char **value, struct list_head *value_list,
+static int get_value1(char **value, struct list_head *value_list,
const char *identifier)
{
struct ucm_value *val;
@@ -1254,7 +1254,7 @@ static int get_value1(const char **value, struct list_head *value_list,
return -ENOENT;
}
-static int get_value3(const char **value,
+static int get_value3(char **value,
const char *identifier,
struct list_head *value_list1,
struct list_head *value_list2,
@@ -1284,7 +1284,7 @@ static int get_value3(const char **value,
*/
static int get_value(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
- const char **value,
+ char **value,
const char *mod_dev_name,
const char *verb_name,
int exact)
@@ -1354,7 +1354,7 @@ static int get_value(snd_use_case_mgr_t *uc_mgr,
*/
int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
const char *identifier,
- const char **value)
+ char **value)
{
const char *slash1, *slash2, *mod_dev_after;
const char *ident, *mod_dev, *verb;
--
1.9.3
next prev parent reply other threads:[~2015-02-10 20:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 20:42 [PATCH 0/3] ucm: miscellaneous fixes Tanu Kaskinen
2015-02-10 20:42 ` [PATCH 1/3] ucm: fix variable mixup Tanu Kaskinen
2015-02-11 11:43 ` Takashi Iwai
2015-02-10 20:42 ` [PATCH 2/3] ucm: add a FIXME comment Tanu Kaskinen
2015-02-11 11:38 ` Takashi Iwai
2015-02-11 11:44 ` Tanu Kaskinen
2015-02-11 13:01 ` Takashi Iwai
2015-02-11 13:34 ` Tanu Kaskinen
2015-02-11 13:35 ` Takashi Iwai
2015-02-11 16:16 ` Liam Girdwood
2015-02-10 20:42 ` Tanu Kaskinen [this message]
2015-02-11 11:42 ` [PATCH 3/3] ucm: fix inappropriate use of const 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=1423600954-8751-4-git-send-email-tanu.kaskinen@linux.intel.com \
--to=tanu.kaskinen@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=liam.r.girdwood@linux.intel.com \
--cc=tiwai@suse.de \
/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