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) |
3546 | 3546 | const WPanel *panel0 = (const WPanel *) f0; |
3547 | 3547 | const WPanel *panel1 = (const WPanel *) f1; |
3548 | 3548 | |
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); |
3550 | 3550 | is_dir0 = S_ISDIR (selection (panel0)->st.st_mode); |
3551 | 3551 | if (is_dir0) |
3552 | 3552 | { |
… |
… |
dview_diff_cmd (const void *f0, const void *f1) |
3555 | 3555 | goto ret; |
3556 | 3556 | } |
3557 | 3557 | |
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); |
3559 | 3559 | is_dir1 = S_ISDIR (selection (panel1)->st.st_mode); |
3560 | 3560 | if (is_dir1) |
3561 | 3561 | { |
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) |
333 | 333 | { |
334 | 334 | vfs_path_t *src_name, *dst_name; |
335 | 335 | |
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); |
338 | 338 | if (compare_files (src_name, dst_name, source->st.st_size)) |
339 | 339 | do_file_mark (panel, i, 1); |
340 | 340 | vfs_path_free (src_name); |
… |
… |
do_link (link_type_t link_type, const char *fname) |
371 | 371 | |
372 | 372 | /* suggest the full path for symlink, and either the full or |
373 | 373 | 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); |
375 | 375 | |
376 | 376 | 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); |
378 | 378 | else |
379 | 379 | d = vfs_path_from_str (fname); |
380 | 380 | |
… |
… |
mkdir_cmd (void) |
875 | 875 | if (dir[0] == '\\' && dir[1] == '~') |
876 | 876 | tmpdir = dir + 1; |
877 | 877 | |
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); |
879 | 879 | } |
880 | 880 | |
881 | 881 | save_cwds_stat (); |
diff --git a/src/filemanager/command.c b/src/filemanager/command.c
index c2a9225..d68e773 100644
a
|
b
|
do_cd_command (char *orig_cmd) |
426 | 426 | if (IS_PATH_SEP (cmd[operand_pos])) |
427 | 427 | new_vpath = vfs_path_from_str (cmd + operand_pos); |
428 | 428 | 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); |
430 | 430 | |
431 | 431 | sync_tree (new_vpath); |
432 | 432 | } |
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) |
208 | 208 | { |
209 | 209 | vfs_path_t *tmp_vpath; |
210 | 210 | |
211 | | tmp_vpath = vfs_path_append_new (vpath, "..", NULL); |
| 211 | tmp_vpath = vfs_path_append_new (vpath, "..", (char *) NULL); |
212 | 212 | ret = mc_stat (tmp_vpath, st) == 0; |
213 | 213 | vfs_path_free (tmp_vpath); |
214 | 214 | } |
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 |
559 | 559 | if (DIR_IS_DOT (dirent->d_name) || DIR_IS_DOTDOT (dirent->d_name)) |
560 | 560 | continue; |
561 | 561 | |
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); |
563 | 563 | |
564 | 564 | res = mc_lstat (tmp_vpath, &s); |
565 | 565 | if (res == 0) |
… |
… |
recursive_erase (file_op_total_context_t * tctx, file_op_context_t * ctx, const |
1127 | 1127 | if (DIR_IS_DOT (next->d_name) || DIR_IS_DOTDOT (next->d_name)) |
1128 | 1128 | continue; |
1129 | 1129 | |
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); |
1131 | 1131 | if (mc_lstat (tmp_vpath, &buf) != 0) |
1132 | 1132 | { |
1133 | 1133 | mc_closedir (reading); |
… |
… |
panel_compute_totals (const WPanel * panel, dirsize_status_msg_t * sm, size_t * |
1293 | 1293 | vfs_path_t *p; |
1294 | 1294 | FileProgressStatus status; |
1295 | 1295 | |
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); |
1297 | 1297 | status = compute_dir_size (p, sm, &dir_count, ret_count, ret_total, compute_symlinks); |
1298 | 1298 | vfs_path_free (p); |
1299 | 1299 | |
… |
… |
copy_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha |
2136 | 2136 | vfs_path_t *tmp; |
2137 | 2137 | |
2138 | 2138 | 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); |
2140 | 2140 | vfs_path_free (tmp); |
2141 | 2141 | |
2142 | 2142 | } |
… |
… |
move_dir_dir (file_op_total_context_t * tctx, file_op_context_t * ctx, const cha |
2325 | 2325 | vfs_path_t *tmp; |
2326 | 2326 | |
2327 | 2327 | 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); |
2329 | 2329 | vfs_path_free (tmp); |
2330 | 2330 | } |
2331 | 2331 | |
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) |
92 | 92 | return (-1); |
93 | 93 | } |
94 | 94 | |
95 | | q = vfs_path_append_new (s_vpath, "..", NULL); |
| 95 | q = vfs_path_append_new (s_vpath, "..", (char *) NULL); |
96 | 96 | result = my_mkdir_rec (q, mode); |
97 | 97 | vfs_path_free (q); |
98 | 98 | |
diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c
index b4c9073..5561002 100644
a
|
b
|
put_link (WPanel * panel) |
751 | 751 | vfs_path_t *vpath; |
752 | 752 | int i; |
753 | 753 | |
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); |
755 | 755 | i = mc_readlink (vpath, buffer, sizeof (buffer) - 1); |
756 | 756 | vfs_path_free (vpath); |
757 | 757 | |
… |
… |
prepend_cwd_on_local (const char *filename) |
969 | 969 | |
970 | 970 | vfs_path_free (vpath); |
971 | 971 | |
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); |
973 | 973 | } |
974 | 974 | |
975 | 975 | /* --------------------------------------------------------------------------------------------- */ |
diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c
index 30d2706..d8dd364 100644
a
|
b
|
display_mini_info (WPanel * panel) |
1009 | 1009 | int len; |
1010 | 1010 | |
1011 | 1011 | 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); |
1013 | 1013 | len = mc_readlink (lc_link_vpath, link_target, MC_MAXPATHLEN - 1); |
1014 | 1014 | vfs_path_free (lc_link_vpath); |
1015 | 1015 | if (len > 0) |
… |
… |
do_enter_on_file_entry (file_entry_t * fe) |
2771 | 2771 | return TRUE; |
2772 | 2772 | } |
2773 | 2773 | |
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); |
2775 | 2775 | |
2776 | 2776 | /* Try associated command */ |
2777 | 2777 | ok = regex_command (full_name_vpath, "Open") != 0; |
… |
… |
do_enter_on_file_entry (file_entry_t * fe) |
2780 | 2780 | return TRUE; |
2781 | 2781 | |
2782 | 2782 | /* 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); |
2784 | 2784 | ok = (is_exe (fe->st.st_mode) && if_link_is_exe (full_name_vpath, fe)); |
2785 | 2785 | vfs_path_free (full_name_vpath); |
2786 | 2786 | if (!ok) |
… |
… |
do_enter_on_file_entry (file_entry_t * fe) |
2799 | 2799 | int ret; |
2800 | 2800 | vfs_path_t *tmp_vpath; |
2801 | 2801 | |
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); |
2803 | 2803 | ret = mc_setctl (tmp_vpath, VFS_SETCTL_RUN, NULL); |
2804 | 2804 | vfs_path_free (tmp_vpath); |
2805 | 2805 | /* We took action only if the dialog was shown or the execution |
… |
… |
chdir_other_panel (WPanel * panel) |
2846 | 2846 | set_display_type (get_other_index (), view_listing); |
2847 | 2847 | |
2848 | 2848 | 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); |
2850 | 2850 | else |
2851 | 2851 | { |
2852 | 2852 | new_dir_vpath = vfs_path_append_new (panel->cwd_vpath, "..", (char *) NULL); |
… |
… |
chdir_to_readlink (WPanel * panel) |
2931 | 2931 | if (IS_PATH_SEP (*buffer)) |
2932 | 2932 | new_dir_vpath = vfs_path_from_str (buffer); |
2933 | 2933 | 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); |
2935 | 2935 | |
2936 | 2936 | change_panel (); |
2937 | 2937 | do_cd (new_dir_vpath, cd_exact); |
diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
index 5742fea..3f48274 100644
a
|
b
|
do_panelize_cd (WPanel * panel) |
419 | 419 | |
420 | 420 | tmp_vpath = |
421 | 421 | vfs_path_append_new (panelized_panel.root_vpath, panelized_panel.list.list[i].fname, |
422 | | NULL); |
| 422 | (char *) NULL); |
423 | 423 | fname = vfs_path_as_str (tmp_vpath); |
424 | 424 | list->list[i].fnamelen = strlen (fname); |
425 | 425 | list->list[i].fname = g_strndup (fname, list->list[i].fnamelen); |
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) |
747 | 747 | if (IS_PATH_SEP (cname[0]) && cname[1] == '\0') |
748 | 748 | name = vfs_path_build_filename (PATH_SEP_STR, subname, NULL); |
749 | 749 | else |
750 | | name = vfs_path_append_new (ts.check_name, subname, NULL); |
| 750 | name = vfs_path_append_new (ts.check_name, subname, (char *) NULL); |
751 | 751 | |
752 | 752 | /* Search for the subdirectory */ |
753 | 753 | current = ts.check_start; |
… |
… |
tree_store_rescan (const vfs_path_t * vpath) |
923 | 923 | if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name)) |
924 | 924 | continue; |
925 | 925 | |
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); |
927 | 927 | if (mc_lstat (tmp_vpath, &buf) != -1 && S_ISDIR (buf.st_mode)) |
928 | 928 | tree_store_mark_checked (dp->d_name); |
929 | 929 | vfs_path_free (tmp_vpath); |