summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/askloc.c23
-rw-r--r--src/common.c8
-rw-r--r--src/dir.c49
-rw-r--r--src/dirn.c20
-rw-r--r--src/ntfs_udl.c20
-rw-r--r--src/psearchn.c5
6 files changed, 67 insertions, 58 deletions
diff --git a/src/askloc.c b/src/askloc.c
index 3dc41fd..a74ce47 100644
--- a/src/askloc.c
+++ b/src/askloc.c
@@ -299,7 +299,7 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
int offset=0;
int pos_num=0;
int old_LINES=0;
- int old_COLS=0;
+ int old_COLS=1;
do
{
int dst_directory_ok=0;
@@ -573,17 +573,18 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
static void dir_aff_entry(WINDOW *window, file_info_t *file_info)
{
char str[11];
- char datestr[80];
- if(file_info->td_mtime!=0)
+ char datestr[80];
{
- const struct tm *tm_p= localtime(&file_info->td_mtime);
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- /* May have to use %d instead of %e */
- } else {
- strncpy(datestr, " ",sizeof(datestr));
+ const struct tm *tm_p;
+ if(file_info->td_mtime!=0 && (tm_p= localtime(&file_info->td_mtime))!=NULL)
+ {
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
+ }
}
mode_string(file_info->st_mode, str);
wprintw(window, "%s %5u %5u ",
diff --git a/src/common.c b/src/common.c
index 22e8511..2aeeba4 100644
--- a/src/common.c
+++ b/src/common.c
@@ -52,6 +52,7 @@ static int32_t secwest=0;
static unsigned int up2power_aux(const unsigned int number);
+/* coverity[+alloc] */
void *MALLOC(size_t size)
{
void *res;
@@ -244,7 +245,10 @@ void set_secwest(void)
const time_t t = time(NULL);
const struct tm *tmptr = localtime(&t);
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
- secwest = -1 * tmptr->tm_gmtoff;
+ if(tmptr)
+ secwest = -1 * tmptr->tm_gmtoff;
+ else
+ secwest = 0;
#elif defined (DJGPP) || defined(__ANDROID__)
secwest = 0;
#else
@@ -254,7 +258,7 @@ void set_secwest(void)
secwest = timezone;
#endif
/* account for daylight savings */
- if (tmptr->tm_isdst)
+ if (tmptr && tmptr->tm_isdst)
secwest -= 3600;
#endif
}
diff --git a/src/dir.c b/src/dir.c
index 7f3ba71..587ff52 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -162,20 +162,22 @@ int dir_aff_log(const dir_data_t *dir_data, const file_info_t *dir_list)
const file_info_t *current_file=td_list_entry(file_walker, file_info_t, list);
char datestr[80];
char str[11];
- if(current_file->td_mtime)
{
- const struct tm *tm_p = localtime(&current_file->td_mtime);
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- /* FIXME: a check using current_file->name will be better */
- if(1900+tm_p->tm_year>=2000 && 1900+tm_p->tm_year<=2014)
+ const struct tm *tm_p;
+ if(current_file->td_mtime && (tm_p = localtime(&current_file->td_mtime))!=NULL)
{
- test_date=1;
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ /* FIXME: a check using current_file->name will be better */
+ if(1900+tm_p->tm_year>=2000 && 1900+tm_p->tm_year<=2014)
+ {
+ test_date=1;
+ }
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
}
- } else {
- strncpy(datestr, " ",sizeof(datestr));
}
mode_string(current_file->st_mode, str);
if((current_file->status&FILE_STATUS_DELETED)!=0)
@@ -219,21 +221,22 @@ int log_list_file(const disk_t *disk, const partition_t *partition, const dir_da
log_info("X");
else
log_info(" ");
- if(current_file->td_mtime)
{
- const struct tm *tm_p = localtime(&current_file->td_mtime);
-
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- /* FIXME: a check using current_file->name will be better */
- if(1900+tm_p->tm_year>=2000 && 1900+tm_p->tm_year<=2012)
+ const struct tm *tm_p;
+ if(current_file->td_mtime && (tm_p = localtime(&current_file->td_mtime))!=NULL)
{
- test_date=1;
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ /* FIXME: a check using current_file->name will be better */
+ if(1900+tm_p->tm_year>=2000 && 1900+tm_p->tm_year<=2014)
+ {
+ test_date=1;
+ }
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
}
- } else {
- strncpy(datestr, " ",sizeof(datestr));
}
mode_string(current_file->st_mode, str);
log_info("%7lu ",(unsigned long int)current_file->st_ino);
diff --git a/src/dirn.c b/src/dirn.c
index 5397d33..2ba20b9 100644
--- a/src/dirn.c
+++ b/src/dirn.c
@@ -141,16 +141,18 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
wbkgdset(window,' ' | COLOR_PAIR(1));
else if((current_file->status&FILE_STATUS_MARKED)!=0 && has_colors())
wbkgdset(window,' ' | COLOR_PAIR(2));
- if(current_file->td_mtime!=0)
{
- const struct tm *tm_p = localtime(&current_file->td_mtime);
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- /* May have to use %d instead of %e */
- } else {
- strncpy(datestr, " ",sizeof(datestr));
+ const struct tm *tm_p;
+ if(current_file->td_mtime!=0 && (tm_p = localtime(&current_file->td_mtime))!=NULL)
+ {
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ /* May have to use %d instead of %e */
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
+ }
}
mode_string(current_file->st_mode, str);
wprintw(window, "%s %5u %5u ",
diff --git a/src/ntfs_udl.c b/src/ntfs_udl.c
index 375f5dc..6c80183 100644
--- a/src/ntfs_udl.c
+++ b/src/ntfs_udl.c
@@ -1262,16 +1262,18 @@ static void ntfs_undelete_menu_ncurses(disk_t *disk_car, const partition_t *part
waddstr(window, " ");
if((file_info->status&FILE_STATUS_MARKED)!=0 && has_colors())
wbkgdset(window,' ' | COLOR_PAIR(2));
- if(file_info->td_mtime!=0)
{
- const struct tm *tm_p= localtime(&file_info->td_mtime);
- snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
- tm_p->tm_mday, monstr[tm_p->tm_mon],
- 1900 + tm_p->tm_year, tm_p->tm_hour,
- tm_p->tm_min);
- /* May have to use %d instead of %e */
- } else {
- strncpy(datestr, " ",sizeof(datestr));
+ const struct tm *tm_p;
+ if(file_info->td_mtime!=0 && (tm_p=localtime(&file_info->td_mtime))!=NULL)
+ {
+ snprintf(datestr, sizeof(datestr),"%2d-%s-%4d %02d:%02d",
+ tm_p->tm_mday, monstr[tm_p->tm_mon],
+ 1900 + tm_p->tm_year, tm_p->tm_hour,
+ tm_p->tm_min);
+ /* May have to use %d instead of %e */
+ } else {
+ strncpy(datestr, " ",sizeof(datestr));
+ }
}
if(COLS <= 1+17+1+9+1)
wprintw(window, "%s", file_info->name);
diff --git a/src/psearchn.c b/src/psearchn.c
index 581c1a8..5a4721f 100644
--- a/src/psearchn.c
+++ b/src/psearchn.c
@@ -406,10 +406,7 @@ pstatus_t photorec_aux(struct ph_param *params, const struct ph_options *options
#ifdef HAVE_NCURSES
ind_stop=photorec_progressbar(stdscr, params->pass, params, offset, current_time);
#endif
- if(file_recovery.file_stat!=NULL)
- params->offset=file_recovery.location.start;
- else
- params->offset=offset;
+ params->offset=offset;
if(current_time >= next_checkpoint)
{
/* Save current progress */