Skip to content

Commit

Permalink
refactor: change return value of TermFindFiles
Browse files Browse the repository at this point in the history
It turns out that `TermFindFiles` and  `TermFindOne` were made
to return hard links just for testfind. Nowhere else in the code is 
hard links count used.
Testfind will later directly get the count from its own fileset without 
the need for calling `TermFindFiles`
  • Loading branch information
alaaeddineelamri authored and arogge committed Mar 2, 2023
1 parent 4e78fde commit 86450c4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
8 changes: 2 additions & 6 deletions core/src/findlib/find.cc
Expand Up @@ -445,20 +445,16 @@ static int OurCallback(JobControlRecord* jcr,
}

// Terminate FindFiles() and release all allocated memory
int TermFindFiles(FindFilesPacket* ff)
void TermFindFiles(FindFilesPacket* ff)
{
int hard_links = 0;

if (ff) {
FreePoolMemory(ff->sys_fname);
if (ff->fname_save) { FreePoolMemory(ff->fname_save); }
if (ff->link_save) { FreePoolMemory(ff->link_save); }
if (ff->ignoredir_fname) { FreePoolMemory(ff->ignoredir_fname); }
hard_links = TermFindOne(ff);
TermFindOne(ff);
free(ff);
}

return hard_links;
}

// Allocate a new include/exclude block.
Expand Down
2 changes: 1 addition & 1 deletion core/src/findlib/find.h
Expand Up @@ -280,7 +280,7 @@ int FindFiles(JobControlRecord* jcr,
bool MatchFiles(JobControlRecord* jcr,
FindFilesPacket* ff,
int sub(JobControlRecord*, FindFilesPacket* ff_pkt, bool));
int TermFindFiles(FindFilesPacket* ff);
void TermFindFiles(FindFilesPacket* ff);
bool IsInFileset(FindFilesPacket* ff);
bool AcceptFile(FindFilesPacket* ff);
findIncludeExcludeItem* allocate_new_incexe(void);
Expand Down
12 changes: 3 additions & 9 deletions core/src/findlib/find_one.cc
Expand Up @@ -1033,15 +1033,9 @@ int FindOneFile(JobControlRecord* jcr,
}
}

int TermFindOne(FindFilesPacket* ff)
void TermFindOne(FindFilesPacket* ff)
{
int count;

if (ff->linkhash == NULL) { return 0; }

count = ff->linkhash->size();
if (ff->linkhash == nullptr) { return; }
delete ff->linkhash;
ff->linkhash = NULL;

return count;
ff->linkhash = nullptr;
}
2 changes: 1 addition & 1 deletion core/src/findlib/find_one.h
Expand Up @@ -29,7 +29,7 @@ int FindOneFile(JobControlRecord* jcr,
char* p,
dev_t parent_device,
bool top_level);
int TermFindOne(FindFilesPacket* ff);
void TermFindOne(FindFilesPacket* ff);
bool HasFileChanged(JobControlRecord* jcr, FindFilesPacket* ff_pkt);
bool CheckChanges(JobControlRecord* jcr, FindFilesPacket* ff_pkt);

Expand Down

0 comments on commit 86450c4

Please sign in to comment.