summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-06-01 18:06:35 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-06-01 18:06:35 +0200
commit65dbe3d4baf4d486bb8119ec197a20697ba4ca28 (patch)
tree1ed5c06affe799b8c4d8efd188a5b4197c6b9dcf /src
parent8ab840414394e1e8454413485c578d75fd8ab68f (diff)
constify more variables
Diffstat (limited to 'src')
-rw-r--r--src/analyse.c6
-rw-r--r--src/chgtypen.c2
-rw-r--r--src/edit.c2
-rw-r--r--src/ext2_sb.c2
-rw-r--r--src/fat1x.c2
-rw-r--r--src/fat32.c2
-rw-r--r--src/fat_adv.c4
-rw-r--r--src/file_fits.c2
-rw-r--r--src/file_gz.c8
-rw-r--r--src/file_jpg.c8
-rw-r--r--src/file_m2ts.c4
-rw-r--r--src/file_mp3.c14
-rw-r--r--src/file_ogg.c6
-rw-r--r--src/file_pdf.c4
-rw-r--r--src/file_png.c4
-rw-r--r--src/file_psp.c5
-rw-r--r--src/file_riff.c4
-rw-r--r--src/file_sig.c3
-rw-r--r--src/file_spf.c3
-rw-r--r--src/file_swf.c2
-rw-r--r--src/file_txt.c6
-rw-r--r--src/file_zip.c6
-rw-r--r--src/intrface.c6
-rw-r--r--src/intrfn.c38
-rw-r--r--src/photorec.c3
-rw-r--r--src/sun.c2
-rw-r--r--src/tanalyse.c2
-rw-r--r--src/texfat.c2
-rw-r--r--src/thfs.c2
-rw-r--r--src/tload.c2
-rw-r--r--src/tlog.c5
-rw-r--r--src/tntfs.c2
-rw-r--r--src/tpartwr.c2
-rw-r--r--src/ufs.c2
34 files changed, 76 insertions, 91 deletions
diff --git a/src/analyse.c b/src/analyse.c
index 458e595..99d47aa 100644
--- a/src/analyse.c
+++ b/src/analyse.c
@@ -66,7 +66,7 @@ int search_NTFS_backup(unsigned char *buffer, disk_t *disk, partition_t *partiti
if(disk->pread(disk, buffer, DEFAULT_SECTOR_SIZE, partition->part_offset) != DEFAULT_SECTOR_SIZE)
return -1;
{
- const struct ntfs_boot_sector*ntfs_header=(const struct ntfs_boot_sector*)buffer;
+ const struct ntfs_boot_sector *ntfs_header=(const struct ntfs_boot_sector*)buffer;
/* NTFS recovery using backup sector */
if(le16(ntfs_header->marker)==0xAA55 &&
recover_NTFS(disk, ntfs_header, partition, verbose, dump_ind, 1)==0)
@@ -141,7 +141,7 @@ int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partit
const struct fat_boot_sector *fat_header=(const struct fat_boot_sector *)buffer;
const struct luks_phdr *luks=(const struct luks_phdr *)buffer;
const struct mdp_superblock_1 *sb1=(const struct mdp_superblock_1 *)buffer;
- const struct ntfs_boot_sector*ntfs_header=(const struct ntfs_boot_sector*)buffer;
+ const struct ntfs_boot_sector *ntfs_header=(const struct ntfs_boot_sector*)buffer;
const struct wbfs_head *wbfs=(const struct wbfs_head *)buffer;
const struct xfs_sb *xfs=(const struct xfs_sb *)buffer;
const union swap_header *swap_header=(const union swap_header *)buffer;
@@ -216,7 +216,7 @@ int search_type_0(const unsigned char *buffer, disk_t *disk, partition_t *partit
int search_type_1(const unsigned char *buffer, disk_t *disk, partition_t *partition, const int verbose, const int dump_ind)
{
const struct disklabel *bsd_header=(const struct disklabel *)(buffer+0x200);
- const struct disk_super_block*beos_block=(const struct disk_super_block*)(buffer+0x200);
+ const struct disk_super_block *beos_block=(const struct disk_super_block*)(buffer+0x200);
const struct cramfs_super *cramfs=(const struct cramfs_super *)(buffer+0x200);
const struct lvm2_label_header *lvm2=(const struct lvm2_label_header *)(buffer+0x200);
const struct sysv4_super_block *sysv4=(const struct sysv4_super_block *)(buffer+0x200);
diff --git a/src/chgtypen.c b/src/chgtypen.c
index 4689f3b..6015860 100644
--- a/src/chgtypen.c
+++ b/src/chgtypen.c
@@ -64,7 +64,7 @@ static void change_part_type_int_ncurses(const disk_t *disk_car, partition_t *pa
int i;
unsigned int last[3], done = 0, next = 0;
struct part_name_struct part_name[0x100];
- struct MenuItem menuType[]=
+ const struct MenuItem menuType[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/edit.c b/src/edit.c
index fe96b98..b3e0e3a 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -227,7 +227,7 @@ static int dump_editor(const unsigned char *nom_dump,const unsigned int lng, con
unsigned int pos;
int done=0;
unsigned int menu;
- struct MenuItem menuDump[]=
+ const struct MenuItem menuDump[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/ext2_sb.c b/src/ext2_sb.c
index 074a404..8a72ed3 100644
--- a/src/ext2_sb.c
+++ b/src/ext2_sb.c
@@ -43,7 +43,7 @@ int interface_superblock(disk_t *disk_car,list_part_t *list_part, char**current_
const list_part_t *parts;
const partition_t *old_part=NULL;
#ifdef HAVE_NCURSES
- struct MenuItem menuSuperblock[]=
+ const struct MenuItem menuSuperblock[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/fat1x.c b/src/fat1x.c
index 2e050e3..f8afc58 100644
--- a/src/fat1x.c
+++ b/src/fat1x.c
@@ -79,7 +79,7 @@ int fat1x_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
unsigned char *buffer_bs;
const char *options="DR";
#ifdef HAVE_NCURSES
- struct MenuItem menu_fat1x[]=
+ const struct MenuItem menu_fat1x[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/fat32.c b/src/fat32.c
index ca895da..a1c7112 100644
--- a/src/fat32.c
+++ b/src/fat32.c
@@ -83,7 +83,7 @@ int fat32_boot_sector(disk_t *disk_car, partition_t *partition, const int verbos
unsigned char *buffer_backup_bs;
const char *options="DRC";
#ifdef HAVE_NCURSES
- struct MenuItem menu_fat32[]=
+ const struct MenuItem menu_fat32[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 069ba32..96f6e87 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -937,7 +937,7 @@ static void menu_write_fat_boot_sector(disk_t *disk_car, partition_t *partition,
{
const struct fat_boot_sector *fat_header=(const struct fat_boot_sector *)newboot;
#ifdef HAVE_NCURSES
- struct MenuItem menuSaveBoot[]=
+ const struct MenuItem menuSaveBoot[]=
{
{ 'D', "Dump", "Dump sector" },
{ 'L', "List", "List directories and files" },
@@ -1816,7 +1816,7 @@ static upart_type_t select_fat_info(const info_offset_t *info_offset, const unsi
{
unsigned int i;
unsigned long int fat2_location=*reserved+*fat_length;
- struct MenuItem menuSelectFAT[]=
+ const struct MenuItem menuSelectFAT[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/file_fits.c b/src/file_fits.c
index 32057e6..ce655a7 100644
--- a/src/file_fits.c
+++ b/src/file_fits.c
@@ -166,7 +166,7 @@ static int header_check_fits(const unsigned char *buffer, const unsigned int buf
#endif
file_recovery_new->min_filesize=2880;
{
- uint64_t tmp=fits_info(buffer, buffer_size, file_recovery_new, &i);
+ const uint64_t tmp=fits_info(buffer, buffer_size, file_recovery_new, &i);
if(tmp==0)
return 1;
if(naxis_size_max < tmp && tmp > 1)
diff --git a/src/file_gz.c b/src/file_gz.c
index b37c20d..44714b6 100644
--- a/src/file_gz.c
+++ b/src/file_gz.c
@@ -85,10 +85,10 @@ static int header_check_gz(const unsigned char *buffer, const unsigned int buffe
return 0;
/*
- 4,5,6,7: mtime
-8: xfl/extra flags
-9: OS 3 - Unix, 7 - Macintosh, 11 - NTFS filesystem (NT)
-*/
+ * 4,5,6,7: mtime
+ * 8: xfl/extra flags
+ * 9: OS 3 - Unix, 7 - Macintosh, 11 - NTFS filesystem (NT)
+ */
if((flags&GZ_FEXTRA)!=0)
{
off+=2;
diff --git a/src/file_jpg.c b/src/file_jpg.c
index f7190a5..a275158 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -983,13 +983,12 @@ static uint64_t jpg_find_error(FILE *handle, const unsigned int output_scanline,
if(stop==1
&& is_line_cut(output_scanline, output_width, output_components, frame, y))
{
- uint64_t offset_rel1,offset_rel2;
+ const uint64_t offset_rel1=offsets[result_y / 8];
+ const uint64_t offset_rel2=offsets[result_y / 8 + 1];
#ifdef DEBUG_JPEG
log_info("x %4u, y %4u: %6u, result=%u, output_scanline_max=%u\n",
result_x, result_y, result_max, result, output_scanline_max);
#endif
- offset_rel1=offsets[result_y / 8];
- offset_rel2=offsets[result_y / 8 + 1];
if(offset_rel1 < offset_rel2)
return jpg_xy_to_offset(handle, result_x, result_y,
// offset_rel1, offset_rel2, offset, blocksize);
@@ -1111,8 +1110,7 @@ static void jpg_check_picture(file_recovery_t *file_recovery)
#if 1
if(jpeg_session.frame!=NULL && jpeg_session.flags!=0)
{
- uint64_t offset_error;
- offset_error=jpg_find_error(jpeg_session.handle, jpeg_session.cinfo.output_scanline, jpeg_session.output_width, jpeg_session.output_components, jpeg_session.frame, &offsets[0], jpeg_session.offset, jpeg_session.blocksize, file_recovery->checkpoint_offset);
+ const uint64_t offset_error=jpg_find_error(jpeg_session.handle, jpeg_session.cinfo.output_scanline, jpeg_session.output_width, jpeg_session.output_components, jpeg_session.frame, &offsets[0], jpeg_session.offset, jpeg_session.blocksize, file_recovery->checkpoint_offset);
if(offset_error !=0 && file_recovery->offset_error > offset_error)
file_recovery->offset_error=offset_error;
#ifdef DEBUG_JPEG
diff --git a/src/file_m2ts.c b/src/file_m2ts.c
index 8141f80..92d4ed9 100644
--- a/src/file_m2ts.c
+++ b/src/file_m2ts.c
@@ -63,7 +63,7 @@ static int data_check_ts_192(const unsigned char *buffer, const unsigned int buf
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
file_recovery->calculated_file_size + 5 < 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]!=0x47) /* TS_SYNC_BYTE */
return 2;
file_recovery->calculated_file_size+=192;
@@ -118,7 +118,7 @@ static int data_check_ts_188(const unsigned char *buffer, const unsigned int buf
{
while(file_recovery->calculated_file_size + 1 < 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]!=0x47) /* TS_SYNC_BYTE */
return 2;
file_recovery->calculated_file_size+=188;
diff --git a/src/file_mp3.c b/src/file_mp3.c
index be318b1..fb239c5 100644
--- a/src/file_mp3.c
+++ b/src/file_mp3.c
@@ -228,7 +228,7 @@ static int data_check_id3(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 + 1 < 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]==0)
{ /* Padding is present */
file_recovery->calculated_file_size++;
@@ -253,7 +253,6 @@ static int data_check_mp3(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 + 16 < file_recovery->file_size + buffer_size/2)
{
- unsigned int MMT_size;
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
#ifdef DEBUG_MP3
log_info("data_check_mp3 start i=0x%x buffer_size=0x%x calculated_file_size=%lu file_size=%lu\n",
@@ -339,17 +338,16 @@ static int data_check_mp3(const unsigned char *buffer, const unsigned int buffer
{
return 1;
}
- else if((MMT_size=search_MMT(buffer,i,buffer_size))!=0)
+ else
{
+ const unsigned int MMT_size=search_MMT(buffer,i,buffer_size);
+ if(MMT_size==0)
+ return 2;
/*
log_info("MusicMatch Tag found at offset 0x%x with size 0x%x \n", file_recovery->calculated_file_size, MMT_size);
- */
+ */
file_recovery->calculated_file_size+=MMT_size;
}
- else
- {
- return 2;
- }
}
return 1;
}
diff --git a/src/file_ogg.c b/src/file_ogg.c
index 8c28042..d2a349e 100644
--- a/src/file_ogg.c
+++ b/src/file_ogg.c
@@ -82,12 +82,10 @@ static int data_check_ogg(const unsigned char *buffer, const unsigned int buffer
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
if(memcmp(&buffer[i],ogg_header,sizeof(ogg_header))==0)
{
- unsigned int number_page_segments;
- unsigned int header_size;
+ const unsigned int number_page_segments=buffer[i+26];
+ const unsigned int header_size = number_page_segments + 27;
unsigned int page_size;
unsigned int j;
- number_page_segments=buffer[i+26];
- header_size = number_page_segments + 27;
page_size=header_size;
for(j=0;j<number_page_segments;j++)
page_size+=buffer[i+27+j];
diff --git a/src/file_pdf.c b/src/file_pdf.c
index 30c2c2b..072a880 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -279,8 +279,8 @@ static void file_date_pdf(file_recovery_t *file_recovery)
while(offset < file_recovery->file_size)
{
int i;
- int bsize;
- if((bsize=fread(buffer, 1, 4096, file_recovery->handle))<=0)
+ const int bsize=fread(buffer, 1, 4096, file_recovery->handle);
+ if(bsize<=0)
{
free(buffer);
return ;
diff --git a/src/file_png.c b/src/file_png.c
index 0643a3d..8c80db4 100644
--- a/src/file_png.c
+++ b/src/file_png.c
@@ -109,7 +109,7 @@ static int data_check_mng(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;
/* chunk: length, type, data, crc */
file_recovery->calculated_file_size+=(buffer[i]<<24)+(buffer[i+1]<<16)+(buffer[i+2]<<8)+buffer[i+3];
file_recovery->calculated_file_size+=12;
@@ -124,7 +124,7 @@ static int data_check_png(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;
/* chunk: length, type, data, crc */
file_recovery->calculated_file_size+=(buffer[i]<<24)+(buffer[i+1]<<16)+(buffer[i+2]<<8)+buffer[i+3];
file_recovery->calculated_file_size+=12;
diff --git a/src/file_psp.c b/src/file_psp.c
index 745d43b..af71e67 100644
--- a/src/file_psp.c
+++ b/src/file_psp.c
@@ -53,7 +53,7 @@ static int data_check_psp(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 + 10 < 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(memcmp(&buffer[i], "~BK\0", 4) != 0)
return 2;
/* chunk: header, id, total_length */
@@ -65,10 +65,9 @@ static int data_check_psp(const unsigned char *buffer, const unsigned int buffer
static int header_check_psp(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
- unsigned int ver_major;
+ const unsigned int ver_major=buffer[0x20]+(buffer[0x21]<<8);
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_psp.extension;
- ver_major=buffer[0x20]+(buffer[0x21]<<8);
if(ver_major>=4)
{
file_recovery_new->calculated_file_size=0x24;
diff --git a/src/file_riff.c b/src/file_riff.c
index 11bdb04..77b811c 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -176,7 +176,7 @@ static int data_check_avi(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 + 12 < 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;
const riff_chunk_header *chunk_header=(const riff_chunk_header*)&buffer[i];
if(memcmp(&buffer[i], "RIFF", 4)==0 && memcmp(&buffer[i+8], "AVIX", 4)==0)
file_recovery->calculated_file_size += 8 + le32(chunk_header->dwSize);
@@ -191,7 +191,7 @@ int data_check_avi_stream(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;
const riff_chunk_header *chunk_header=(const riff_chunk_header*)&buffer[i];
if(buffer[i+2]!='d' || buffer[i+3]!='b') /* Video Data Binary ?*/
return 2;
diff --git a/src/file_sig.c b/src/file_sig.c
index 6edd757..0a87831 100644
--- a/src/file_sig.c
+++ b/src/file_sig.c
@@ -124,8 +124,7 @@ static FILE *open_signature_file(void)
#endif
#ifndef DJGPP
{
- char *home;
- home = getenv("HOME");
+ const char *home = getenv("HOME");
if (home != NULL)
{
FILE*handle;
diff --git a/src/file_spf.c b/src/file_spf.c
index 4524d8d..df7073a 100644
--- a/src/file_spf.c
+++ b/src/file_spf.c
@@ -82,8 +82,7 @@ static void file_check_spf(file_recovery_t *file_recovery)
while(1)
{
int i;
- int taille;
- taille=fread(buffer,1,READ_SIZE,file_recovery->handle);
+ const int taille=fread(buffer,1,READ_SIZE,file_recovery->handle);
if(taille<512)
{
file_recovery->file_size=0;
diff --git a/src/file_swf.c b/src/file_swf.c
index 7d93ca4..8315640 100644
--- a/src/file_swf.c
+++ b/src/file_swf.c
@@ -48,7 +48,7 @@ const file_hint_t file_hint_swf= {
static int read_SB(const unsigned char **data, unsigned int *offset_bit, unsigned int nbit)
{
int res=0;
- unsigned int sign=((**data) >>(7 - (*offset_bit)))&1;
+ const unsigned int sign=((**data) >>(7 - (*offset_bit)))&1;
while(nbit>1)
{
(*offset_bit)++;
diff --git a/src/file_txt.c b/src/file_txt.c
index 85ea044..5c22178 100644
--- a/src/file_txt.c
+++ b/src/file_txt.c
@@ -417,9 +417,8 @@ static int UTFsize(const unsigned char *buffer, const unsigned int buf_len)
static int data_check_html(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
const char sign_html_end[] = "</html>";
- unsigned int i;
+ const unsigned int i=UTFsize(&buffer[buffer_size/2], buffer_size/2);
unsigned int j;
- i=UTFsize(&buffer[buffer_size/2], buffer_size/2);
for(j=(buffer_size/2>sizeof(sign_html_end)?buffer_size/2-sizeof(sign_html_end):0);
j+sizeof(sign_html_end)-1 < buffer_size;
j++)
@@ -442,8 +441,7 @@ static int data_check_html(const unsigned char *buffer, const unsigned int buffe
static int data_check_txt(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
- unsigned int i;
- i=UTFsize(&buffer[buffer_size/2], buffer_size/2);
+ const unsigned int i=UTFsize(&buffer[buffer_size/2], buffer_size/2);
if(i<buffer_size/2)
{
if(i>=10)
diff --git a/src/file_zip.c b/src/file_zip.c
index 791c633..864d7dc 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -336,7 +336,7 @@ static int zip_parse_file_entry(file_recovery_t *fr, const char **ext, const uns
Typically used in OOO documents
Search ZIP_DATA_DESCRIPTOR */
static const unsigned char zip_data_desc_header[4]= {0x50, 0x4B, 0x07, 0x08};
- int64_t pos = file_get_pos(fr->handle, zip_data_desc_header, 4);
+ const int64_t pos = file_get_pos(fr->handle, zip_data_desc_header, 4);
#ifdef DEBUG_ZIP
log_trace("Searched footer, got length %lli\n", (long long int)pos);
#endif
@@ -435,7 +435,7 @@ static int zip64_parse_end_central_dir(file_recovery_t *fr)
if (dir.end_size > 0)
{
- uint64_t len = le64(dir.end_size);
+ const uint64_t len = le64(dir.end_size);
if (fseek(fr->handle, len, SEEK_CUR) == -1)
{
#ifdef DEBUG_ZIP
@@ -475,7 +475,7 @@ static int zip_parse_end_central_dir(file_recovery_t *fr)
if (dir.comment_length)
{
- uint16_t len = le16(dir.comment_length);
+ const uint16_t len = le16(dir.comment_length);
if (fseek(fr->handle, len, SEEK_CUR) == -1)
{
#ifdef DEBUG_ZIP
diff --git a/src/intrface.c b/src/intrface.c
index 48fd438..2e12615 100644
--- a/src/intrface.c
+++ b/src/intrface.c
@@ -79,7 +79,7 @@ void interface_list(disk_t *disk, const int verbose, const int saveheader, const
static list_part_t *ask_structure_cli(disk_t *disk_car,list_part_t *list_part, const int verbose, char **current_cmd)
{
- list_part_t *pos=list_part;
+ const list_part_t *pos=list_part;
while(*current_cmd[0]==',')
(*current_cmd)++;
if(strncmp(*current_cmd,"list",4)==0)
@@ -87,7 +87,7 @@ static list_part_t *ask_structure_cli(disk_t *disk_car,list_part_t *list_part, c
(*current_cmd)+=4;
if(pos!=NULL)
{
- partition_t *partition=pos->part;
+ const partition_t *partition=pos->part;
if(partition->sb_offset==0 || partition->sb_size==0)
dir_partition(disk_car,partition,verbose, current_cmd);
else
@@ -362,7 +362,7 @@ static list_part_t *ask_structure_ncurses(disk_t *disk_car,list_part_t *list_par
case 'P':
if(list_part!=NULL)
{
- partition_t *partition=pos->part;
+ const partition_t *partition=pos->part;
if(partition->sb_offset==0 || partition->sb_size==0)
dir_partition(disk_car,partition,verbose, current_cmd);
else
diff --git a/src/intrfn.c b/src/intrfn.c
index 1413fe6..e1f3535 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -160,7 +160,9 @@ static int wgetch_nodelay(WINDOW *window)
static int wmenuUpdate(WINDOW *window, const int yinfo, int y, int x, const struct MenuItem *menuItems, const unsigned int itemLength, const char *available, const int menuType, unsigned int current)
{
- unsigned int i, lmargin = x, ymargin = y;
+ unsigned int i;
+ const unsigned int lmargin = x;
+ const unsigned int ymargin = y;
unsigned int lenNameMax=0;
for( i = 0; menuItems[i].key!=0; i++ )
if(strchr(available, menuItems[i].key)!=NULL )
@@ -271,7 +273,9 @@ int menu_to_command(const unsigned int yinfo, const unsigned int y_org, const un
{
unsigned int y=y_org;
unsigned int x=x_org;
- unsigned int i, lmargin = x, ymargin = y;
+ unsigned int i;
+ const unsigned int lmargin = x;
+ const unsigned int ymargin = y;
unsigned int lenNameMax=0;
for( i = 0; menuItems[i].key!=0; i++ )
if(strchr(available, menuItems[i].key)!=NULL )
@@ -341,10 +345,8 @@ int wmenuSelect(WINDOW *window, const int yinfo, const int y, const int x, const
return wmenuSelect_ext(window, yinfo, y, x, menuItems, itemLength, available, menuType, &current, NULL);
}
-int wmenuSelect_ext(WINDOW *window, const int yinfo, const int y_org, const int x_org, const struct MenuItem *menuItems, const unsigned int itemLength, const char *available, const int menuType, unsigned int *current, int *real_key)
+int wmenuSelect_ext(WINDOW *window, const int yinfo, const int y, const int x, const struct MenuItem *menuItems, const unsigned int itemLength, const char *available, const int menuType, unsigned int *current, int *real_key)
{
- unsigned int y=y_org;
- unsigned int x=x_org;
unsigned int i;
unsigned int ylast = y;
int key = 0;
@@ -1043,8 +1045,7 @@ static char *filename_to_directory(const char *filename)
char buf[2048];
char *res;
#ifdef HAVE_READLINK
- int len;
- len=readlink(filename,buf,sizeof(buf)-1);
+ const int len=readlink(filename,buf,sizeof(buf)-1);
if(len>=0)
buf[len]='\0';
else
@@ -1260,7 +1261,7 @@ void screen_buffer_to_interface(void)
{
{
int i;
- int pos=intr_nbr_line-DUMP_MAX_LINES<0?0:intr_nbr_line-DUMP_MAX_LINES;
+ const int pos=intr_nbr_line-DUMP_MAX_LINES<0?0:intr_nbr_line-DUMP_MAX_LINES;
if(intr_nbr_line<MAX_LINES && intr_buffer_screen[intr_nbr_line][0]!='\0')
intr_nbr_line++;
/* curses interface */
@@ -1316,7 +1317,6 @@ int vaff_txt(int line, WINDOW *window, const char *_format, va_list ap)
void display_message(const char*msg)
{
- int pipo=0;
static const struct MenuItem menuGeometry[]=
{
{ 'Q', "Ok", "" },
@@ -1326,7 +1326,7 @@ void display_message(const char*msg)
log_info("%s",msg);
aff_copy(window);
mvwaddstr(window,5,0,msg);
- wmenuSimple(window,menuGeometry, pipo);
+ wmenuSimple(window,menuGeometry, 0);
delwin(window);
(void) clearok(stdscr, TRUE);
#ifdef HAVE_TOUCHWIN
@@ -1337,13 +1337,12 @@ void display_message(const char*msg)
uint64_t ask_int_ncurses(const char *string)
{
WINDOW *local_win;
- int startx, starty, width, height;
+ const int height = 3;
+ const int width = 40;
+ const int starty = (LINES - height) / 2; /* Calculating for a center placement */
+ const int startx = (COLS - width) / 2; /* of the window */
uint64_t min_size=0;
char response[128];
- height = 3;
- width = 40;
- starty = (LINES - height) / 2; /* Calculating for a center placement */
- startx = (COLS - width) / 2; /* of the window */
local_win = newwin(height, width, starty, startx);
keypad(local_win, TRUE); /* Need it to get arrow key */
@@ -1366,12 +1365,11 @@ uint64_t ask_int_ncurses(const char *string)
const char *ask_string_ncurses(const char *string)
{
WINDOW *local_win;
- int startx, starty, width, height;
+ const int height = 3;
+ const int width = 60;
+ const int starty = (LINES - height) / 2; /* Calculating for a center placement */
+ const int startx = (COLS - width) / 2; /* of the window */
static char response[128];
- height = 3;
- width = 60;
- starty = (LINES - height) / 2; /* Calculating for a center placement */
- startx = (COLS - width) / 2; /* of the window */
local_win = newwin(height, width, starty, startx);
keypad(local_win, TRUE); /* Need it to get arrow key */
diff --git a/src/photorec.c b/src/photorec.c
index 73e00e5..e731ef2 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -510,8 +510,7 @@ unsigned int find_blocksize(alloc_data_t *list_search_space, const unsigned int
run_again=0;
td_list_for_each(search_walker, &list_search_space->list)
{
- alloc_data_t *tmp;
- tmp=td_list_entry(search_walker, alloc_data_t, list);
+ const alloc_data_t *tmp=td_list_entry(search_walker, alloc_data_t, list);
if(tmp->file_stat!=NULL)
{
if(tmp->start%blocksize!=*offset && blocksize>default_blocksize)
diff --git a/src/sun.c b/src/sun.c
index 7f5bf29..43f3f60 100644
--- a/src/sun.c
+++ b/src/sun.c
@@ -47,7 +47,7 @@ static int test_sun_i386(const disk_t *disk_car, const sun_partition_i386 *sunla
int check_sun_i386(disk_t *disk_car,partition_t *partition,const int verbose)
{
unsigned char *buffer=(unsigned char*)MALLOC(SUN_PARTITION_I386_SIZE);
- sun_partition_i386 *sunlabel=(sun_partition_i386*)buffer;
+ const sun_partition_i386 *sunlabel=(const sun_partition_i386*)buffer;
if(disk_car->pread(disk_car, buffer, SUN_PARTITION_I386_SIZE, partition->part_offset + 0x200) != SUN_PARTITION_I386_SIZE)
{
free(buffer);
diff --git a/src/tanalyse.c b/src/tanalyse.c
index 1de4a44..a65e111 100644
--- a/src/tanalyse.c
+++ b/src/tanalyse.c
@@ -43,7 +43,7 @@ static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbos
list_part_t *list_part;
int command;
#ifdef HAVE_NCURSES
- struct MenuItem menuAnalyse[]=
+ const struct MenuItem menuAnalyse[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/texfat.c b/src/texfat.c
index 5b41bd4..2f890e0 100644
--- a/src/texfat.c
+++ b/src/texfat.c
@@ -80,7 +80,7 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
const char *options="";
int rescan=1;
#ifdef HAVE_NCURSES
- struct MenuItem menu_exFAT[]=
+ const struct MenuItem menu_exFAT[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/thfs.c b/src/thfs.c
index 6e37bb1..f7635b5 100644
--- a/src/thfs.c
+++ b/src/thfs.c
@@ -81,7 +81,7 @@ int HFS_HFSP_boot_sector(disk_t *disk_car, partition_t *partition, const int ver
const char *options="";
int rescan=1;
#ifdef HAVE_NCURSES
- struct MenuItem menu_hfsp[]=
+ const struct MenuItem menu_hfsp[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/tload.c b/src/tload.c
index 0868649..3160e7f 100644
--- a/src/tload.c
+++ b/src/tload.c
@@ -63,7 +63,7 @@ static struct td_list_head *interface_load_ncurses(disk_t *disk_car, backup_disk
unsigned int menu=3; /* default : quit */
struct td_list_head *backup_current=backup_list->list.next;
struct td_list_head *backup_walker=NULL;
- struct MenuItem menuLoadBackup[]=
+ const struct MenuItem menuLoadBackup[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/tlog.c b/src/tlog.c
index 0164890..2fdfec8 100644
--- a/src/tlog.c
+++ b/src/tlog.c
@@ -73,9 +73,8 @@ int ask_testdisk_log_creation(void)
wprintw(stdscr,"Use arrow keys to select, then press Enter key:");
while(1)
{
- int command;
- command = wmenuSelect_ext(stdscr, 23, 17, 0, menuLogCreation, 8,
- "CAQ", MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+ const int command = wmenuSelect_ext(stdscr, 23, 17, 0, menuLogCreation, 8,
+ "CAQ", MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
switch(command)
{
case 'C':
diff --git a/src/tntfs.c b/src/tntfs.c
index 4ecafd6..9958c77 100644
--- a/src/tntfs.c
+++ b/src/tntfs.c
@@ -78,7 +78,7 @@ int ntfs_boot_sector(disk_t *disk_car, partition_t *partition, const int verbose
unsigned char *buffer_backup_bs;
const char *options="";
#ifdef HAVE_NCURSES
- struct MenuItem menu_ntfs[]=
+ const struct MenuItem menu_ntfs[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/tpartwr.c b/src/tpartwr.c
index 3d41d33..f32fd3b 100644
--- a/src/tpartwr.c
+++ b/src/tpartwr.c
@@ -41,7 +41,7 @@ int interface_write(disk_t *disk_car,list_part_t *list_part,const int can_search
{
list_part_t *parts;
#ifdef HAVE_NCURSES
- struct MenuItem menuWrite[]=
+ const struct MenuItem menuWrite[]=
{
{ 'P', "Previous",""},
{ 'N', "Next","" },
diff --git a/src/ufs.c b/src/ufs.c
index 9466027..ea18364 100644
--- a/src/ufs.c
+++ b/src/ufs.c
@@ -42,7 +42,7 @@ static int test_ufs(const disk_t *disk_car, const struct ufs_super_block *sb, pa
int check_ufs(disk_t *disk_car,partition_t *partition,const int verbose)
{
- const struct ufs_super_block*sb;
+ const struct ufs_super_block *sb;
unsigned char *buffer;
buffer=(unsigned char*)MALLOC(UFS_SUPERBLOCK_SIZE);
sb=(const struct ufs_super_block*)buffer;