diff options
author | Christophe Grenier <[email protected]> | 2016-06-14 19:04:44 +0200 |
---|---|---|
committer | Christophe Grenier <[email protected]> | 2016-06-14 19:04:44 +0200 |
commit | 2d2292caede8d4bebb7968fb8fb181df55f07aaf (patch) | |
tree | 3209453ed22d607e4c6f2f3cffb1a789ce6272cc | |
parent | d576a81e1f0481cef490974509273e54dd572372 (diff) |
Fix for various cppcheck warnings
-rw-r--r-- | src/ext2_sbn.c | 2 | ||||
-rw-r--r-- | src/fat_dir.c | 2 | ||||
-rw-r--r-- | src/file_hdf.c | 8 | ||||
-rw-r--r-- | src/log.c | 2 | ||||
-rw-r--r-- | src/phbf.c | 2 | ||||
-rw-r--r-- | src/phmain.c | 1 | ||||
-rw-r--r-- | src/testdisk.c | 6 |
7 files changed, 14 insertions, 9 deletions
diff --git a/src/ext2_sbn.c b/src/ext2_sbn.c index 7c7a1780..ac276b7b 100644 --- a/src/ext2_sbn.c +++ b/src/ext2_sbn.c @@ -144,7 +144,7 @@ list_part_t *search_superblock(disk_t *disk_car, partition_t *partition, const i log_info("Ext2 superblock found at sector %llu (block=%llu, blocksize=%u)\n", (long long unsigned) hd_offset/DEFAULT_SECTOR_SIZE, (long long unsigned) hd_offset>>(EXT2_MIN_BLOCK_LOG_SIZE+le32(sb->s_log_block_size)), - EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); + (unsigned int)EXT2_MIN_BLOCK_SIZE<<le32(sb->s_log_block_size)); #ifdef HAVE_NCURSES wmove(stdscr,10+nbr_sb,0); wprintw(stdscr,"Ext2 superblock found at sector %llu (block=%llu, blocksize=%u) \n", diff --git a/src/fat_dir.c b/src/fat_dir.c index 4423a0aa..fbe1095d 100644 --- a/src/fat_dir.c +++ b/src/fat_dir.c @@ -261,7 +261,7 @@ RecEnd: unsigned int i,o; file_info_t *new_file=(file_info_t *)MALLOC(sizeof(*new_file)); new_file->name=(char*)MALLOC(DIR_NAME_LEN); - for(i=0,o=0; unicode[i]!=0 && o<DIR_NAME_LEN-1; i++) + for(i=0,o=0; o<DIR_NAME_LEN-2 && unicode[i]!=0; i++) { if(utf8 && unicode[i]>0x7f) { diff --git a/src/file_hdf.c b/src/file_hdf.c index 0eec179e..53b02609 100644 --- a/src/file_hdf.c +++ b/src/file_hdf.c @@ -83,12 +83,12 @@ static void file_check_hdf(file_recovery_t *file_recovery) file_recovery->file_size=0; return ; } - if(file_size < offset + sizeof(struct dd_struct) * be16(ddh.size)) - file_size = offset + sizeof(struct dd_struct) * be16(ddh.size); + size=be16(ddh.size); + if(file_size < offset + sizeof(struct dd_struct) * size) + file_size = offset + sizeof(struct dd_struct) * size; #ifdef DEBUG_HDF - log_info("size=%u next=%lu\n", be16(ddh.size), be32(ddh.next)); + log_info("size=%u next=%lu\n", size, be32(ddh.next)); #endif - size=be16(ddh.size); for(i=0, p=dd; i < size; i++,p++) { #ifdef DEBUG_HDF @@ -118,7 +118,7 @@ FILE *log_open_default(const char*default_filename, const int mode, int *errsv) strcpy(filename, path); strcat(filename, "/"); strcat(filename, default_filename); - log_open(default_filename, mode, errsv); + log_open(filename, mode, errsv); free(filename); return log_handle; } @@ -449,7 +449,7 @@ static bf_status_t photorec_bf_frag_fast(struct ph_param *params, file_recovery_ const uint64_t original_offset_ok=file_recovery->offset_ok; const unsigned int blocs_to_skip=file_recovery->extra / blocksize; unsigned int i; - log_info("photorec_bf_frag_fast %s, original_offset_ok=%llu, original_offset_error=%llu, blocs_to_skip=%d, extra=%llu\n", + log_info("photorec_bf_frag_fast %s, original_offset_ok=%llu, original_offset_error=%llu, blocs_to_skip=%u, extra=%llu\n", file_recovery->filename, (long long unsigned)original_offset_ok, (long long unsigned)original_offset_error, diff --git a/src/phmain.c b/src/phmain.c index a6344902..a21b1351 100644 --- a/src/phmain.c +++ b/src/phmain.c @@ -288,6 +288,7 @@ int main( int argc, char **argv ) if(start_ncurses("PhotoRec", argv[0])) { free(params.recup_dir); + log_close(); return 1; } { diff --git a/src/testdisk.c b/src/testdisk.c index 21c67f86..3b901556 100644 --- a/src/testdisk.c +++ b/src/testdisk.c @@ -203,7 +203,9 @@ static int display_disk_list(list_disk_t *list_disk, const int testdisk_mode, int main( int argc, char **argv ) { int i; +#ifdef SUDO_BIN int use_sudo=0; +#endif int verbose=0, dump_ind=0; int create_log=TD_LOG_NONE; int do_list=0; @@ -455,9 +457,11 @@ int main( int argc, char **argv ) #endif #endif } -#endif if(use_sudo==0) use_sudo=do_curses_testdisk(verbose,dump_ind,list_disk,saveheader,cmd_device,&cmd_run); +#else + do_curses_testdisk(verbose,dump_ind,list_disk,saveheader,cmd_device,&cmd_run); +#endif #ifdef HAVE_NCURSES end_ncurses(); #endif |