mirror of
https://github.com/troglobit/libite.git
synced 2026-10-18 10:49:38 +00:00
libite: Fix cppcheck warnings in rsync unit test
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
5eb4f640b1
commit
80c2a132cd
1 file changed
+17
-12
@@ -142,26 +142,31 @@ static int makedir(char *buf, size_t buf_len, char *dir, char *name, mode_t mode
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int find(char *file, char **files, int num)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
for (n = 0; n < num; n++)
|
||||||
|
if (!strncmp (files[n], file, MAX(strlen(files[n]), strlen(file))))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Prune old files, no longer existing on source, from destination directory. */
|
/* Prune old files, no longer existing on source, from destination directory. */
|
||||||
static int prune(char *dst, char **new_files, int new_num)
|
static int prune(char *dst, char **new_files, int new_num)
|
||||||
{
|
{
|
||||||
int i, num, result = 0;
|
int num, result = 0;
|
||||||
char **files;
|
char **files;
|
||||||
|
|
||||||
int find(char *file) {
|
|
||||||
int n;
|
|
||||||
|
|
||||||
for (n = 0; n < new_num; n++)
|
|
||||||
if (!strncmp (new_files[n], file, MAX(strlen(new_files[n]), strlen(file))))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
num = dir(dst, "", NULL, &files, 0);
|
num = dir(dst, "", NULL, &files, 0);
|
||||||
if (num) {
|
if (num) {
|
||||||
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
if (!find(files[i])) {
|
if (!find(files[i], new_files, new_num)) {
|
||||||
char *name;
|
char *name;
|
||||||
size_t len = strlen(files[i]) + 2 + strlen(dst);
|
size_t len = strlen(files[i]) + 2 + strlen(dst);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user