summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-10-25 18:26:16 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-10-25 18:26:16 +0100
commit5156d5b462f00da3830dc6314dd74feda37f1257 (patch)
tree85ff8a96aeab5a1cdd6054f6be8a53d12d401788
parent4a75ec8effe3e4878e7710a1322d8ed86f059c08 (diff)
Code cleanup
-rw-r--r--src/bfs.c4
-rw-r--r--src/bfs.h34
-rw-r--r--src/chgtype.c2
-rw-r--r--src/crc.c2
-rw-r--r--src/crc.h6
-rw-r--r--src/file_all.c2
-rw-r--r--src/file_asf.c2
-rw-r--r--src/file_d2s.c2
-rw-r--r--src/file_e01.c1
-rw-r--r--src/file_gz.c4
-rw-r--r--src/file_jpg.c2
-rw-r--r--src/file_logic.c2
-rw-r--r--src/file_mp3.c2
-rw-r--r--src/file_rns.c2
-rw-r--r--src/file_spf.c2
-rw-r--r--src/file_tiff.c5
-rw-r--r--src/fnctdsk.h2
-rw-r--r--src/godmode.h1
-rw-r--r--src/hdcache.c3
-rw-r--r--src/hpa_dco.c2
-rw-r--r--src/intrf.c6
-rw-r--r--src/intrf.h4
-rw-r--r--src/lang.h18
-rw-r--r--src/md.h2
-rw-r--r--src/netware.h4
-rw-r--r--src/ntfs.c1
-rw-r--r--src/ntfs.h1
-rw-r--r--src/ntfs_udl.c2
-rw-r--r--src/parti386.c6
-rw-r--r--src/parti386n.c2
-rw-r--r--src/partmac.c2
-rw-r--r--src/partnone.c7
-rw-r--r--src/partsun.c4
-rw-r--r--src/partsunn.c2
-rw-r--r--src/partxbox.c2
-rw-r--r--src/phmain.c8
-rw-r--r--src/photorec.c10
-rw-r--r--src/photorec.h9
-rw-r--r--src/phrecn.c40
-rw-r--r--src/rfs.h1
-rw-r--r--src/savehdr.h5
-rw-r--r--src/sysv.h2
-rw-r--r--src/testdisk.c6
-rw-r--r--src/zfs.h4
44 files changed, 86 insertions, 144 deletions
diff --git a/src/bfs.c b/src/bfs.c
index 1e5d75c..b88f368 100644
--- a/src/bfs.c
+++ b/src/bfs.c
@@ -61,7 +61,7 @@ int recover_BeFS(disk_t *disk_car, const struct disk_super_block *beos_block, pa
if(test_BeFS(disk_car,beos_block,partition,dump_ind)!=0)
return 1;
set_BeFS_info(beos_block, partition);
- partition->part_size=le64(beos_block->num_blocks) * (1<<le32(beos_block->block_shift));
+ partition->part_size=le64(beos_block->num_blocks) << le32(beos_block->block_shift);
partition->part_type_i386=(unsigned char)P_BEOS;
return 0;
}
@@ -69,7 +69,7 @@ int recover_BeFS(disk_t *disk_car, const struct disk_super_block *beos_block, pa
static int test_BeFS(disk_t *disk_car, const struct disk_super_block*beos_block,partition_t *partition, const int dump_ind)
{
if(beos_block->magic1==le32(SUPER_BLOCK_MAGIC1) &&
- beos_block->magic2==(signed)le32(SUPER_BLOCK_MAGIC2) &&
+ beos_block->magic2==le32(SUPER_BLOCK_MAGIC2) &&
beos_block->magic3==le32(SUPER_BLOCK_MAGIC3))
{
partition->upart_type=UP_BEOS;
diff --git a/src/bfs.h b/src/bfs.h
index 8d2d734..14087a2 100644
--- a/src/bfs.h
+++ b/src/bfs.h
@@ -28,7 +28,7 @@ extern "C" {
typedef struct block_run
{
- int32_t allocation_group;
+ uint32_t allocation_group;
uint16_t start;
uint16_t len; /* in blocks */
} block_run;
@@ -38,36 +38,36 @@ typedef block_run inode_addr;
#define B_OS_NAME_LENGTH 32
-typedef struct disk_super_block /* super block as it is on disk */
+struct disk_super_block /* super block as it is on disk */
{
char name[B_OS_NAME_LENGTH];
- int32_t magic1; /* 0x20 */
- int32_t fs_byte_order; /* 0x24 */
+ uint32_t magic1; /* 0x20 */
+ uint32_t fs_byte_order; /* 0x24 */
uint32_t block_size; /* 0x28 in bytes */
uint32_t block_shift; /* 0x2C block_size == (1 << block_shift) */
- int64_t num_blocks; /* 0x30 */
- int64_t used_blocks; /* 0x38 */
+ uint64_t num_blocks; /* 0x30 */
+ uint64_t used_blocks; /* 0x38 */
- int32_t inode_size; /* 0x40 # of bytes per inode */
+ uint32_t inode_size; /* 0x40 # of bytes per inode */
- int32_t magic2; /* 0x44 */
- int32_t blocks_per_ag; /* 0x48 in blocks */
- int32_t ag_shift; /* 0x4C # of bits to shift to get ag num */
- int32_t num_ags; /* 0x50 # of allocation groups */
- int32_t flags; /* 0x54 if it's clean, etc */
+ uint32_t magic2; /* 0x44 */
+ uint32_t blocks_per_ag; /* 0x48 in blocks */
+ uint32_t ag_shift; /* 0x4C # of bits to shift to get ag num */
+ uint32_t num_ags; /* 0x50 # of allocation groups */
+ uint32_t flags; /* 0x54 if it's clean, etc */
block_run log_blocks; /* 0x58 a block_run of the log blocks */
- int64_t log_start; /* 0x60 block # of the beginning */
- int64_t log_end; /* 0x68 block # of the end of the log */
+ uint64_t log_start; /* 0x60 block # of the beginning */
+ uint64_t log_end; /* 0x68 block # of the end of the log */
- int32_t magic3; /* 0x70 */
+ uint32_t magic3; /* 0x70 */
inode_addr root_dir; /* 0x74 */
inode_addr indices; /* 0x7C */
- int32_t pad[8]; /* 0x84 extra stuff for the future */
+ uint32_t pad[8]; /* 0x84 extra stuff for the future */
/* 0xA4-0xFF */
-} disk_super_block;
+};
/*the flags field can have these values */
diff --git a/src/chgtype.c b/src/chgtype.c
index a3b85c9..8446c9f 100644
--- a/src/chgtype.c
+++ b/src/chgtype.c
@@ -35,8 +35,6 @@
extern const arch_fnct_t arch_gpt;
extern const arch_fnct_t arch_none;
-extern const arch_fnct_t arch_i386;
-extern const arch_fnct_t arch_sun;
void change_part_type_cli(const disk_t *disk_car,partition_t *partition, char **current_cmd)
{
diff --git a/src/crc.c b/src/crc.c
index b1faa6c..0d1b268 100644
--- a/src/crc.c
+++ b/src/crc.c
@@ -95,7 +95,7 @@ unsigned int get_crc32(const void*buf, const unsigned int len, const uint32_t se
{
crc32val = crc32_tab[(crc32val ^ s[i]) & 0xff] ^ (crc32val >> 8);
}
- return crc32val;
+ return (unsigned int)crc32val;
}
#if 0
diff --git a/src/crc.h b/src/crc.h
index 1c9646b..50b6667 100644
--- a/src/crc.h
+++ b/src/crc.h
@@ -24,12 +24,6 @@
extern "C" {
#endif
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "types.h"
-#include "common.h"
-
#if 0
uint32_t* make_crc32_table(uint32_t poly);
unsigned int get_crc32_gen(const unsigned char *s, const unsigned int len, const uint32_t seed, const uint32_t *crctab);
diff --git a/src/file_all.c b/src/file_all.c
index 9ba9e88..91d9aea 100644
--- a/src/file_all.c
+++ b/src/file_all.c
@@ -43,7 +43,7 @@ const file_hint_t file_hint_all= {
.register_header_check=&register_header_check_all
};
-const unsigned char all_header[8]= { 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x06, 0x04};
+static const unsigned char all_header[8]= { 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x06, 0x04};
static void register_header_check_all(file_stat_t *file_stat)
{
diff --git a/src/file_asf.c b/src/file_asf.c
index 819678c..d049b8d 100644
--- a/src/file_asf.c
+++ b/src/file_asf.c
@@ -44,7 +44,7 @@ const file_hint_t file_hint_asf= {
.register_header_check=&register_header_check_asf
};
-const unsigned char asf_header[4]= { 0x30,0x26,0xB2,0x75};
+static const unsigned char asf_header[4]= { 0x30,0x26,0xB2,0x75};
static void register_header_check_asf(file_stat_t *file_stat)
{
diff --git a/src/file_d2s.c b/src/file_d2s.c
index 97d6b09..2bbaf49 100644
--- a/src/file_d2s.c
+++ b/src/file_d2s.c
@@ -52,8 +52,6 @@ static void register_header_check_d2s(file_stat_t *file_stat)
register_header_check(0, d2s_header,sizeof(d2s_header), &header_check_d2s, file_stat);
}
-/* TODO: extract the name from the file */
-
static int header_check_d2s(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)
{
if(memcmp(buffer,d2s_header,sizeof(d2s_header))==0)
diff --git a/src/file_e01.c b/src/file_e01.c
index 5a09705..9dee249 100644
--- a/src/file_e01.c
+++ b/src/file_e01.c
@@ -106,7 +106,6 @@ static void file_check_e01(file_recovery_t *file_recovery)
'n', 'e', 'x', 't', 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- uint64_t file_size=file_recovery->file_size;
file_search_footer(file_recovery, sig_next, sizeof(sig_next), 60);
if(file_recovery->file_size!=0)
return ;
diff --git a/src/file_gz.c b/src/file_gz.c
index f26c1bc..3893ca5 100644
--- a/src/file_gz.c
+++ b/src/file_gz.c
@@ -72,7 +72,7 @@ static void register_header_check_gz(file_stat_t *file_stat)
static int header_check_gz(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)
{
static const unsigned char tar_header_posix[8] = { 'u','s','t','a','r',' ',' ',0x00};
- static const unsigned char xournal_header[0x2d] = {
+ static const unsigned char xournal_header[0x2e] = {
'<', '?', 'x', 'm', 'l', ' ', 'v', 'e',
'r', 's', 'i', 'o', 'n', '=', '"', '1',
'.', '0', '"', ' ', 's', 't', 'a', 'n',
@@ -232,7 +232,6 @@ static void file_rename_gz(const char *old_filename)
unsigned char buffer[512];
FILE *file;
int buffer_size;
- int off=10;
if((file=fopen(old_filename, "rb"))==NULL)
return;
buffer_size=fread(buffer, 1, sizeof(buffer), file);
@@ -243,6 +242,7 @@ static void file_rename_gz(const char *old_filename)
return ;
{
const unsigned int flags=buffer[3];
+ int off=10;
if((flags&GZ_FEXTRA)!=0)
{
off+=2;
diff --git a/src/file_jpg.c b/src/file_jpg.c
index a5ea516..66e11de 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -487,11 +487,11 @@ static void jpg_check_structure(file_recovery_t *file_recovery, const unsigned i
{
FILE* infile=file_recovery->handle;
unsigned char buffer[40*8192];
- unsigned int offset=2;
int nbytes;
fseek(infile, 0, SEEK_SET);
if((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0)
{
+ unsigned int offset=2;
while(offset < nbytes)
{
const unsigned int i=offset;
diff --git a/src/file_logic.c b/src/file_logic.c
index 7d51caf..1e418d6 100644
--- a/src/file_logic.c
+++ b/src/file_logic.c
@@ -43,7 +43,7 @@ const file_hint_t file_hint_logic= {
.register_header_check=&register_header_check_logic
};
-const unsigned char logic_header[12]= {
+static const unsigned char logic_header[12]= {
0xab, 0xc0, 0x47, 0x13, 0x05, 0x17, 0x00, 0x15, 0x00, 0x04, 0x00, 0x24
};
diff --git a/src/file_mp3.c b/src/file_mp3.c
index 1eb4865..a847ce7 100644
--- a/src/file_mp3.c
+++ b/src/file_mp3.c
@@ -258,7 +258,7 @@ 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 = 0;
+ unsigned int MMT_size;
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
/*
log_trace("data_check_mp3 start i=0x%x buffer_size=0x%x calculated_file_size=%lu file_size=%lu\n",
diff --git a/src/file_rns.c b/src/file_rns.c
index ae79031..9829058 100644
--- a/src/file_rns.c
+++ b/src/file_rns.c
@@ -44,7 +44,7 @@ const file_hint_t file_hint_rns= {
.register_header_check=&register_header_check_rns
};
-const unsigned char rns_header[] = "Propellerheads Reason Song File";
+static const unsigned char rns_header[] = "Propellerheads Reason Song File";
static void register_header_check_rns(file_stat_t *file_stat)
{
diff --git a/src/file_spf.c b/src/file_spf.c
index 2fdf07f..9da9b6e 100644
--- a/src/file_spf.c
+++ b/src/file_spf.c
@@ -46,7 +46,7 @@ const file_hint_t file_hint_spf= {
.register_header_check=&register_header_check_spf
};
-const unsigned char spf_header[12]= {
+static const unsigned char spf_header[12]= {
'S', 'P', 'F', 'I', 0x00, 0x02, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00
};
diff --git a/src/file_tiff.c b/src/file_tiff.c
index da09558..fff194e 100644
--- a/src/file_tiff.c
+++ b/src/file_tiff.c
@@ -93,7 +93,7 @@ static const char *find_tag_from_tiff_header_be(const TIFFHeader *tiff, const un
/* IFD1 */
if(be32(*tiff_next_diroff)>0)
{
- const const struct ifd_header *ifd1=(const struct ifd_header*)((const char *)tiff+be32(*tiff_next_diroff));
+ const struct ifd_header *ifd1=(const struct ifd_header*)((const char *)tiff+be32(*tiff_next_diroff));
if((const char*)ifd1 <= (const char*)tiff ||
(const char*)(ifd1+1) > (const char*)tiff+tiff_size)
return NULL;
@@ -144,7 +144,7 @@ static const char *find_tag_from_tiff_header_le(const TIFFHeader *tiff, const un
/* IFD1 */
if(le32(*tiff_next_diroff)>0)
{
- const const struct ifd_header *ifd1=(const struct ifd_header*)((const char *)tiff+le32(*tiff_next_diroff));
+ const struct ifd_header *ifd1=(const struct ifd_header*)((const char *)tiff+le32(*tiff_next_diroff));
/* Bound checking */
if((const char*)(ifd1) <= (const char*)tiff ||
(const char*)(ifd1+1) > (const char*)tiff+tiff_size)
@@ -222,6 +222,7 @@ static int header_check_tiff(const unsigned char *buffer, const unsigned int buf
file_recovery_new->extension="cr2";
else if(find_tag_from_tiff_header((const TIFFHeader *)buffer, buffer_size, TIFFTAG_DNGVERSION)!=NULL)
{
+ /* Adobe Digital Negative */
file_recovery_new->extension="dng";
}
else
diff --git a/src/fnctdsk.h b/src/fnctdsk.h
index 4e5989e..8f6569f 100644
--- a/src/fnctdsk.h
+++ b/src/fnctdsk.h
@@ -32,14 +32,12 @@ void offset2CHS(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS);
list_disk_t *insert_new_disk(list_disk_t *list_disk, disk_t *disk_car);
list_part_t *insert_new_partition(list_part_t *list_part, partition_t *part, const int force_insert, int *insert_error);
-list_part_t *remove_partition(list_part_t *list_part, list_part_t *element2removed);
list_part_t *sort_partition_list(list_part_t *list_part);
list_part_t *gen_sorted_partition_list(const list_part_t *list_part);
void part_free_list(list_part_t *list_part);
void part_free_list_only(list_part_t *list_part);
void partition_reset(partition_t *partition, const arch_fnct_t *arch);
partition_t *partition_new(const arch_fnct_t *arch);
-int check_list_part(list_part_t *list_part);
unsigned int get_geometry_from_list_part(const disk_t *disk_car, const list_part_t *list_part, const int verbose);
int delete_list_disk(list_disk_t *list_disk);
const char *size_to_unit(uint64_t disk_size, char *buffer);
diff --git a/src/godmode.h b/src/godmode.h
index 1733121..ce3deb2 100644
--- a/src/godmode.h
+++ b/src/godmode.h
@@ -23,7 +23,6 @@
extern "C" {
#endif
-enum part_offset { PART_OFFSET128, PART_OFFSET2, PART_OFFSET1, PART_OFFSET0, PART_QUIT};
typedef enum part_offset part_offset_t;
int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, int align, const int ask_part_order, const unsigned int expert, const int search_vista_part, char **current_cmd);
void only_one_bootable( list_part_t *list_part, list_part_t *part_boot);
diff --git a/src/hdcache.c b/src/hdcache.c
index ba32723..87648f7 100644
--- a/src/hdcache.c
+++ b/src/hdcache.c
@@ -217,8 +217,7 @@ static int cache_clean(disk_t *disk_car)
for(i=0;i<CACHE_BUFFER_NBR;i++)
{
struct cache_buffer_struct *cache=&data->cache[i];
- if(cache->buffer!=NULL)
- free(cache->buffer);
+ free(cache->buffer);
}
free(data->disk_car);
free(disk_car->data);
diff --git a/src/hpa_dco.c b/src/hpa_dco.c
index 52dfa94..c679757 100644
--- a/src/hpa_dco.c
+++ b/src/hpa_dco.c
@@ -180,7 +180,7 @@ static uint64_t sg_read_native_max_ext(int fd)
if (sb[0] != 0x72 || sb[7] < 14 || desc[0] != 9 || desc[1] < 12)
return 0;
return ((uint64_t)word[2]>>8) | (((uint64_t)word[3]>>8)<<8) | (((uint64_t)word[4]>>8)<<16) |
- ((uint64_t)(word[2]&0xff)<<24) | ((uint64_t)(word[3]&0xff)<<32) | ((uint64_t)(word[4]&0xff)<<48);
+ ((uint64_t)(word[2]&0xff)<<24) | (((uint64_t)word[3]&0xff)<<32) | (((uint64_t)word[4]&0xff)<<48);
#else
return 0;
#endif
diff --git a/src/intrf.c b/src/intrf.c
index a7ac5d4..2607e1c 100644
--- a/src/intrf.c
+++ b/src/intrf.c
@@ -101,7 +101,7 @@ int screen_buffer_add(const char *_format, ...)
return 0;
}
-void screen_buffer_to_stdout()
+void screen_buffer_to_stdout(void)
{
int i;
if(intr_nbr_line<MAX_LINES && intr_buffer_screen[intr_nbr_line][0]!='\0')
@@ -114,13 +114,13 @@ void screen_buffer_to_stdout()
}
}
-void screen_buffer_reset()
+void screen_buffer_reset(void)
{
intr_nbr_line=0;
memset(intr_buffer_screen, 0, sizeof(intr_buffer_screen));
}
-void screen_buffer_to_log()
+void screen_buffer_to_log(void)
{
int i;
if(intr_buffer_screen[intr_nbr_line][0]!='\0')
diff --git a/src/intrf.h b/src/intrf.h
index 9bdd06f..f37bff3 100644
--- a/src/intrf.h
+++ b/src/intrf.h
@@ -54,8 +54,6 @@ struct MenuItem
#define MENU_MAX_ITEMS 256 /* for simpleMenu function */
#define key_CR '\015'
#define key_ESC '\033'
-#define key_DEL '\177'
-#define key_BELL '\007'
/* '\014' == ^L */
#define key_REDRAWKEY '\014'
@@ -67,14 +65,12 @@ void aff_part_buffer(const unsigned int newline,const disk_t *disk_car,const par
int ask_confirmation(const char*_format, ...) __attribute__ ((format (printf, 1, 2)));
unsigned long long int ask_number(const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 4, 5)));
unsigned long long int ask_number_cli(char **current_cmd, const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 5, 6)));
-int display_message_aux(const char*_format,...) __attribute__ ((format (printf, 1, 2)));
void not_implemented(const char *msg);
void screen_buffer_reset(void);
int screen_buffer_add(const char *_format, ...) __attribute__ ((format (printf, 1, 2)));
void screen_buffer_to_log(void);
void screen_buffer_to_interface(void);
void screen_buffer_to_stdout(void);
-int intrf_no_disk(const char *prog_name);
char *get_default_location(void);
void dump_ncurses(const void *nom_dump, unsigned int lng);
char *td_getcwd(char *buf, unsigned long size);
diff --git a/src/lang.h b/src/lang.h
index ef53acf..f20dce7 100644
--- a/src/lang.h
+++ b/src/lang.h
@@ -25,7 +25,6 @@
#define c_YES 'Y'
#define c_NO 'N'
#define msg_TBL_NMARK "\nPartition sector doesn't have the endmark 0xAA55\n"
-#define msg_BAD_NMARK "\nBoot sector doesn't have the endmark 0xAA55\n"
#define msg_BAD_S_CYL "\nWarning: Bad starting cylinder (CHS and LBA don't match)"
#define msg_BAD_S_HEAD "\nWarning: Bad starting head (CHS and LBA don't match)"
#define msg_BAD_S_SECT "\nWarning: Bad starting sector (CHS and LBA don't match)"
@@ -37,12 +36,9 @@
#define msg_BAD_SCOUNT "\nBad sector count."
#define msg_CHKFAT_BAD_JUMP "check_FAT: Bad jump in FAT partition\n"
#define msg_CHKFAT_SECT_CLUSTER "check_FAT: Bad number of sectors per cluster\n"
-#define msg_CHKFAT_SECTTRACK "check_FAT: Incorrect number of sectors per track\n"
-#define msg_CHKFAT_SIDE "check_FAT: Incorrect number of sides\n"
#define msg_CHKFAT_ENTRY "check_FAT: Bad number of entries in root dir\n"
#define msg_CHKFAT_SIZE "check_FAT: Incorrect size of partition\n"
#define msg_CHKFAT_SECTPFAT "check_FAT: Incorrect number of sectors per FAT\n"
-#define msg_CHKFAT_BAD_HIDDEN "check_FAT: Incorrect number of hidden sectors\n"
#define msg_CHKFAT_BADFAT32VERSION "check_FAT: Bad FAT32 version, should be 0.0\n"
#define msg_PART_HEADER " Partition\t\t Start End Size in sectors\n"
#define msg_PART_HEADER_LONG " Partition\t\t\tStart End Size in sectors\n"
@@ -50,12 +46,9 @@
#define msg_PART_WR_ERR "\nPartition: Write error\n"
#define msg_ONLY_ONE_DOS "Partition Table contains two or more Primary DOS FAT partitions\n"
#define msg_ONLY_ONE_EXT "Partition Table may contain only one Extended partition\n"
-#define msg_NO_OS2MB "There are hidden partitions, but no OS2 MultiBoot.\n"
#define msg_NO_BOOTABLE "No partition is bootable\n"
#define msg_ONLY1MUSTBOOT "Only one partition must be bootable\n"
#define msg_SAME_SPACE "Space conflict between the following two partitions\n"
-#define msg_CHOICE "\nChoice ? "
-#define msg_FREE_ERROR "\nFree memory allocation error"
#define msg_WRITE_CLEAN_TABLE "Clear MBR partition table by writing zero bytes to it? (Y/N) "
#define msg_WRITE_MBR_CODE "Write a new copy of MBR code to first sector? (Y/N) "
#define msg_STRUCT_BAD "Structure: Bad."
@@ -64,14 +57,3 @@
#define msg_MBR_ORDER_GOOD "Partitions order: Ok "
#define msg_MBR_ORDER_BAD "Partitions order: Bad"
#define msg_NO_EXT_PART "No extended partition\n"
-#define msg_ROOT_CLUSTER_RERR "\nroot_cluster: read error"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-const unsigned char *partition_type(const unsigned char type, const struct systypes *parttype_name_table);
-#ifdef __cplusplus
-} /* closing brace for extern "C" */
-#endif
-
diff --git a/src/md.h b/src/md.h
index 4c24531..fa2f680 100644
--- a/src/md.h
+++ b/src/md.h
@@ -245,10 +245,12 @@ struct mdp_superblock_1 {
uint16_t dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
};
+#if 0
static inline uint64_t md_event(mdp_super_t *sb) {
uint64_t ev = sb->events_hi;
return (ev<<32)| sb->events_lo;
}
+#endif
/* TestDisk */
int check_MD(disk_t *disk_car,partition_t *partition,const int verbose);
diff --git a/src/netware.h b/src/netware.h
index 8fb59c6..8e52679 100644
--- a/src/netware.h
+++ b/src/netware.h
@@ -23,14 +23,14 @@
extern "C" {
#endif
-typedef struct disk_netware
+struct disk_netware
{
char unknown;
char magic[12];
char unknown2[3];
char unknown3[3]; /* 0x10 */
int32_t nbr_sectors;
-} disk_netware;
+};
int check_netware(disk_t *disk_car, partition_t *partition);
int recover_netware(disk_t *disk_car, const struct disk_netware *netware_block, partition_t *partition);
diff --git a/src/ntfs.c b/src/ntfs.c
index e978523..fa69576 100644
--- a/src/ntfs.c
+++ b/src/ntfs.c
@@ -45,7 +45,6 @@
#include "log.h"
/* #include "guid_cmp.h" */
extern const arch_fnct_t arch_i386;
-extern const arch_fnct_t arch_mac;
static int set_NTFS_info(disk_t *disk_car, const struct ntfs_boot_sector*ntfs_header,partition_t *partition,const int verbose);
static int ntfs_read_MFT(disk_t *disk_car, partition_t *partition, const struct ntfs_boot_sector*ntfs_header, const int my_type, const int verbose);
diff --git a/src/ntfs.h b/src/ntfs.h
index bdcdc31..4dae58e 100644
--- a/src/ntfs.h
+++ b/src/ntfs.h
@@ -70,7 +70,6 @@ int test_NTFS(const disk_t *disk_car,const struct ntfs_boot_sector*ntfs_header,
unsigned int ntfs_sector_size(const struct ntfs_boot_sector *ntfs_header);
int rebuild_NTFS_BS(disk_t *disk_car,partition_t *partition, const int verbose, const int interface, const unsigned int expert, char**current_cmd);
int repair_MFT(disk_t *disk_car, partition_t *partition, const int verbose, const unsigned int expert);
-int repair_MFT_Vol(disk_t *disk_car, partition_t *partition, const int verbose);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/ntfs_udl.c b/src/ntfs_udl.c
index 3dc10e7..911a07d 100644
--- a/src/ntfs_udl.c
+++ b/src/ntfs_udl.c
@@ -938,7 +938,7 @@ static int undelete_file(ntfs_volume *vol, long long inode)
}
}
- cluster_count = 0LL;
+ cluster_count = (long long)0;
for (i = 0; rl[i].length > 0; i++) {
if (rl[i].lcn == LCN_RL_NOT_MAPPED) {
diff --git a/src/parti386.c b/src/parti386.c
index 7908412..ca538cb 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -265,7 +265,7 @@ static uint64_t get_start_sect(const struct partition_dos *p)
return read4_little_endian(p->start4);
}
-uint64_t get_nr_sects(const struct partition_dos *p)
+static uint64_t get_nr_sects(const struct partition_dos *p)
{
return read4_little_endian(p->size4);
}
@@ -281,7 +281,7 @@ static void set_start_sect(struct partition_dos *p, unsigned int start_sect)
}
-int get_geometry_from_i386mbr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
+static int get_geometry_from_i386mbr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
{
unsigned int i;
if(verbose>1)
@@ -628,7 +628,7 @@ static int test_MBR_over(disk_t *disk_car,list_part_t *list_part)
return res;
}
-int write_part_i386(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose, const int align)
+static int write_part_i386(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose, const int align)
{
int res=0;
res+=write_mbr_i386(disk_car,list_part,ro,verbose);
diff --git a/src/parti386n.c b/src/parti386n.c
index 8e4d5a6..abaf240 100644
--- a/src/parti386n.c
+++ b/src/parti386n.c
@@ -43,7 +43,6 @@ extern const arch_fnct_t arch_i386;
list_part_t *add_partition_i386_ncurses(disk_t *disk_car,list_part_t *list_part, char **current_cmd)
{
- int position=0;
CHS_t start,end;
partition_t *new_partition=partition_new(&arch_i386);
start.cylinder=0;
@@ -53,6 +52,7 @@ list_part_t *add_partition_i386_ncurses(disk_t *disk_car,list_part_t *list_part,
end.head=disk_car->geom.heads_per_cylinder-1;
end.sector=disk_car->geom.sectors_per_head;
{
+ int position=0;
int done = 0;
while (done==0)
{
diff --git a/src/partmac.c b/src/partmac.c
index 46040b8..23db660 100644
--- a/src/partmac.c
+++ b/src/partmac.c
@@ -111,7 +111,7 @@ static unsigned int get_part_type_mac(const partition_t *partition)
return partition->part_type_mac;
}
-list_part_t *read_part_mac(disk_t *disk_car, const int verbose, const int saveheader)
+static list_part_t *read_part_mac(disk_t *disk_car, const int verbose, const int saveheader)
{
unsigned char buffer[DEFAULT_SECTOR_SIZE];
list_part_t *new_list_part=NULL;
diff --git a/src/partnone.c b/src/partnone.c
index 621aeba..fe461bc 100644
--- a/src/partnone.c
+++ b/src/partnone.c
@@ -46,6 +46,7 @@
#include "ext2.h"
#include "fat.h"
#include "fatx.h"
+#include "iso9660.h"
#include "iso.h"
#include "hfs.h"
#include "hfsp.h"
@@ -151,7 +152,7 @@ static unsigned int get_part_type_none(const partition_t *partition)
return partition->upart_type;
}
-int get_geometry_from_nonembr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
+static int get_geometry_from_nonembr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
{
{
/* Ugly hack to get geometry from FAT and NTFS */
@@ -169,7 +170,7 @@ int get_geometry_from_nonembr(const unsigned char *buffer, const int verbose, CH
return 0;
}
-list_part_t *read_part_none(disk_t *disk_car, const int verbose, const int saveheader)
+static list_part_t *read_part_none(disk_t *disk_car, const int verbose, const int saveheader)
{
int insert_error=0;
unsigned char *buffer_disk;
@@ -373,7 +374,7 @@ static const char *get_partition_typename_none_aux(const unsigned int part_type_
return NULL;
}
-const char *get_partition_typename_none(const partition_t *partition)
+static const char *get_partition_typename_none(const partition_t *partition)
{
return get_partition_typename_none_aux(partition->upart_type);
}
diff --git a/src/partsun.c b/src/partsun.c
index 01a1e83..6545b56 100644
--- a/src/partsun.c
+++ b/src/partsun.c
@@ -117,7 +117,7 @@ static unsigned int get_part_type_sun(const partition_t *partition)
return partition->part_type_sun;
}
-int get_geometry_from_sunmbr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
+static int get_geometry_from_sunmbr(const unsigned char *buffer, const int verbose, CHSgeometry_t *geometry)
{
const sun_partition *sunlabel=(const sun_partition*)buffer;
if(verbose>1)
@@ -135,7 +135,7 @@ int get_geometry_from_sunmbr(const unsigned char *buffer, const int verbose, CHS
return 0;
}
-list_part_t *read_part_sun(disk_t *disk_car, const int verbose, const int saveheader)
+static list_part_t *read_part_sun(disk_t *disk_car, const int verbose, const int saveheader)
{
unsigned int i;
sun_partition *sunlabel;
diff --git a/src/partsunn.c b/src/partsunn.c
index c74c743..d6f0070 100644
--- a/src/partsunn.c
+++ b/src/partsunn.c
@@ -44,7 +44,6 @@ list_part_t *add_partition_sun_ncurses(disk_t *disk_car,list_part_t *list_part,
{
CHS_t start,end;
partition_t *new_partition=partition_new(&arch_sun);
- int position=0;
start.cylinder=0;
start.head=0;
start.sector=1;
@@ -52,6 +51,7 @@ list_part_t *add_partition_sun_ncurses(disk_t *disk_car,list_part_t *list_part,
end.head=disk_car->geom.heads_per_cylinder-1;
end.sector=disk_car->geom.sectors_per_head;
{
+ int position=0;
int done = FALSE;
while (done==FALSE) {
int command;
diff --git a/src/partxbox.c b/src/partxbox.c
index cf6f7f5..78e8d4b 100644
--- a/src/partxbox.c
+++ b/src/partxbox.c
@@ -90,7 +90,7 @@ static unsigned int get_part_type_xbox(const partition_t *partition)
return partition->part_type_xbox;
}
-list_part_t *read_part_xbox(disk_t *disk_car, const int verbose, const int saveheader)
+static list_part_t *read_part_xbox(disk_t *disk_car, const int verbose, const int saveheader)
{
unsigned char buffer[0x800];
list_part_t *new_list_part=NULL;
diff --git a/src/phmain.c b/src/phmain.c
index 3382980..226fdda 100644
--- a/src/phmain.c
+++ b/src/phmain.c
@@ -80,16 +80,14 @@
#include "pdisksel.h"
extern const arch_fnct_t arch_i386;
extern const arch_fnct_t arch_mac;
-extern const arch_fnct_t arch_none;
extern const arch_fnct_t arch_sun;
-extern const arch_fnct_t arch_xbox;
extern file_enable_t list_file_enable[];
#ifdef HAVE_SIGACTION
-struct sigaction action;
-void sighup_hdlr(int sig);
+static struct sigaction action;
+static void sighup_hdlr(int sig);
-void sighup_hdlr(int sig)
+static void sighup_hdlr(int sig)
{
if(sig == SIGINT)
log_critical("SIGINT detected! PhotoRec has been killed.\n");
diff --git a/src/photorec.c b/src/photorec.c
index 28cd99e..061be3b 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -499,16 +499,6 @@ partition_t *new_whole_disk(const disk_t *disk_car)
return fake_partition;
}
-
-typedef struct info_cluster_offset cluster_offset_t;
-
-struct info_cluster_offset
-{
- unsigned int cluster_size;
- unsigned long int offset;
- unsigned int nbr;
-};
-
unsigned int find_blocksize(alloc_data_t *list_search_space, const unsigned int default_blocksize, uint64_t *offset)
{
unsigned int blocksize=128*512;
diff --git a/src/photorec.h b/src/photorec.h
index 1789db7..085c62a 100644
--- a/src/photorec.h
+++ b/src/photorec.h
@@ -27,14 +27,6 @@ extern "C" {
enum photorec_status { STATUS_FIND_OFFSET, STATUS_UNFORMAT, STATUS_EXT2_ON, STATUS_EXT2_ON_BF, STATUS_EXT2_OFF, STATUS_EXT2_OFF_BF, STATUS_EXT2_ON_SAVE_EVERYTHING, STATUS_EXT2_OFF_SAVE_EVERYTHING, STATUS_QUIT };
typedef enum photorec_status photorec_status_t;
-typedef struct list_cluster_struct list_cluster_t;
-struct list_cluster_struct
-{
- struct td_list_head list;
- uint64_t offset;
- uint32_t cluster;
- file_data_t *dir_list;
-};
int get_prev_file_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset);
int file_finish(file_recovery_t *file_recovery, const char *recup_dir, const int paranoid, unsigned int *file_nbr,
@@ -43,7 +35,6 @@ int file_finish(file_recovery_t *file_recovery, const char *recup_dir, const int
alloc_data_t *file_finish2(file_recovery_t *file_recovery, const char *recup_dir, const int paranoid, unsigned int *file_nbr,
const unsigned int blocksize, alloc_data_t *list_search_space,
unsigned int *dir_num, const photorec_status_t status, const disk_t *disk);
-void reset_file_stats(file_stat_t *file_stats);
void write_stats_log(const file_stat_t *file_stats);
void write_stats_stdout(const file_stat_t *file_stats);
void update_stats(file_stat_t *file_stats, alloc_data_t *list_search_space);
diff --git a/src/phrecn.c b/src/phrecn.c
index dea4b88..3227e3d 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -125,26 +125,6 @@ static inline void file_recovery_cpy(file_recovery_t *dst, file_recovery_t *src)
dst->location.list.next=&dst->location.list;
}
-static inline void list_append_block(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const unsigned int data)
-{
- if(!td_list_empty(&list->list))
- {
- alloc_list_t *prev=td_list_entry(list->list.prev, alloc_list_t, list);
- if(prev->end+1==offset && prev->data==data)
- {
- prev->end=offset+blocksize-1;
- return ;
- }
- }
- {
- alloc_list_t *new_list=(alloc_list_t *)MALLOC(sizeof(*new_list));
- new_list->start=offset;
- new_list->end=offset+blocksize-1;
- new_list->data=data;
- td_list_add_tail(&new_list->list, &list->list);
- }
-}
-
/* ==================== INLINE FUNCTIONS ========================= */
#if defined(__CYGWIN__) || defined(__MINGW32__)
@@ -618,6 +598,26 @@ static void gen_image(const char *filename, disk_t *disk, const alloc_data_t *li
}
#if 0
+static inline void list_append_block(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const unsigned int data)
+{
+ if(!td_list_empty(&list->list))
+ {
+ alloc_list_t *prev=td_list_entry(list->list.prev, alloc_list_t, list);
+ if(prev->end+1==offset && prev->data==data)
+ {
+ prev->end=offset+blocksize-1;
+ return ;
+ }
+ }
+ {
+ alloc_list_t *new_list=(alloc_list_t *)MALLOC(sizeof(*new_list));
+ new_list->start=offset;
+ new_list->end=offset+blocksize-1;
+ new_list->data=data;
+ td_list_add_tail(&new_list->list, &list->list);
+ }
+}
+
static void test_files_aux(disk_t *disk, partition_t *partition, file_recovery_t *file_recovery, const char *recup_dir, const unsigned int dir_num, const uint64_t start, const uint64_t end)
{
uint64_t datasize=end-start+1;
diff --git a/src/rfs.h b/src/rfs.h
index 175419c..bccdb1a 100644
--- a/src/rfs.h
+++ b/src/rfs.h
@@ -76,7 +76,6 @@ struct reiserfs_super_block
#define REISERFS4_SUPER_MAGIC "ReIsEr4"
#define MAGIC_SIZE 16
-typedef struct reiser4_master_sb reiser4_master_sb;
struct reiser4_master_sb {
char magic[16]; /* "ReIsEr4" */
uint16_t disk_plugin_id; /* id of disk layout plugin */
diff --git a/src/savehdr.h b/src/savehdr.h
index 2210a5b..9b13a34 100644
--- a/src/savehdr.h
+++ b/src/savehdr.h
@@ -24,14 +24,13 @@ extern "C" {
#endif
#include "list.h"
-typedef struct backup_disk backup_disk_t;
-struct backup_disk
+typedef struct
{
struct td_list_head list;
time_t my_time;
char description[128];
list_part_t *list_part;
-};
+} backup_disk_t;
int save_header(disk_t *disk_car,partition_t *partition, const int verbose);
int partition_save(disk_t *disk_car, list_part_t *list_part, const int verbose);
diff --git a/src/sysv.h b/src/sysv.h
index ac2690f..5603d9f 100644
--- a/src/sysv.h
+++ b/src/sysv.h
@@ -36,7 +36,7 @@ typedef uint16_t sysv_ino_t;
significant 16 bits come last.
*/
-typedef uint32_t sysv_zone_t;
+/* typedef uint32_t sysv_zone_t; */
/* Among the blocks ... */
/* Xenix FS, Coherent FS: block 0 is the boot block, block 1 the super-block.
diff --git a/src/testdisk.c b/src/testdisk.c
index 125703b..a404fbc 100644
--- a/src/testdisk.c
+++ b/src/testdisk.c
@@ -71,10 +71,10 @@ extern const arch_fnct_t arch_mac;
extern const arch_fnct_t arch_sun;
#ifdef HAVE_SIGACTION
-struct sigaction action;
-void sighup_hdlr(int sig);
+static struct sigaction action;
+static void sighup_hdlr(int sig);
-void sighup_hdlr(int sig)
+static void sighup_hdlr(int sig)
{
if(sig == SIGINT)
log_critical("SIGINT detected! TestDisk has been killed.\n");
diff --git a/src/zfs.h b/src/zfs.h
index e7541cb..8d242ea 100644
--- a/src/zfs.h
+++ b/src/zfs.h
@@ -30,13 +30,13 @@ extern "C" {
#define VDEV_BOOT_VERSION 1 /* version number */
#define VDEV_BOOT_HEADER_SIZE (8 << 10)
-typedef struct vdev_boot_header {
+struct vdev_boot_header {
uint64_t vb_magic; /* VDEV_BOOT_MAGIC */
uint64_t vb_version; /* VDEV_BOOT_VERSION */
uint64_t vb_offset; /* start offset (bytes) */
uint64_t vb_size; /* size (bytes) */
char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (uint64_t)];
-} vdev_boot_header_t;
+};
int check_ZFS(disk_t *disk,partition_t *partition);
int recover_ZFS(disk_t *disk, const struct vdev_boot_header *ZFS_header,partition_t *partition,const int verbose, const int dump_ind);
#ifdef __cplusplus