Ticket #3547: mc-3547-cleanup-conversion-warning-mc_search_new.patch

File mc-3547-cleanup-conversion-warning-mc_search_new.patch, 13.2 KB (added by and, 6 years ago)
  • lib/filehighlight/ini-file-read.c

    fix -Wconversion warning for mc_search_new()
    
    mc_search_new() parameter orignial_len use once only
    factor out into own function mc_search_new_len()
    
    patch will fix following warnings:
    ini-file-read.c:116:58: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    search.c:418:38: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    ext.c:726:38: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    ext.c:915:44: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    filegui.c:1306:58: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    find.c:406:32: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    find.c:1626:61: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    find.c:1637:55: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    panel.c:2059:38: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    panel.c:2527:38: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    panel.c:2647:38: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    config_parser.c:216:56: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    config_parser.c:259:63: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    config_parser.c:407:57: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    actions_cmd.c:150:69: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    dialogs.c:145:61: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    editcmd.c:1229:39: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    editcmd.c:2570:47: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    editcmd.c:2792:69: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    editcmd_dialogs.c:166:61: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    search.c:254:70: warning: implicit conversion changes signedness: 'int' to 'gsize' (aka 'unsigned long') [-Wsign-conversion]
    
    patch against a5cd0093c5330ae6118cbf2830cf288dd4a68ed0 + previous patches
    compile test with gcc 4.6/4.9/5.2 and clang 3.7
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    
    a b  
    113113 
    114114    mc_filter = g_new0 (mc_fhl_filter_t, 1); 
    115115    mc_filter->type = MC_FLHGH_T_FREGEXP; 
    116     mc_filter->search_condition = mc_search_new (regexp, -1, DEFAULT_CHARSET); 
     116    mc_filter->search_condition = mc_search_new (regexp, DEFAULT_CHARSET); 
    117117    mc_filter->search_condition->is_case_sensitive = TRUE; 
    118118    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; 
    119119 
     
    158158 
    159159    mc_filter = g_new0 (mc_fhl_filter_t, 1); 
    160160    mc_filter->type = MC_FLHGH_T_FREGEXP; 
    161     mc_filter->search_condition = mc_search_new (buf->str, buf->len, DEFAULT_CHARSET); 
     161    mc_filter->search_condition = mc_search_new_len (buf->str, buf->len, DEFAULT_CHARSET); 
    162162    mc_filter->search_condition->is_case_sensitive = 
    163163        mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE); 
    164164    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX; 
  • lib/search/search.c

    a b  
    134134 */ 
    135135 
    136136mc_search_t * 
    137 mc_search_new (const gchar * original, gsize original_len, const gchar * original_charset) 
     137mc_search_new (const gchar * original, const gchar * original_charset) 
     138{ 
     139    if (original == NULL) 
     140        return NULL; 
     141    return mc_search_new_len (original, strlen (original), original_charset); 
     142} 
     143mc_search_t * 
     144mc_search_new_len (const gchar * original, gsize original_len, const gchar * original_charset) 
    138145{ 
    139146    mc_search_t *lc_mc_search; 
    140147 
    141148    if (original == NULL) 
    142149        return NULL; 
    143150 
    144     if ((gssize) original_len == -1) 
    145     { 
    146         original_len = strlen (original); 
    147         if (original_len == 0) 
    148             return NULL; 
    149     } 
     151    if (original_len == 0) 
     152        return NULL; 
    150153 
    151154    lc_mc_search = g_new0 (mc_search_t, 1); 
    152155    lc_mc_search->original = g_strndup (original, original_len); 
     
    415418    if (str == NULL) 
    416419        return FALSE; 
    417420 
    418     search = mc_search_new (pattern, -1, pattern_charset); 
     421    search = mc_search_new (pattern, pattern_charset); 
    419422    if (search == NULL) 
    420423        return FALSE; 
    421424 
  • lib/search.h

    a b  
    129129 
    130130/*** declarations of public functions ************************************************************/ 
    131131 
    132 mc_search_t *mc_search_new (const gchar * original, gsize original_len, 
     132mc_search_t *mc_search_new (const gchar * original, const gchar * original_charset); 
     133 
     134mc_search_t *mc_search_new_len (const gchar * original, gsize original_len, 
    133135                            const gchar * original_charset); 
    134136 
    135137void mc_search_free (mc_search_t * lc_mc_search); 
  • src/diffviewer/search.c

    a b  
    251251 
    252252    mc_search_free (dview->search.handle); 
    253253#ifdef HAVE_CHARSET 
    254     dview->search.handle = mc_search_new (dview->search.last_string, -1, cp_source); 
     254    dview->search.handle = mc_search_new (dview->search.last_string, cp_source); 
    255255#else 
    256     dview->search.handle = mc_search_new (dview->search.last_string, -1, NULL); 
     256    dview->search.handle = mc_search_new (dview->search.last_string, NULL); 
    257257#endif 
    258258 
    259259    if (dview->search.handle == NULL) 
  • src/editor/editcmd.c

    a b  
    12261226    edit_search_status_msg_t esm; 
    12271227 
    12281228#ifdef HAVE_CHARSET 
    1229     srch = mc_search_new (match_expr, -1, cp_source); 
     1229    srch = mc_search_new (match_expr, cp_source); 
    12301230#else 
    1231     srch = mc_search_new (match_expr, -1, NULL); 
     1231    srch = mc_search_new (match_expr, NULL); 
    12321232#endif 
    12331233    if (srch == NULL) 
    12341234        return 0; 
     
    25672567    if (edit->search == NULL) 
    25682568    { 
    25692569#ifdef HAVE_CHARSET 
    2570         edit->search = mc_search_new (input1, -1, cp_source); 
     2570        edit->search = mc_search_new (input1, cp_source); 
    25712571#else 
    2572         edit->search = mc_search_new (input1, -1, NULL); 
     2572        edit->search = mc_search_new (input1, NULL); 
    25732573#endif 
    25742574        if (edit->search == NULL) 
    25752575        { 
     
    27892789            g_list_free_full (history, g_free); 
    27902790 
    27912791#ifdef HAVE_CHARSET 
    2792             edit->search = mc_search_new (edit->last_search_string, -1, cp_source); 
     2792            edit->search = mc_search_new (edit->last_search_string, cp_source); 
    27932793#else 
    2794             edit->search = mc_search_new (edit->last_search_string, -1, NULL); 
     2794            edit->search = mc_search_new (edit->last_search_string, NULL); 
    27952795#endif 
    27962796            if (edit->search == NULL) 
    27972797            { 
  • src/editor/editcmd_dialogs.c

    a b  
    163163    mc_search_free (edit->search); 
    164164 
    165165#ifdef HAVE_CHARSET 
    166     edit->search = mc_search_new (edit->last_search_string, -1, cp_source); 
     166    edit->search = mc_search_new (edit->last_search_string, cp_source); 
    167167#else 
    168     edit->search = mc_search_new (edit->last_search_string, -1, NULL); 
     168    edit->search = mc_search_new (edit->last_search_string, NULL); 
    169169#endif 
    170170    if (edit->search != NULL) 
    171171    { 
  • src/filemanager/ext.c

    a b  
    723723    { 
    724724        mc_search_t *search; 
    725725 
    726         search = mc_search_new (ptr, -1, DEFAULT_CHARSET); 
     726        search = mc_search_new (ptr, DEFAULT_CHARSET); 
    727727        if (search != NULL) 
    728728        { 
    729729            search->search_type = MC_SEARCH_T_REGEX; 
     
    912912                if (case_insense) 
    913913                    p += 2; 
    914914 
    915                 search = mc_search_new (p, -1, DEFAULT_CHARSET); 
     915                search = mc_search_new (p, DEFAULT_CHARSET); 
    916916                if (search != NULL) 
    917917                { 
    918918                    search->search_type = MC_SEARCH_T_REGEX; 
  • src/filemanager/filegui.c

    a b  
    13031303            return dest_dir; 
    13041304        } 
    13051305 
    1306         ctx->search_handle = mc_search_new (source_mask, -1, NULL); 
     1306        ctx->search_handle = mc_search_new (source_mask, NULL); 
    13071307 
    13081308        if (ctx->search_handle == NULL) 
    13091309        { 
  • src/filemanager/find.c

    a b  
    403403    mc_search_t *search; 
    404404    gboolean regexp_ok = FALSE; 
    405405 
    406     search = mc_search_new (r, -1, NULL); 
     406    search = mc_search_new (r, NULL); 
    407407 
    408408    if (search != NULL) 
    409409    { 
     
    16231623{ 
    16241624    int ret; 
    16251625 
    1626     search_content_handle = mc_search_new (content_pattern, -1, NULL); 
     1626    search_content_handle = mc_search_new (content_pattern, NULL); 
    16271627    if (search_content_handle) 
    16281628    { 
    16291629        search_content_handle->search_type = 
     
    16341634        search_content_handle->is_all_charsets = options.content_all_charsets; 
    16351635#endif 
    16361636    } 
    1637     search_file_handle = mc_search_new (find_pattern, -1, NULL); 
     1637    search_file_handle = mc_search_new (find_pattern, NULL); 
    16381638    search_file_handle->search_type = options.file_pattern ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX; 
    16391639    search_file_handle->is_case_sensitive = options.file_case_sens; 
    16401640#ifdef HAVE_CHARSET 
  • src/filemanager/panel.c

    a b  
    20562056 
    20572057    g_free (cur_file_ext); 
    20582058 
    2059     search = mc_search_new (reg_exp, -1, NULL); 
     2059    search = mc_search_new (reg_exp, NULL); 
    20602060    search->search_type = MC_SEARCH_T_REGEX; 
    20612061    search->is_case_sensitive = FALSE; 
    20622062 
     
    25242524        return; 
    25252525    } 
    25262526 
    2527     search = mc_search_new (reg_exp, -1, NULL); 
     2527    search = mc_search_new (reg_exp, NULL); 
    25282528    search->search_type = (shell_patterns != 0) ? MC_SEARCH_T_GLOB : MC_SEARCH_T_REGEX; 
    25292529    search->is_entire_line = TRUE; 
    25302530    search->is_case_sensitive = case_sens != 0; 
     
    26442644 
    26452645    reg_exp = g_strdup_printf ("%s*", panel->search_buffer); 
    26462646    esc_str = strutils_escape (reg_exp, ",|\\{}[]", TRUE); 
    2647     search = mc_search_new (esc_str, -1, NULL); 
     2647    search = mc_search_new (esc_str, NULL); 
    26482648    search->search_type = MC_SEARCH_T_GLOB; 
    26492649    search->is_entire_line = TRUE; 
    26502650 
  • src/vfs/sftpfs/config_parser.c

    a b  
    213213 
    214214    mc_return_val_if_error (mcerror, FALSE); 
    215215 
    216     host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", -1, DEFAULT_CHARSET); 
     216    host_regexp = mc_search_new ("^\\s*host\\s+(.*)$", DEFAULT_CHARSET); 
    217217    host_regexp->search_type = MC_SEARCH_T_REGEX; 
    218218    host_regexp->is_case_sensitive = FALSE; 
    219219 
     
    256256            { 
    257257                mc_search_t *pattern_regexp; 
    258258 
    259                 pattern_regexp = mc_search_new (host_pattern, -1, DEFAULT_CHARSET); 
     259                pattern_regexp = mc_search_new (host_pattern, DEFAULT_CHARSET); 
    260260                pattern_regexp->search_type = MC_SEARCH_T_GLOB; 
    261261                pattern_regexp->is_case_sensitive = FALSE; 
    262262                pattern_regexp->is_entire_line = TRUE; 
     
    404404    for (i = 0; config_variables[i].pattern != NULL; i++) 
    405405    { 
    406406        config_variables[i].pattern_regexp = 
    407             mc_search_new (config_variables[i].pattern, -1, DEFAULT_CHARSET); 
     407            mc_search_new (config_variables[i].pattern, DEFAULT_CHARSET); 
    408408        config_variables[i].pattern_regexp->search_type = MC_SEARCH_T_REGEX; 
    409409        config_variables[i].pattern_regexp->is_case_sensitive = FALSE; 
    410410        config_variables[i].offset = structure_offsets[i]; 
  • src/viewer/actions_cmd.c

    a b  
    147147            g_list_free_full (history, g_free); 
    148148 
    149149#ifdef HAVE_CHARSET 
    150             view->search = mc_search_new (view->last_search_string, -1, cp_source); 
     150            view->search = mc_search_new (view->last_search_string, cp_source); 
    151151#else 
    152             view->search = mc_search_new (view->last_search_string, -1, NULL); 
     152            view->search = mc_search_new (view->last_search_string, NULL); 
    153153#endif 
    154154            view->search_nroff_seq = mcview_nroff_seq_new (view); 
    155155 
  • src/viewer/dialogs.c

    a b  
    142142    mc_search_free (view->search); 
    143143 
    144144#ifdef HAVE_CHARSET 
    145     view->search = mc_search_new (view->last_search_string, -1, cp_source); 
     145    view->search = mc_search_new (view->last_search_string, cp_source); 
    146146#else 
    147     view->search = mc_search_new (view->last_search_string, -1, NULL); 
     147    view->search = mc_search_new (view->last_search_string, NULL); 
    148148#endif 
    149149    view->search_nroff_seq = mcview_nroff_seq_new (view); 
    150150    if (view->search != NULL) 
  • tests/lib/search/glob_prepare_replace_str.c

    a b  
    7171    mc_search_t *s; 
    7272    char *dest_str; 
    7373 
    74     s = mc_search_new (data->glob_str, -1, NULL); 
     74    s = mc_search_new (data->glob_str, NULL); 
    7575    s->is_case_sensitive = TRUE; 
    7676    s->search_type = MC_SEARCH_T_GLOB; 
    7777