1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: ensure namelist is defined

Seems coverity doesn't have good model for scandir.
Let's ensure pointer is seen as defined.
This commit is contained in:
Zdenek Kabelac 2024-03-25 17:16:00 +01:00
parent 4abdc5981a
commit 421afd287a

View File

@ -1390,7 +1390,7 @@ static int _filter_backup_files(const struct dirent *de)
static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, time_t *tp, uint32_t df_counter) static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, time_t *tp, uint32_t df_counter)
{ {
struct dirent *de; struct dirent *de;
struct dirent **namelist; struct dirent **namelist = NULL;
DIR *dir; DIR *dir;
FILE *fp = NULL; FILE *fp = NULL;
struct tm *tm; struct tm *tm;
@ -1529,7 +1529,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
log_debug("Limit backup %u found %u sorted %d removing %u.", log_debug("Limit backup %u found %u sorted %d removing %u.",
backup_limit, backup_count, sort_count, remove_count); backup_limit, backup_count, sort_count, remove_count);
for (i = 0; i < sort_count; i++) { for (i = 0; namelist && i < sort_count; i++) {
if (remove_count) { if (remove_count) {
log_debug("Remove backup %s", namelist[i]->d_name); log_debug("Remove backup %s", namelist[i]->d_name);
if (unlinkat(dir_fd, namelist[i]->d_name, 0) < 0 && errno != ENOENT) if (unlinkat(dir_fd, namelist[i]->d_name, 0) < 0 && errno != ENOENT)