Ticket #4179: mc-4179-internal.c-fix-cast-qual-warning.patch

File mc-4179-internal.c-fix-cast-qual-warning.patch, 2.4 KB (added by and, 4 years ago)
  • src/vfs/sftpfs/internal.c

    From 92f34d40297a59c470d17c4b64b81b06dfc80097 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Tue, 22 Dec 2020 21:15:41 +0000
    Subject: [PATCH] (internal.c) Fix -Wcast-qual warning
    
    internal.c:400:14: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
        tmp_path = sftpfs_fix_filename (path_element2->path, &tmp_path_len);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    internal.c:601:25: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
        tmp_path = (char *) sftpfs_fix_filename (path_element2->path, &tmp_path_len);
                            ^
    
    Found by Clang-11
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/sftpfs/internal.c | 10 ++++++----
     1 file changed, 6 insertions(+), 4 deletions(-)
    
    diff --git a/src/vfs/sftpfs/internal.c b/src/vfs/sftpfs/internal.c
    index baa2de4f7..74a4d5c67 100644
    a b sftpfs_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** 
    391391    const vfs_path_element_t *path_element1; 
    392392    const vfs_path_element_t *path_element2 = NULL; 
    393393    char *tmp_path; 
     394    const char *ctmp_path; 
    394395    unsigned int tmp_path_len; 
    395396    int res; 
    396397 
    397398    if (!sftpfs_op_init (&super, &path_element2, vpath2, mcerror)) 
    398399        return -1; 
    399400 
    400     tmp_path = (char *) sftpfs_fix_filename (path_element2->path, &tmp_path_len); 
    401     tmp_path = g_strndup (tmp_path, tmp_path_len); 
     401    ctmp_path = sftpfs_fix_filename (path_element2->path, &tmp_path_len); 
     402    tmp_path = g_strndup (ctmp_path, tmp_path_len); 
    402403 
    403404    path_element1 = vfs_path_get_by_index (vpath1, -1); 
    404405 
    sftpfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** m 
    592593    const vfs_path_element_t *path_element1; 
    593594    const vfs_path_element_t *path_element2 = NULL; 
    594595    char *tmp_path; 
     596    const char *ctmp_path; 
    595597    unsigned int tmp_path_len; 
    596598    int res; 
    597599 
    598600    if (!sftpfs_op_init (&super, &path_element2, vpath2, mcerror)) 
    599601        return -1; 
    600602 
    601     tmp_path = (char *) sftpfs_fix_filename (path_element2->path, &tmp_path_len); 
    602     tmp_path = g_strndup (tmp_path, tmp_path_len); 
     603    ctmp_path = sftpfs_fix_filename (path_element2->path, &tmp_path_len); 
     604    tmp_path = g_strndup (ctmp_path, tmp_path_len); 
    603605 
    604606    path_element1 = vfs_path_get_by_index (vpath1, -1); 
    605607