summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-05-26 09:21:30 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-05-26 09:21:30 +0200
commit8ab840414394e1e8454413485c578d75fd8ab68f (patch)
tree4d7cb333d48e5cd71bdcde328db0bff816d8f988
parent7ff26a5fcd838b0ac9d6a3a4e82f802d0b752d81 (diff)
Constify some variables
-rw-r--r--src/adv.c3
-rw-r--r--src/askloc.c3
-rw-r--r--src/chgarchn.c2
-rw-r--r--src/chgtypen.c2
-rw-r--r--src/common.c7
-rw-r--r--src/dfxml.c6
-rw-r--r--src/dimage.c3
-rw-r--r--src/dir.c11
-rw-r--r--src/dirn.c7
-rw-r--r--src/exfatp.c5
-rw-r--r--src/ext2_dir.c11
-rw-r--r--src/ext2_sbn.c3
-rw-r--r--src/fat.c3
-rw-r--r--src/fat_adv.c9
-rw-r--r--src/file_ab.c4
-rw-r--r--src/file_bld.c20
-rw-r--r--src/file_caf.c2
-rw-r--r--src/file_doc.c14
-rw-r--r--src/file_emf.c12
-rw-r--r--src/file_evt.c4
-rw-r--r--src/file_exe.c3
-rw-r--r--src/godmode.c10
22 files changed, 58 insertions, 86 deletions
diff --git a/src/adv.c b/src/adv.c
index 348d003..c2cbfea 100644
--- a/src/adv.c
+++ b/src/adv.c
@@ -355,8 +355,7 @@ void interface_adv(disk_t *disk_car, const int verbose,const int dump_ind, const
}
else if(isdigit(*current_cmd[0]))
{
- unsigned int order;
- order= atoi(*current_cmd);
+ const unsigned int order= atoi(*current_cmd);
while(*current_cmd[0]!=',' && *current_cmd[0]!='\0')
(*current_cmd)++;
for(element=list_part;element!=NULL && element->part->order!=order;element=element->next);
diff --git a/src/askloc.c b/src/askloc.c
index 6e24dd3..43b4880 100644
--- a/src/askloc.c
+++ b/src/askloc.c
@@ -217,8 +217,7 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
while(1)
{
char current_file[4096];
- struct dirent *dir_entrie;
- dir_entrie=readdir(dir);
+ const struct dirent *dir_entrie=readdir(dir);
if(dir_entrie==NULL)
break;
/* hide filename beginning by '.' except '.' and '..' */
diff --git a/src/chgarchn.c b/src/chgarchn.c
index 7ffa5ca..1d786c3 100644
--- a/src/chgarchn.c
+++ b/src/chgarchn.c
@@ -63,7 +63,7 @@ int change_arch_type_ncurses(disk_t *disk, const int verbose)
{
int car;
int real_key;
- struct MenuItem menuOptions[]=
+ const struct MenuItem menuOptions[]=
{
{ 'I', arch_i386.part_name, "Intel/PC partition" },
{ 'G', arch_gpt.part_name, "EFI GPT partition map (Mac i386, some x86_64...)" },
diff --git a/src/chgtypen.c b/src/chgtypen.c
index daf748b..4689f3b 100644
--- a/src/chgtypen.c
+++ b/src/chgtypen.c
@@ -112,7 +112,7 @@ static void change_part_type_int_ncurses(const disk_t *disk_car, partition_t *pa
wclrtoeol(stdscr);
wprintw(stdscr,"New partition type [current %02x] ? ",partition->arch->get_part_type(partition));
if (get_string(stdscr, response, sizeof(response), NULL) > 0) {
- int tmp_val = strtol(response, NULL, 16);
+ const int tmp_val = strtol(response, NULL, 16);
partition->arch->set_part_type(partition,tmp_val);
}
}
diff --git a/src/common.c b/src/common.c
index 3e008f1..f013d51 100644
--- a/src/common.c
+++ b/src/common.c
@@ -241,11 +241,8 @@ int date_dos2unix(const unsigned short f_time, const unsigned short f_date)
void set_secwest(void)
{
- struct tm *tmptr;
- time_t t;
-
- t = time(NULL);
- tmptr = localtime(&t);
+ const time_t t = time(NULL);
+ const struct tm *tmptr = localtime(&t);
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
secwest = -1 * tmptr->tm_gmtoff;
#elif defined (DJGPP) || defined(__ANDROID__)
diff --git a/src/dfxml.c b/src/dfxml.c
index d6ee137..f04e6cd 100644
--- a/src/dfxml.c
+++ b/src/dfxml.c
@@ -237,10 +237,8 @@ void xml_add_DFXML_creator(const char *package, const char *version)
#endif
{
char outstr[200];
- time_t t;
- struct tm *tmp;
- t = time(NULL);
- tmp = localtime(&t);
+ const time_t t = time(NULL);
+ const struct tm *tmp = localtime(&t);
if (tmp != NULL &&
strftime(outstr, sizeof(outstr), "%Y-%m-%dT%H:%M:%S%z", tmp) != 0)
{
diff --git a/src/dimage.c b/src/dimage.c
index 00b2796..6299a4d 100644
--- a/src/dimage.c
+++ b/src/dimage.c
@@ -63,8 +63,7 @@ static void disk_image_backward(int disk_dst, disk_t *disk, const uint64_t src_o
unsigned char *buffer=(unsigned char *)MALLOC(disk->sector_size);
for(src_offset=src_offset_end-disk->sector_size; src_offset > src_offset_start; src_offset-=disk->sector_size, dst_offset-=disk->sector_size)
{
- ssize_t pread_res;
- pread_res=disk->pread(disk, buffer, disk->sector_size, src_offset);
+ const ssize_t pread_res=disk->pread(disk, buffer, disk->sector_size, src_offset);
if((unsigned)pread_res != disk->sector_size)
{
free(buffer);
diff --git a/src/dir.c b/src/dir.c
index b07cee0..58ca672 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -164,8 +164,7 @@ int dir_aff_log(const dir_data_t *dir_data, const file_info_t *dir_list)
char str[11];
if(current_file->td_mtime)
{
- struct tm *tm_p;
- tm_p = localtime(&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,
@@ -213,18 +212,16 @@ int log_list_file(const disk_t *disk, const partition_t *partition, const dir_da
}
td_list_for_each(tmp, &list->list)
{
- file_info_t *current_file;
char datestr[80];
char str[11];
- current_file=td_list_entry(tmp, file_info_t, list);
+ const file_info_t *current_file=td_list_entry(tmp, file_info_t, list);
if((current_file->status&FILE_STATUS_DELETED)!=0)
log_info("X");
else
log_info(" ");
if(current_file->td_mtime)
{
- struct tm *tm_p;
- tm_p = localtime(&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],
@@ -578,7 +575,7 @@ static unsigned int filename_convert(char *dst, const char*src, const unsigned i
char *gen_local_filename(const char *filename)
{
- int l=strlen(filename);
+ const int l=strlen(filename);
char *dst=(char *)MALLOC(l+1);
filename_convert(dst, filename, l);
#if defined(DJGPP) || defined(__CYGWIN__) || defined(__MINGW32__)
diff --git a/src/dirn.c b/src/dirn.c
index 3b7229b..5397d33 100644
--- a/src/dirn.c
+++ b/src/dirn.c
@@ -143,8 +143,7 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
wbkgdset(window,' ' | COLOR_PAIR(2));
if(current_file->td_mtime!=0)
{
- struct tm *tm_p;
- tm_p = localtime(&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,
@@ -363,7 +362,7 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
file_info_t *tmp=td_list_entry(pos, file_info_t, list);
if(pos!=&dir_list->list && (LINUX_S_ISDIR(tmp->st_mode)!=0))
{
- unsigned long int new_inode=tmp->st_ino;
+ const unsigned long int new_inode=tmp->st_ino;
if((new_inode!=inode) &&(strcmp(tmp->name,".")!=0))
{
if(strcmp(tmp->name,"..")==0)
@@ -608,7 +607,7 @@ static void copy_dir(WINDOW *window, disk_t *disk, const partition_t *partition,
dir_data->get_dir(disk, partition, dir_data, (const unsigned long int)dir->st_ino, &dir_list);
td_list_for_each(file_walker, &dir_list.list)
{
- file_info_t *current_file;
+ const file_info_t *current_file;
current_file=td_list_entry(file_walker, file_info_t, list);
dir_data->current_directory[current_directory_namelength]='\0';
if(current_directory_namelength+1+strlen(current_file->name)<sizeof(dir_data->current_directory)-1)
diff --git a/src/exfatp.c b/src/exfatp.c
index d20fac7..da3eb21 100644
--- a/src/exfatp.c
+++ b/src/exfatp.c
@@ -48,7 +48,7 @@ static struct exfat_alloc_bitmap_entry *exfat_get_bitmap(unsigned char*buffer, c
unsigned int exfat_remove_used_space(disk_t *disk, const partition_t *partition, alloc_data_t *list_search_space)
{
struct exfat_super_block *exfat_header;
- struct exfat_alloc_bitmap_entry *bitmap;
+ const struct exfat_alloc_bitmap_entry *bitmap;
unsigned int cluster_shift;
/* Load boot sector */
exfat_header=(struct exfat_super_block *)MALLOC(0x200);
@@ -90,8 +90,7 @@ unsigned int exfat_remove_used_space(disk_t *disk, const partition_t *partition,
buffer=(unsigned char *)MALLOC(1<<cluster_shift);
for(i=2; i<le32(exfat_header->total_clusters)+2; i++)
{
- unsigned int offset_o;
- offset_o=(i-2)%(8<<cluster_shift);
+ const unsigned int offset_o=(i-2)%(8<<cluster_shift);
if(offset_o==0)
{
exfat_read_cluster(disk, partition, exfat_header, buffer, cluster_bitmap);
diff --git a/src/ext2_dir.c b/src/ext2_dir.c
index 9f48a2d..ee965e5 100644
--- a/src/ext2_dir.c
+++ b/src/ext2_dir.c
@@ -156,7 +156,7 @@ static errcode_t my_set_blksize(io_channel channel, int blksize)
static errcode_t my_read_blk(io_channel channel, unsigned long block, int count, void *buf)
{
ssize_t size;
- my_data_t *my_data=(my_data_t*)channel->private_data;
+ const my_data_t *my_data=(const my_data_t*)channel->private_data;
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
size = (count < 0) ? -count : count * channel->block_size;
@@ -178,7 +178,7 @@ static errcode_t my_write_blk(io_channel channel, unsigned long block, int count
EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
#if 1
{
- my_data_t *my_data=(my_data_t*)channel;
+ const my_data_t *my_data=(const my_data_t*)channel;
if(my_data->disk_car->pwrite(my_data->disk_car, buf, count * channel->block_size, my_data->partition->part_offset + (uint64_t)block * channel->block_size) != count * channel->block_size)
return 1;
return 0;
@@ -203,7 +203,7 @@ static int list_dir_proc2(ext2_ino_t dir,
{
struct ext2_inode inode;
ext2_ino_t ino;
- struct ext2_dir_struct *ls = (struct ext2_dir_struct *) privateinfo;
+ const struct ext2_dir_struct *ls = (const struct ext2_dir_struct *) privateinfo;
file_info_t *new_file;
if(entry==DIRENT_DELETED_FILE && (ls->dir_data->param & FLAG_LIST_DELETED)==0)
return 0;
@@ -221,8 +221,7 @@ static int list_dir_proc2(ext2_ino_t dir,
}
new_file=(file_info_t *)MALLOC(sizeof(*new_file));
{
- unsigned int thislen;
- thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
+ const unsigned int thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
(dirent->name_len & 0xFF) : EXT2_NAME_LEN;
new_file->name=(char *)MALLOC(thislen+1);
memcpy(new_file->name, dirent->name, thislen);
@@ -273,7 +272,7 @@ static int ext2_copy(disk_t *disk_car, const partition_t *partition, dir_data_t
{
int error=0;
FILE *f_out;
- struct ext2_dir_struct *ls = (struct ext2_dir_struct *)dir_data->private_dir_data;
+ const struct ext2_dir_struct *ls = (const struct ext2_dir_struct *)dir_data->private_dir_data;
char *new_file;
f_out=fopen_local(&new_file, dir_data->local_dir, dir_data->current_directory);
if(!f_out)
diff --git a/src/ext2_sbn.c b/src/ext2_sbn.c
index 87344b1..14ec0ae 100644
--- a/src/ext2_sbn.c
+++ b/src/ext2_sbn.c
@@ -101,8 +101,7 @@ list_part_t *search_superblock(disk_t *disk_car, partition_t *partition, const i
for(hd_offset=0;hd_offset<partition->part_size && nbr_sb<10 && ind_stop==0;hd_offset=next_sb(hd_offset))
{
#ifdef HAVE_NCURSES
- unsigned long int percent;
- percent=hd_offset*100/partition->part_size;
+ const unsigned long int percent=hd_offset*100/partition->part_size;
if(interface>0 && percent!=old_percent)
{
wmove(stdscr,9,0);
diff --git a/src/fat.c b/src/fat.c
index ca9766c..477e094 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -392,8 +392,7 @@ unsigned int fat32_get_prev_cluster(disk_t *disk_car,const partition_t *partitio
for(prev_cluster=2;prev_cluster<=no_of_cluster+1;prev_cluster++)
{
- unsigned int offset_o;
- offset_o=prev_cluster%(disk_car->sector_size/4);
+ const unsigned int offset_o=prev_cluster%(disk_car->sector_size/4);
if((offset_o==0)||(prev_cluster==2))
{
if((unsigned)disk_car->pread(disk_car, buffer, disk_car->sector_size, hd_offset) != disk_car->sector_size)
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 74f3f2c..069ba32 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -1086,13 +1086,13 @@ static void create_fat_boot_sector(disk_t *disk_car, partition_t *partition, con
{
unsigned char *orgboot;
unsigned char *newboot;
- struct fat_boot_sector *org_fat_header;
+ const struct fat_boot_sector *org_fat_header;
struct fat_boot_sector *fat_header;
int error=0;
unsigned long int part_size=0;
orgboot=(unsigned char *)MALLOC(3*disk_car->sector_size);
newboot=(unsigned char *)MALLOC(3*disk_car->sector_size);
- org_fat_header=(struct fat_boot_sector *)orgboot;
+ org_fat_header=(const struct fat_boot_sector *)orgboot;
fat_header=(struct fat_boot_sector *)newboot;
if((unsigned)disk_car->pread(disk_car, orgboot, 3 * disk_car->sector_size, partition->part_offset) != 3 * disk_car->sector_size)
{
@@ -1606,7 +1606,7 @@ static int fat_find_type(disk_t *disk_car,const partition_t *partition,const uin
offset+=disk_car->sector_size)
{
#ifdef HAVE_NCURSES
- unsigned long int percent=offset*100/max_offset;
+ const unsigned long int percent=offset*100/max_offset;
if(interface && (percent!=old_percent))
{
wmove(stdscr,8,30);
@@ -1620,8 +1620,7 @@ static int fat_find_type(disk_t *disk_car,const partition_t *partition,const uin
if((unsigned)disk_car->pread(disk_car, buffer, disk_car->sector_size, partition->part_offset + offset) == disk_car->sector_size)
{
unsigned long int fat_offset=0;
- unsigned int fat_type;
- fat_type=fat_find_fat_start(buffer,p_fat12,p_fat16,p_fat32,&fat_offset,disk_car->sector_size);
+ const unsigned int fat_type=fat_find_fat_start(buffer,p_fat12,p_fat16,p_fat32,&fat_offset,disk_car->sector_size);
if(fat_type!=0 && fat_offset<=(offset/disk_car->sector_size))
{
unsigned int j;
diff --git a/src/file_ab.c b/src/file_ab.c
index e49f752..e0816ce 100644
--- a/src/file_ab.c
+++ b/src/file_ab.c
@@ -68,7 +68,7 @@ static int data_check_addressbook(const unsigned char *buffer, const unsigned in
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
file_recovery->calculated_file_size + 8 < file_recovery->file_size + buffer_size/2)
{
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
#ifdef DEBUG_AB
log_debug("data_check_addressbook i=0x%x buffer_size=0x%x calculated_file_size=%lu file_size=%lu\n",
i, buffer_size,
@@ -78,7 +78,7 @@ static int data_check_addressbook(const unsigned char *buffer, const unsigned in
#endif
if(buffer[i+0]=='L' && buffer[i+1]=='J' && buffer[i+3]==0x00)
{
- unsigned int length=(buffer[i+4]<<24)+(buffer[i+5]<<16)+(buffer[i+6]<<8)+buffer[i+7];
+ const unsigned int length=(buffer[i+4]<<24)+(buffer[i+5]<<16)+(buffer[i+6]<<8)+buffer[i+7];
if(length<8)
{
return 2;
diff --git a/src/file_bld.c b/src/file_bld.c
index ce3b8a8..5fdb2ad 100644
--- a/src/file_bld.c
+++ b/src/file_bld.c
@@ -88,9 +88,8 @@ static int data_check_blend4le(const unsigned char *buffer, const unsigned int b
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
file_recovery->calculated_file_size + 0x14 < file_recovery->file_size + buffer_size/2)
{
- unsigned int len;
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- len=buffer[i+4]+ ((buffer[i+5])<<8)+ ((buffer[i+6])<<16)+ ((buffer[i+7])<<24);
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int len=buffer[i+4]+ ((buffer[i+5])<<8)+ ((buffer[i+6])<<16)+ ((buffer[i+7])<<24);
#ifdef DEBUG_BLEND
log_debug("file_mov.c: atom %c%c%c%c (0x%02x%02x%02x%02x) size %u, calculated_file_size %llu\n",
buffer[i+0],buffer[i+1],buffer[i+2],buffer[i+3],
@@ -112,9 +111,8 @@ static int data_check_blend8le(const unsigned char *buffer, const unsigned int b
{
while(file_recovery->calculated_file_size + 0x18 < file_recovery->file_size + buffer_size/2)
{
- unsigned int len;
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- len=buffer[i+4]+ ((buffer[i+5])<<8)+ ((buffer[i+6])<<16)+ ((buffer[i+7])<<24);
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int len=buffer[i+4]+ ((buffer[i+5])<<8)+ ((buffer[i+6])<<16)+ ((buffer[i+7])<<24);
#ifdef DEBUG_BLEND
log_debug("file_mov.c: atom %c%c%c%c (0x%02x%02x%02x%02x) size %u, calculated_file_size %llu\n",
buffer[i+0],buffer[i+1],buffer[i+2],buffer[i+3],
@@ -136,9 +134,8 @@ static int data_check_blend4be(const unsigned char *buffer, const unsigned int b
{
while(file_recovery->calculated_file_size + 0x14 < file_recovery->file_size + buffer_size/2)
{
- unsigned int len;
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- len=(buffer[i+4]<<24)+ ((buffer[i+5])<<16)+ ((buffer[i+6])<<8)+ buffer[i+7];
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int len=(buffer[i+4]<<24)+ ((buffer[i+5])<<16)+ ((buffer[i+6])<<8)+ buffer[i+7];
#ifdef DEBUG_BLEND
log_debug("file_mov.c: atom %c%c%c%c (0x%02x%02x%02x%02x) size %u, calculated_file_size %llu\n",
buffer[i+0],buffer[i+1],buffer[i+2],buffer[i+3],
@@ -160,9 +157,8 @@ static int data_check_blend8be(const unsigned char *buffer, const unsigned int b
{
while(file_recovery->calculated_file_size + 0x18 < file_recovery->file_size + buffer_size/2)
{
- unsigned int len;
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- len=(buffer[i+4]<<24)+ ((buffer[i+5])<<16)+ ((buffer[i+6])<<8)+ buffer[i+7];
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int len=(buffer[i+4]<<24)+ ((buffer[i+5])<<16)+ ((buffer[i+6])<<8)+ buffer[i+7];
#ifdef DEBUG_BLEND
log_debug("file_mov.c: atom %c%c%c%c (0x%02x%02x%02x%02x) size %u, calculated_file_size %llu\n",
buffer[i+0],buffer[i+1],buffer[i+2],buffer[i+3],
diff --git a/src/file_caf.c b/src/file_caf.c
index 27e47c8..3d64a05 100644
--- a/src/file_caf.c
+++ b/src/file_caf.c
@@ -67,7 +67,7 @@ static int data_check_caf(const unsigned char *buffer, const unsigned int buffer
{
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
const struct chunk_struct *chunk=(const struct chunk_struct*)&buffer[i];
- int64_t chunk_size=be64(chunk->size);
+ const int64_t chunk_size=be64(chunk->size);
#ifdef DEBUG_CAF
log_trace("file_caf.c: %s chunk %c%c%c%c (0x%02x%02x%02x%02x) size %llu, calculated_file_size %llu (0x%llx)\n",
file_recovery->filename,
diff --git a/src/file_doc.c b/src/file_doc.c
index c8654e1..2fe49c6 100644
--- a/src/file_doc.c
+++ b/src/file_doc.c
@@ -80,7 +80,7 @@ static void file_check_doc(file_recovery_t *file_recovery)
uint32_t *fat;
unsigned long int i;
unsigned int freesect_count=0;
- struct OLE_HDR *header=(struct OLE_HDR*)&buffer_header;
+ const struct OLE_HDR *header=(const struct OLE_HDR*)&buffer_header;
const uint64_t doc_file_size_org=file_recovery->file_size;
file_recovery->file_size=0;
/*reads first sector including OLE header */
@@ -674,10 +674,10 @@ static void OLE_parse_summary_aux(const unsigned char *dataPt, const unsigned in
return ;
for(i=0; i<numEntries; i++)
{
- unsigned int entry = pos + 8 + 8 * i;
- unsigned int tag=get32u(dataPt, entry);
- unsigned int offset=get32u(dataPt, entry + 4);
- unsigned int valStart = pos + 4 + offset;
+ const unsigned int entry = pos + 8 + 8 * i;
+ const unsigned int tag=get32u(dataPt, entry);
+ const unsigned int offset=get32u(dataPt, entry + 4);
+ const unsigned int valStart = pos + 4 + offset;
unsigned int type;
if(valStart >= dirLen)
return ;
@@ -821,7 +821,7 @@ static void file_rename_doc(const char *old_filename)
FILE *file;
unsigned char buffer_header[512];
uint32_t *fat;
- struct OLE_HDR *header=(struct OLE_HDR*)&buffer_header;
+ const struct OLE_HDR *header=(const struct OLE_HDR*)&buffer_header;
time_t file_time=0;
unsigned int fat_entries;
if(strstr(old_filename, ".sdd")!=NULL)
@@ -898,7 +898,7 @@ static void file_rename_doc(const char *old_filename)
#endif
{
unsigned int sid;
- struct OLE_DIR *dir_entry=dir_entries;
+ const struct OLE_DIR *dir_entry=dir_entries;
if(i==0)
{
ministream_block=le32(dir_entry->start_block);
diff --git a/src/file_emf.c b/src/file_emf.c
index 99ccab0..38ab0a6 100644
--- a/src/file_emf.c
+++ b/src/file_emf.c
@@ -219,8 +219,7 @@ static int header_check_emf(const unsigned char *buffer, const unsigned int buff
le32(hdr->nBytes) >= 88 &&
le16(hdr->sReserved)==0)
{
- unsigned int atom_size;
- atom_size=buffer[4]+(buffer[5]<<8)+(buffer[6]<<16)+(buffer[7]<<24);
+ const unsigned int atom_size=buffer[4]+(buffer[5]<<8)+(buffer[6]<<16)+(buffer[7]<<24);
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_emf.extension;
file_recovery_new->data_check=data_check_emf;
@@ -236,12 +235,9 @@ static int data_check_emf(const unsigned char *buffer, const unsigned int buffer
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
file_recovery->calculated_file_size + 8 < file_recovery->file_size + buffer_size/2)
{
- unsigned int atom_size;
- unsigned int itype;
- unsigned int i;
- i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- itype=buffer[i]+(buffer[i+1]<<8)+(buffer[i+2]<<16)+(buffer[i+3]<<24);
- atom_size=buffer[i+4]+(buffer[i+5]<<8)+(buffer[i+6]<<16)+(buffer[i+7]<<24);
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int itype=buffer[i]+(buffer[i+1]<<8)+(buffer[i+2]<<16)+(buffer[i+3]<<24);
+ const unsigned int atom_size=buffer[i+4]+(buffer[i+5]<<8)+(buffer[i+6]<<16)+(buffer[i+7]<<24);
#ifdef DEBUG_EMF
log_trace("0x%llx ", (long long unsigned)file_recovery->calculated_file_size);
switch(itype)
diff --git a/src/file_evt.c b/src/file_evt.c
index 9dbab1f..82f6f41 100644
--- a/src/file_evt.c
+++ b/src/file_evt.c
@@ -72,14 +72,14 @@ static int data_check_evt(const unsigned char *buffer, const unsigned int buffer
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
file_recovery->calculated_file_size + 8 < file_recovery->file_size + buffer_size/2)
{
- unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
+ const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
if((buffer[i+4]=='L' && buffer[i+5]=='f' && buffer[i+6]=='L' && buffer[i+7]=='e') ||
(buffer[i+4]==0x11 && buffer[i+5]==0x11 && buffer[i+6]==0x11 && buffer[i+7]==0x11) ||
(buffer[i+4]==0x22 && buffer[i+5]==0x22 && buffer[i+6]==0x22 && buffer[i+7]==0x22) ||
(buffer[i+4]==0x33 && buffer[i+5]==0x33 && buffer[i+6]==0x33 && buffer[i+7]==0x33) ||
(buffer[i+4]==0x44 && buffer[i+5]==0x44 && buffer[i+6]==0x44 && buffer[i+7]==0x44))
{
- unsigned int length=(buffer[i+0] + (buffer[i+1]<<8) + (buffer[i+2]<<16) + (buffer[i+3]<<24));
+ const unsigned int length=(buffer[i+0] + (buffer[i+1]<<8) + (buffer[i+2]<<16) + (buffer[i+3]<<24));
if(length<8)
{
return 2;
diff --git a/src/file_exe.c b/src/file_exe.c
index fb8ec5c..e48abca 100644
--- a/src/file_exe.c
+++ b/src/file_exe.c
@@ -253,10 +253,9 @@ static unsigned int ReadUnicodeStr(const char *buffer, unsigned int pos, const u
return pos;
}
-static int PEVersion_aux(const char*buffer, const unsigned int length, const char *old_filename, const char *needle, const unsigned int needle_len, const int force_ext)
+static int PEVersion_aux(const char*buffer, const unsigned int end, const char *old_filename, const char *needle, const unsigned int needle_len, const int force_ext)
{
unsigned int pos=0;
- unsigned int end=length;
while(1)
{
const struct PE_index *PE_index;
diff --git a/src/godmode.c b/src/godmode.c
index 889a041..f7832ef 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -813,8 +813,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
partition->part_size>1 &&
partition->part_offset>=min_location)
{
- uint64_t pos_fin;
- pos_fin=partition->part_offset+partition->part_size-1;
+ const uint64_t pos_fin=partition->part_offset+partition->part_size-1;
if(partition->upart_type!=UP_MD && partition->upart_type!=UP_MD1 &&
ind_stop==INDSTOP_CONTINUE)
{ /* Detect Linux md 0.9 software raid */
@@ -843,8 +842,8 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
free(new_partition);
}
{
- uint64_t next_part_offset=partition->part_offset+partition->part_size-1+1;
- uint64_t head_size=disk_car->geom.sectors_per_head * disk_car->sector_size;
+ const uint64_t next_part_offset=partition->part_offset+partition->part_size-1+1;
+ const uint64_t head_size=disk_car->geom.sectors_per_head * disk_car->sector_size;
hint_insert(try_offset, next_part_offset, &try_offset_nbr);
hint_insert(try_offset, next_part_offset+head_size, &try_offset_nbr);
if(next_part_offset%head_size!=0)
@@ -1305,8 +1304,7 @@ int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, cons
list_part=search_part(disk_car, list_part_org, verbose, dump_ind, fast_mode, current_cmd);
if(list_part!=NULL && (disk_car->arch==&arch_i386 || disk_car->arch==&arch_sun))
{ /* Correct disk geometry is necessary for successfull Intel and Sun partition recovery */
- unsigned int heads_per_cylinder;
- heads_per_cylinder=get_geometry_from_list_part(disk_car, list_part, verbose);
+ const unsigned int heads_per_cylinder=get_geometry_from_list_part(disk_car, list_part, verbose);
if(disk_car->geom.heads_per_cylinder!=heads_per_cylinder)
{
log_warning("Warning: the current number of heads per cylinder is %u but the correct value may be %u.\n",