various: fix Wdiscarded-qualifiers warnings

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
This commit is contained in:
Rudi Heitbaum authored and Kacper Michajłow committed 2026-03-15 14:49:00 +01:00
1 parent afef9126ce
commit 8ace278cbe
12 files changed
+28 -28

No files matched your search

+1 -1
View File
@@ -547,7 +547,7 @@ static char *append_params(void *ta_parent, const char *device, const char *p)
return talloc_strdup(ta_parent, device);
int len = strlen(device);
char *end = strchr(device, ':');
const char *end = strchr(device, ':');
if (!end) {
/* no existing parameters: add it behind device name */
return talloc_asprintf(ta_parent, "%s:%s", device, p);
+2 -2
View File
@@ -98,7 +98,7 @@ static bool test_matroska_ext(const char *filename)
static char **find_files(const char *original_file)
{
void *tmpmem = talloc_new(NULL);
char *basename = mp_basename(original_file);
const char *basename = mp_basename(original_file);
struct bstr directory = mp_dirname(original_file);
char **results = talloc_size(NULL, 0);
char *dir_zero = bstrdup0(tmpmem, directory);
@@ -119,7 +119,7 @@ static char **find_files(const char *original_file)
char *name = mp_path_join_bstr(results, directory, bstr0(ep->d_name));
char *s1 = ep->d_name;
char *s2 = basename;
const char *s2 = basename;
int matchlen = 0;
while (*s1 && *s1++ == *s2++)
matchlen++;
+4 -4
View File
@@ -39,9 +39,9 @@
#include <pathcch.h>
#endif
char *mp_basename(const char *path)
const char *mp_basename(const char *path)
{
char *s;
const char *s;
#if HAVE_DOS_PATHS
if (!mp_is_url(bstr0(path))) {
@@ -54,7 +54,7 @@ char *mp_basename(const char *path)
}
#endif
s = strrchr(path, '/');
return s ? s + 1 : (char *)path;
return s ? s + 1 : path;
}
struct bstr mp_dirname(const char *path)
@@ -85,7 +85,7 @@ void mp_path_strip_trailing_separator(char *path)
char *mp_splitext(const char *path, bstr *root)
{
mp_assert(path);
char *bn = mp_basename(path);
const char *bn = mp_basename(path);
// Skip all leading dots, not just for "hidden" unix files, otherwise we
// end up splitting a part of the filename sans leading dot.
+1 -1
View File
@@ -24,7 +24,7 @@
// Return pointer to filename part of path
char *mp_basename(const char *path);
const char *mp_basename(const char *path);
/* Return file extension, excluding the '.'. If root is not NULL, set it to the
* part of the path without extension. So: path == root + "." + extension
+2 -2
View File
@@ -208,9 +208,9 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
}
}
bool m_property_split_path(const char *path, bstr *prefix, char **rem)
bool m_property_split_path(const char *path, bstr *prefix, const char **rem)
{
char *next = strchr(path, '/');
const char *next = strchr(path, '/');
if (next) {
*prefix = bstr_splice(bstr0(path), 0, next - path);
*rem = next + 1;
+1 -1
View File
@@ -165,7 +165,7 @@ int m_property_do(struct mp_log *log, const struct m_property* prop_list,
// and rem to "b/c", and return true.
// If there is no '/' in the path, set prefix to path, and rem to "", and
// return false.
bool m_property_split_path(const char *path, bstr *prefix, char **rem);
bool m_property_split_path(const char *path, bstr *prefix, const char **rem);
// Print a list of properties.
void m_properties_print_help_list(struct mp_log *log,
+8 -8
View File
@@ -1282,7 +1282,7 @@ static int tag_property(int action, void *arg, struct mp_tags *tags)
case M_PROPERTY_KEY_ACTION: {
struct m_property_action_arg *ka = arg;
bstr key;
char *rem;
const char *rem;
m_property_split_path(ka->key, &key, &rem);
if (bstr_equals0(key, "list")) {
struct m_property_action_arg nka = *ka;
@@ -1352,7 +1352,7 @@ static int mp_property_filter_metadata(void *ctx, struct m_property *prop,
if (action == M_PROPERTY_KEY_ACTION) {
struct m_property_action_arg *ka = arg;
bstr key;
char *rem;
const char *rem;
m_property_split_path(ka->key, &key, &rem);
struct mp_tags *metadata = NULL;
struct mp_output_chain *chain = NULL;
@@ -2115,7 +2115,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
struct m_property_action_arg *ka = arg;
if (!strncmp(ka->key, "metadata/", 9)) {
bstr key = {0};
char *rem = "";
const char *rem = "";
m_property_split_path(ka->key, &key, &rem);
ka->key = rem;
if (!rem[0]) {
@@ -2253,7 +2253,7 @@ static int mp_property_current_tracks(void *ctx, struct m_property *prop,
struct m_property_action_arg *ka = arg;
bstr key;
char *rem;
const char *rem;
m_property_split_path(ka->key, &key, &rem);
if (bstr_equals0(key, "video")) {
@@ -3505,11 +3505,11 @@ static int mp_property_playlist(void *ctx, struct m_property *prop,
if (pl->current == e)
res = append_selected_style(mpctx, res);
const char *reset = pl->current == e ? get_style_reset(mpctx) : "";
char *p = e->title;
const char *p = e->title;
if (!p || mpctx->opts->playlist_entry_name > 0) {
p = e->filename;
if (!mp_is_url(bstr0(p))) {
char *s = mp_basename(e->filename);
const char *s = mp_basename(e->filename);
if (s[0])
p = s;
}
@@ -3874,7 +3874,7 @@ static int mp_property_option_info(void *ctx, struct m_property *prop,
case M_PROPERTY_KEY_ACTION: {
struct m_property_action_arg *ka = arg;
bstr key;
char *rem;
const char *rem;
m_property_split_path(ka->key, &key, &rem);
struct m_config_option *co = m_config_get_co(mpctx->mconfig, key);
if (!co)
@@ -4134,7 +4134,7 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
// See if the next layer down will also be a sub-object access
bstr key;
char *rem;
const char *rem;
bool has_split = m_property_split_path(act->key, &key, &rem);
if (!has_split && act->action == M_PROPERTY_DELETE) {
+2 -2
View File
@@ -126,7 +126,7 @@ static void mp_load_per_file_config(struct MPContext *mpctx)
return;
}
char *name = mp_basename(cfg);
const char *name = mp_basename(cfg);
bstr dir = mp_dirname(cfg);
char *dircfg = mp_path_join_bstr(NULL, dir, bstr0("mpv.conf"));
@@ -243,7 +243,7 @@ static bool needs_config_quoting(const char *s)
return false;
}
static void write_filename(struct MPContext *mpctx, FILE *file, char *filename)
static void write_filename(struct MPContext *mpctx, FILE *file, const char *filename)
{
if (mpctx->opts->ignore_path_in_watch_later_config && !mp_is_url(bstr0(filename)))
filename = mp_basename(filename);
+1 -1
View File
@@ -168,7 +168,7 @@ static char *create_fname(struct MPContext *mpctx, char *template,
}
case 'f':
case 'F': {
char *name;
const char *name;
if (!mpctx->filename) {
name = "NO_FILE";
} else if (bstr_endswith0(bstr0(mpctx->filename), "/")) {
+4 -4
View File
@@ -111,7 +111,7 @@ static int64_t mp_load_script(struct MPContext *mpctx, const char *fname)
void *tmp = talloc_new(NULL);
const char *path = NULL;
char *script_name = NULL;
const char *script_name = NULL;
const struct mp_scripting *backend = NULL;
struct stat s;
@@ -138,9 +138,9 @@ static int64_t mp_load_script(struct MPContext *mpctx, const char *fname)
return -1;
}
script_name = talloc_strdup(tmp, path);
mp_path_strip_trailing_separator(script_name);
script_name = mp_basename(script_name);
char *path_dup = talloc_strdup(tmp, path);
mp_path_strip_trailing_separator(path_dup);
script_name = mp_basename(path_dup);
} else {
for (int n = 0; scripting_backends[n]; n++) {
const struct mp_scripting *b = scripting_backends[n];
+1 -1
View File
@@ -156,7 +156,7 @@ void mp_url_unescape_inplace(char *url)
}
}
char *mp_url_unescape(void *talloc_ctx, char *url)
char *mp_url_unescape(void *talloc_ctx, const char *url)
{
char *unescaped = talloc_strdup(talloc_ctx, url);
mp_url_unescape_inplace(unescaped);
+1 -1
View File
@@ -260,7 +260,7 @@ struct stream *stream_create(const char *url, int flags,
stream_t *open_output_stream(const char *filename, struct mpv_global *global);
void mp_url_unescape_inplace(char *buf);
char *mp_url_unescape(void *talloc_ctx, char *url);
char *mp_url_unescape(void *talloc_ctx, const char *url);
char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok);
// stream_memory.c