Ticket #3607: mc-3607-cppcheck-Cleanup-Passing-NULL-after-the-last-warning.patch

File mc-3607-cppcheck-Cleanup-Passing-NULL-after-the-last-warning.patch, 16.1 KB (added by and, 8 years ago)
  • src/diffviewer/ydiff.c

    From d5ae5fdfa488d71d76f9be66a5d3340beb4e5e7f Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Fri, 25 Mar 2016 18:33:44 +0000
    Subject: [PATCH] cppcheck: Cleanup Passing NULL after the last typed argument warning
    
    Cleanup Passing NULL after the last typed argument warning.
    
    Found  by cppcheck:
    [src/diffviewer/ydiff.c:3549]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/diffviewer/ydiff.c:3558]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/cmd.c:336]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/cmd.c:337]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/cmd.c:374]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/cmd.c:377]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/cmd.c:878]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/command.c:429]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/dir.c:211]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/file.c:562]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/file.c:1130]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/file.c:1296]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/file.c:2139]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/file.c:2328]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/filenot.c:95]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/midnight.c:754]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/midnight.c:972]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:1012]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:2774]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:2783]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:2802]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:2849]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panel.c:2934]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/panelize.c:421]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/treestore.c:750]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    [src/filemanager/treestore.c:926]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/diffviewer/ydiff.c      |  4 ++--
     src/filemanager/cmd.c       | 10 +++++-----
     src/filemanager/command.c   |  2 +-
     src/filemanager/dir.c       |  2 +-
     src/filemanager/file.c      | 10 +++++-----
     src/filemanager/filenot.c   |  2 +-
     src/filemanager/midnight.c  |  4 ++--
     src/filemanager/panel.c     | 12 ++++++------
     src/filemanager/panelize.c  |  2 +-
     src/filemanager/treestore.c |  4 ++--
     10 files changed, 26 insertions(+), 26 deletions(-)
    
    diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c
    index c4c8f67..0c7acfd 100644
    a b dview_diff_cmd (const void *f0, const void *f1) 
    35463546            const WPanel *panel0 = (const WPanel *) f0; 
    35473547            const WPanel *panel1 = (const WPanel *) f1; 
    35483548 
    3549             file0 = vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname, NULL); 
     3549            file0 = vfs_path_append_new (panel0->cwd_vpath, selection (panel0)->fname, (char *) NULL); 
    35503550            is_dir0 = S_ISDIR (selection (panel0)->st.st_mode); 
    35513551            if (is_dir0) 
    35523552            { 
    dview_diff_cmd (const void *f0, const void *f1) 
    35553555                goto ret; 
    35563556            } 
    35573557 
    3558             file1 = vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname, NULL); 
     3558            file1 = vfs_path_append_new (panel1->cwd_vpath, selection (panel1)->fname, (char *) NULL); 
    35593559            is_dir1 = S_ISDIR (selection (panel1)->st.st_mode); 
    35603560            if (is_dir1) 
    35613561            { 
  • src/filemanager/cmd.c

    diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c
    index d384273..5435fb3 100644
    a b compare_dir (WPanel * panel, WPanel * other, enum CompareMode mode) 
    333333            { 
    334334                vfs_path_t *src_name, *dst_name; 
    335335 
    336                 src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, NULL); 
    337                 dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, NULL); 
     336                src_name = vfs_path_append_new (panel->cwd_vpath, source->fname, (char *) NULL); 
     337                dst_name = vfs_path_append_new (other->cwd_vpath, target->fname, (char *) NULL); 
    338338                if (compare_files (src_name, dst_name, source->st.st_size)) 
    339339                    do_file_mark (panel, i, 1); 
    340340                vfs_path_free (src_name); 
    do_link (link_type_t link_type, const char *fname) 
    371371 
    372372        /* suggest the full path for symlink, and either the full or 
    373373           relative path to the file it points to  */ 
    374         s = vfs_path_append_new (current_panel->cwd_vpath, fname, NULL); 
     374        s = vfs_path_append_new (current_panel->cwd_vpath, fname, (char *) NULL); 
    375375 
    376376        if (get_other_type () == view_listing) 
    377             d = vfs_path_append_new (other_panel->cwd_vpath, fname, NULL); 
     377            d = vfs_path_append_new (other_panel->cwd_vpath, fname, (char *) NULL); 
    378378        else 
    379379            d = vfs_path_from_str (fname); 
    380380 
    mkdir_cmd (void) 
    875875            if (dir[0] == '\\' && dir[1] == '~') 
    876876                tmpdir = dir + 1; 
    877877 
    878             absdir = vfs_path_append_new (current_panel->cwd_vpath, tmpdir, NULL); 
     878            absdir = vfs_path_append_new (current_panel->cwd_vpath, tmpdir, (char *) NULL); 
    879879        } 
    880880 
    881881        save_cwds_stat (); 
  • src/filemanager/command.c

    diff --git a/src/filemanager/command.c b/src/filemanager/command.c
    index c2a9225..d68e773 100644
    a b do_cd_command (char *orig_cmd) 
    426426            if (IS_PATH_SEP (cmd[operand_pos])) 
    427427                new_vpath = vfs_path_from_str (cmd + operand_pos); 
    428428            else 
    429                 new_vpath = vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos, NULL); 
     429                new_vpath = vfs_path_append_new (current_panel->cwd_vpath, cmd + operand_pos, (char *) NULL); 
    430430 
    431431            sync_tree (new_vpath); 
    432432        } 
  • src/filemanager/dir.c

    diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c
    index da689dd..232dcbb 100644
    a b dir_get_dotdot_stat (const vfs_path_t * vpath, struct stat *st) 
    208208        { 
    209209            vfs_path_t *tmp_vpath; 
    210210 
    211             tmp_vpath = vfs_path_append_new (vpath, "..", NULL); 
     211            tmp_vpath = vfs_path_append_new (vpath, "..", (char *) NULL); 
    212212            ret = mc_stat (tmp_vpath, st) == 0; 
    213213            vfs_path_free (tmp_vpath); 
    214214        } 
  • src/filemanager/file.c

    diff --git a/src/filemanager/file.c b/src/filemanager/file.c
    index 188b2fa..c1784ab 100644
    a b do_compute_dir_size (const vfs_path_t * dirname_vpath, dirsize_status_msg_t * ds 
    559559        if (DIR_IS_DOT (dirent->d_name) || DIR_IS_DOTDOT (dirent->d_name)) 
    560560            continue; 
    561561 
    562         tmp_vpath = vfs_path_append_new (dirname_vpath, dirent->d_name, NULL); 
     562        tmp_vpath = vfs_path_append_new (dirname_vpath, dirent->d_name, (char *) NULL); 
    563563 
    564564        res = mc_lstat (tmp_vpath, &s); 
    565565        if (res == 0) 
    recursive_erase (file_op_total_context_t * tctx, file_op_context_t * ctx, const 
    11271127        if (DIR_IS_DOT (next->d_name) || DIR_IS_DOTDOT (next->d_name)) 
    11281128            continue; 
    11291129 
    1130         tmp_vpath = vfs_path_append_new (vpath, next->d_name, NULL); 
     1130        tmp_vpath = vfs_path_append_new (vpath, next->d_name, (char *) NULL); 
    11311131        if (mc_lstat (tmp_vpath, &buf) != 0) 
    11321132        { 
    11331133            mc_closedir (reading); 
    panel_compute_totals (const WPanel * panel, dirsize_status_msg_t * sm, size_t * 
    12931293            vfs_path_t *p; 
    12941294            FileProgressStatus status; 
    12951295 
    1296             p = vfs_path_append_new (panel->cwd_vpath, panel->dir.list[i].fname, NULL); 
     1296            p = vfs_path_append_new (panel->cwd_vpath, panel->dir.list[i].fname, (char *) NULL); 
    12971297            status = compute_dir_size (p, sm, &dir_count, ret_count, ret_total, compute_symlinks); 
    12981298            vfs_path_free (p); 
    12991299 
    copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha 
    21362136            vfs_path_t *tmp; 
    21372137 
    21382138            tmp = dst_vpath; 
    2139             dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL); 
     2139            dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), (char *) NULL); 
    21402140            vfs_path_free (tmp); 
    21412141 
    21422142        } 
    move_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha 
    23252325        vfs_path_t *tmp; 
    23262326 
    23272327        tmp = dst_vpath; 
    2328         dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), NULL); 
     2328        dst_vpath = vfs_path_append_new (dst_vpath, x_basename (s), (char *) NULL); 
    23292329        vfs_path_free (tmp); 
    23302330    } 
    23312331 
  • src/filemanager/filenot.c

    diff --git a/src/filemanager/filenot.c b/src/filemanager/filenot.c
    index 90de998..4e4224e 100644
    a b my_mkdir_rec (const vfs_path_t * s_vpath, mode_t mode) 
    9292        return (-1); 
    9393    } 
    9494 
    95     q = vfs_path_append_new (s_vpath, "..", NULL); 
     95    q = vfs_path_append_new (s_vpath, "..", (char *) NULL); 
    9696    result = my_mkdir_rec (q, mode); 
    9797    vfs_path_free (q); 
    9898 
  • src/filemanager/midnight.c

    diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c
    index b4c9073..5561002 100644
    a b put_link (WPanel * panel) 
    751751        vfs_path_t *vpath; 
    752752        int i; 
    753753 
    754         vpath = vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname, NULL); 
     754        vpath = vfs_path_append_new (panel->cwd_vpath, selection (panel)->fname, (char *) NULL); 
    755755        i = mc_readlink (vpath, buffer, sizeof (buffer) - 1); 
    756756        vfs_path_free (vpath); 
    757757 
    prepend_cwd_on_local (const char *filename) 
    969969 
    970970    vfs_path_free (vpath); 
    971971 
    972     return vfs_path_append_new (vfs_get_raw_current_dir (), filename, NULL); 
     972    return vfs_path_append_new (vfs_get_raw_current_dir (), filename, (char *) NULL); 
    973973} 
    974974 
    975975/* --------------------------------------------------------------------------------------------- */ 
  • src/filemanager/panel.c

    diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
    index 30d2706..d8dd364 100644
    a b display_mini_info (WPanel * panel) 
    10091009        int len; 
    10101010 
    10111011        lc_link_vpath = 
    1012             vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname, NULL); 
     1012            vfs_path_append_new (panel->cwd_vpath, panel->dir.list[panel->selected].fname, (char *) NULL); 
    10131013        len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1); 
    10141014        vfs_path_free (lc_link_vpath); 
    10151015        if (len > 0) 
    do_enter_on_file_entry (file_entry_t * fe) 
    27712771        return TRUE; 
    27722772    } 
    27732773 
    2774     full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, NULL); 
     2774    full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, (char *) NULL); 
    27752775 
    27762776    /* Try associated command */ 
    27772777    ok = regex_command (full_name_vpath, "Open") != 0; 
    do_enter_on_file_entry (file_entry_t * fe) 
    27802780        return TRUE; 
    27812781 
    27822782    /* Check if the file is executable */ 
    2783     full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, NULL); 
     2783    full_name_vpath = vfs_path_append_new (current_panel->cwd_vpath, fe->fname, (char *) NULL); 
    27842784    ok = (is_exe (fe->st.st_mode) && if_link_is_exe (full_name_vpath, fe)); 
    27852785    vfs_path_free (full_name_vpath); 
    27862786    if (!ok) 
    do_enter_on_file_entry (file_entry_t * fe) 
    27992799        int ret; 
    28002800        vfs_path_t *tmp_vpath; 
    28012801 
    2802         tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, NULL); 
     2802        tmp_vpath = vfs_path_append_new (vfs_get_raw_current_dir (), fe->fname, (char *) NULL); 
    28032803        ret = mc_setctl (tmp_vpath, VFS_SETCTL_RUN, NULL); 
    28042804        vfs_path_free (tmp_vpath); 
    28052805        /* We took action only if the dialog was shown or the execution 
    chdir_other_panel (WPanel * panel) 
    28462846        set_display_type (get_other_index (), view_listing); 
    28472847 
    28482848    if (S_ISDIR (entry->st.st_mode) || entry->f.link_to_dir) 
    2849         new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname, NULL); 
     2849        new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, entry->fname, (char *) NULL); 
    28502850    else 
    28512851    { 
    28522852        new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, "..", (char *) NULL); 
    chdir_to_readlink (WPanel * panel) 
    29312931    if (IS_PATH_SEP (*buffer)) 
    29322932        new_dir_vpath = vfs_path_from_str (buffer); 
    29332933    else 
    2934         new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, buffer, NULL); 
     2934        new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, buffer, (char *) NULL); 
    29352935 
    29362936    change_panel (); 
    29372937    do_cd (new_dir_vpath, cd_exact); 
  • src/filemanager/panelize.c

    diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
    index 5742fea..3f48274 100644
    a b do_panelize_cd (WPanel * panel) 
    419419 
    420420            tmp_vpath = 
    421421                vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname, 
    422                                      NULL); 
     422                                     (char *) NULL); 
    423423            fname = vfs_path_as_str (tmp_vpath); 
    424424            list->list[i].fnamelen = strlen (fname); 
    425425            list->list[i].fname = g_strndup (fname, list->list[i].fnamelen); 
  • src/filemanager/treestore.c

    diff --git a/src/filemanager/treestore.c b/src/filemanager/treestore.c
    index 41f19c3..badbbb9 100644
    a b tree_store_mark_checked (const char *subname) 
    747747    if (IS_PATH_SEP (cname[0]) && cname[1] == '\0') 
    748748        name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL); 
    749749    else 
    750         name = vfs_path_append_new (ts.check_name, subname, NULL); 
     750        name = vfs_path_append_new (ts.check_name, subname, (char *) NULL); 
    751751 
    752752    /* Search for the subdirectory */ 
    753753    current = ts.check_start; 
    tree_store_rescan (const vfs_path_t * vpath) 
    923923            if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name)) 
    924924                continue; 
    925925 
    926             tmp_vpath = vfs_path_append_new (vpath, dp->d_name, NULL); 
     926            tmp_vpath = vfs_path_append_new (vpath, dp->d_name, (char *) NULL); 
    927927            if (mc_lstat (tmp_vpath, &buf) != -1 && S_ISDIR (buf.st_mode)) 
    928928                tree_store_mark_checked (dp->d_name); 
    929929            vfs_path_free (tmp_vpath);