Simpler const fix for fill_metadata_from_path()

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Sat, 2 May 2026 23:02:33 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 8768266d27616ec58278c980558dffcba2a1ef18
Author: Solomon Peachy <[email protected]>
Date:   Sat May 2 23:01:00 2026 -0400

    Simpler const fix for fill_metadata_from_path()
    
    Make sure the output of strchr(const*) is assinged to a const*
    
    This way the filename argument can stay const
    
    Change-Id: Ie46be936491eb62ba2a7e729b8cd7881e205bba7

diff --git a/lib/rbcodec/metadata/metadata.c b/lib/rbcodec/metadata/metadata.c
index fafd227c14..00c6bfd581 100644
--- a/lib/rbcodec/metadata/metadata.c
+++ b/lib/rbcodec/metadata/metadata.c
@@ -381,7 +381,7 @@ bool format_buffers_with_offset(int afmt)
 /* Simple file type probing by looking at the filename extension. */
 unsigned int probe_file_format(const char *filename)
 {
-    char *suffix;
+    const char *suffix;
     unsigned int i;
 
     suffix = strrchr(filename, '.');
@@ -418,7 +418,7 @@ unsigned int probe_file_format(const char *filename)
  * file that would prevent playback. supply a filedescriptor <0 and the file will be opened
  * and closed automatically within the get_metadata call
  * get_metadata_ex allows flags to change the way get_metadata behaves
- * METADATA_EXCLUDE_ID3_PATH  won't copy filename path to the id3 path buffer 
+ * METADATA_EXCLUDE_ID3_PATH  won't copy filename path to the id3 path buffer
  * METADATA_CLOSE_FD_ON_EXIT closes the open filedescriptor on exit
  */
 bool get_metadata_ex(struct mp3entry* id3, int fd, const char* trackname, int flags)
@@ -554,8 +554,8 @@ void fill_metadata_from_path(struct mp3entry *id3, const char *trackname)
     wipe_mp3entry(id3);
 
     /* Find the filename portion of the path */
-    p = strrchr(trackname, '/');
-    strlcpy(id3->id3v2buf, p ? ++p : id3->path, ID3V2_BUF_SIZE);
+    const char *pt = strrchr(trackname, '/');
+    strlcpy(id3->id3v2buf, pt ? ++pt : id3->path, ID3V2_BUF_SIZE);
 
     /* Get the format from the extension and trim it off */
     p = strrchr(id3->id3v2buf, '.');
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c
index b9e57d9573..44fba90445 100644
--- a/lib/skin_parser/skin_debug.c
+++ b/lib/skin_parser/skin_debug.c
@@ -317,7 +317,7 @@ void skin_error_format_message(void)
     char text[128];
     if (!error_line_start)
         return;
-    char* line_end = strchr(error_line_start, '\n');
+    const char* line_end = strchr(error_line_start, '\n');
     int len = MIN(line_end - error_line_start, 80);
     if (!line_end)
         len = strlen(error_line_start);
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs