summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/file_au.c2
-rw-r--r--src/file_hdf.c4
-rw-r--r--src/file_jpg.c4
-rw-r--r--src/file_lxo.c7
-rw-r--r--src/file_lzh.c7
-rw-r--r--src/file_mid.c4
-rw-r--r--src/file_par2.c2
-rw-r--r--src/file_pdf.c4
-rw-r--r--src/file_r3d.c2
-rw-r--r--src/file_raf.c6
-rw-r--r--src/file_sig.c2
-rw-r--r--src/file_ttf.c2
-rw-r--r--src/file_woff.c13
-rw-r--r--src/filegen.h2
-rw-r--r--src/geometry.c2
-rw-r--r--src/ntfs_dir.c2
-rw-r--r--src/texfat.c19
-rw-r--r--src/xfs.c6
18 files changed, 47 insertions, 43 deletions
diff --git a/src/file_au.c b/src/file_au.c
index 7b8c35f..44edeb5 100644
--- a/src/file_au.c
+++ b/src/file_au.c
@@ -66,7 +66,7 @@ static int header_check_au(const unsigned char *buffer, const unsigned int buffe
{
const struct header_au_s *au=(const struct header_au_s *)buffer;
if(memcmp(buffer,au_header,sizeof(au_header))==0 &&
- be32(au->offset) >= sizeof(struct header_au_s) &&
+ (const uint32_t)be32(au->offset) >= sizeof(struct header_au_s) &&
be32(au->encoding)>0 && be32(au->encoding)<=27 &&
be32(au->channels)>0 && be32(au->channels)<=256)
{
diff --git a/src/file_hdf.c b/src/file_hdf.c
index a557667..fd02b68 100644
--- a/src/file_hdf.c
+++ b/src/file_hdf.c
@@ -74,6 +74,7 @@ static void file_check_hdf(file_recovery_t *file_recovery)
struct ddh_struct ddh;
const struct dd_struct *p;
unsigned int i;
+ unsigned int size;
if(
#ifdef HAVE_FSEEKO
fseeko(file_recovery->handle, offset, SEEK_SET) < 0 ||
@@ -93,7 +94,8 @@ static void file_check_hdf(file_recovery_t *file_recovery)
#ifdef DEBUG_HDF
log_info("size=%u next=%lu\n", be16(ddh.size), be32(ddh.next));
#endif
- for(i=0, p=dd; i < be16(ddh.size); i++,p++)
+ size=be16(ddh.size);
+ for(i=0, p=dd; i < size; i++,p++)
{
#ifdef DEBUG_HDF
log_info("tag=0x%04x, ref=%u, offset=%lu, length=%lu\n",
diff --git a/src/file_jpg.c b/src/file_jpg.c
index c192405..fcfafca 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -1299,7 +1299,7 @@ static void jpg_search_marker(file_recovery_t *file_recovery)
{
FILE* infile=file_recovery->handle;
unsigned char buffer[40*8192];
- int nbytes;
+ size_t nbytes;
uint64_t offset;
unsigned int i;
if(file_recovery->blocksize==0)
@@ -1350,7 +1350,7 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
FILE* infile=file_recovery->handle;
unsigned char buffer[40*8192];
uint64_t thumb_offset=0;
- int nbytes;
+ size_t nbytes;
file_recovery->extra=0;
#ifdef HAVE_FSEEKO
if(fseeko(infile, 0, SEEK_SET) < 0)
diff --git a/src/file_lxo.c b/src/file_lxo.c
index 532414c..d19493e 100644
--- a/src/file_lxo.c
+++ b/src/file_lxo.c
@@ -53,13 +53,14 @@ struct lxo_header
static int header_check_lxo(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)
{
const struct lxo_header *header=(const struct lxo_header *)buffer;
- if(be32(header->size) +8 < sizeof(struct lxo_header))
+ const uint64_t size=be32(header->size) + 8;
+ if(size < sizeof(struct lxo_header))
return 0;
if(buffer[8]=='L' && buffer[9]=='X' && buffer[10]=='O')
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_lxo.extension;
- file_recovery_new->calculated_file_size=be32(header->size)+8;
+ file_recovery_new->calculated_file_size=size;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->data_check=&data_check_size;
return 1;
@@ -68,7 +69,7 @@ static int header_check_lxo(const unsigned char *buffer, const unsigned int buff
{
reset_file_recovery(file_recovery_new);
file_recovery_new->extension="lwo";
- file_recovery_new->calculated_file_size=be32(header->size)+8;
+ file_recovery_new->calculated_file_size=size;
file_recovery_new->file_check=&file_check_size;
file_recovery_new->data_check=&data_check_size;
return 1;
diff --git a/src/file_lzh.c b/src/file_lzh.c
index 669b2b2..86b6f56 100644
--- a/src/file_lzh.c
+++ b/src/file_lzh.c
@@ -90,7 +90,7 @@ static void file_rename_level0(const char *old_filename)
{
unsigned char buffer[512];
FILE *file;
- int buffer_size;
+ size_t buffer_size;
unsigned int i;
const struct lzh_level0 *hdr=(const struct lzh_level0 *)&buffer;
if((file=fopen(old_filename, "rb"))==NULL)
@@ -118,7 +118,6 @@ static int header_check_lzh(const unsigned char *buffer, const unsigned int buff
file_recovery_new->file_rename=&file_rename_level0;
return 1;
}
- break;
/* Level 1 */
case 1:
{
@@ -129,16 +128,14 @@ static int header_check_lzh(const unsigned char *buffer, const unsigned int buff
file_recovery_new->extension=file_hint_lzh.extension;
return 1;
}
- break;
/* Level 2 */
case 2:
{
-// const struct lzh_level2 *hdr=(const struct lzh_level2 *)buffer;
+ // const struct lzh_level2 *hdr=(const struct lzh_level2 *)buffer;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_lzh.extension;
return 1;
}
- break;
}
return 0;
}
diff --git a/src/file_mid.c b/src/file_mid.c
index 2c45861..2ea72d6 100644
--- a/src/file_mid.c
+++ b/src/file_mid.c
@@ -60,6 +60,7 @@ static void file_check_midi(file_recovery_t *file_recovery)
const uint64_t fs_org=file_recovery->file_size;
struct midi_header hdr;
unsigned int i;
+ unsigned int tracks;
uint64_t fs=4+4+6;
file_recovery->file_size=0;
if(
@@ -70,7 +71,8 @@ static void file_check_midi(file_recovery_t *file_recovery)
#endif
fread(&hdr, sizeof(hdr), 1, file_recovery->handle) != 1)
return ;
- for(i=0; i<be16(hdr.tracks); i++)
+ tracks=be16(hdr.tracks);
+ for(i=0; i<tracks; i++)
{
struct midi_header track;
#ifdef DEBUG_MIDI
diff --git a/src/file_par2.c b/src/file_par2.c
index 67ce70b..a82fb39 100644
--- a/src/file_par2.c
+++ b/src/file_par2.c
@@ -73,7 +73,7 @@ static void file_rename_par2(const char *old_filename)
while(1)
{
uint64_t length;
- int buffer_size;
+ size_t buffer_size;
unsigned char buffer[4096];
const uint64_t *lengthp=(const uint64_t *)&buffer[8];
#ifdef HAVE_FSEEKO
diff --git a/src/file_pdf.c b/src/file_pdf.c
index 509b0a1..c48d455 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -72,7 +72,7 @@ static void file_rename_pdf(const char *old_filename)
unsigned char*buffer;
unsigned int i;
unsigned int j;
- int bsize;
+ size_t bsize;
const unsigned char utf16[3]= { 0xfe, 0xff, 0x00};
if((handle=fopen(old_filename, "rb"))==NULL)
return;
@@ -129,7 +129,7 @@ static void file_rename_pdf(const char *old_filename)
}
if(buffer[i]=='<')
{
- int s=i;
+ unsigned int s=i;
/* hexa to ascii */
j=s;
buffer[j++]='(';
diff --git a/src/file_r3d.c b/src/file_r3d.c
index c0f4265..a39c47a 100644
--- a/src/file_r3d.c
+++ b/src/file_r3d.c
@@ -129,7 +129,7 @@ static void file_rename_r3d(const char *old_filename)
{
unsigned char buffer[512];
FILE *file;
- int buffer_size;
+ size_t buffer_size;
unsigned int i;
if((file=fopen(old_filename, "rb"))==NULL)
return;
diff --git a/src/file_raf.c b/src/file_raf.c
index 1b455cf..efff456 100644
--- a/src/file_raf.c
+++ b/src/file_raf.c
@@ -67,11 +67,11 @@ static int header_check_raf(const unsigned char *buffer, const unsigned int buff
uint64_t tmp;
const struct header_raf *raf=(const struct header_raf *)buffer;
uint64_t size;
- if(be32(raf->jpg_offset)!=0 && be32(raf->jpg_offset)<sizeof(struct header_raf))
+ if((const uint32_t)be32(raf->jpg_offset)!=0 && (const uint32_t)be32(raf->jpg_offset)<sizeof(struct header_raf))
return 0;
- if(be32(raf->cfa_offset)!=0 && be32(raf->cfa_offset)<sizeof(struct header_raf))
+ if((const uint32_t)be32(raf->cfa_offset)!=0 && (const uint32_t)be32(raf->cfa_offset)<sizeof(struct header_raf))
return 0;
- if(be32(raf->cfa_header_offset)!=0 && be32(raf->cfa_header_offset)<sizeof(struct header_raf))
+ if((const uint32_t)be32(raf->cfa_header_offset)!=0 && (const uint32_t)be32(raf->cfa_header_offset)<sizeof(struct header_raf))
return 0;
size=(uint64_t)be32(raf->jpg_offset)+be32(raf->jpg_size);
tmp=(uint64_t)be32(raf->cfa_offset)+be32(raf->cfa_size);
diff --git a/src/file_sig.c b/src/file_sig.c
index 820390d..565ebd7 100644
--- a/src/file_sig.c
+++ b/src/file_sig.c
@@ -388,7 +388,7 @@ static void register_header_check_sig(file_stat_t *file_stat)
{
char *pos;
char *buffer;
- off_t buffer_size;
+ size_t buffer_size;
struct stat stat_rec;
FILE *handle;
handle=open_signature_file();
diff --git a/src/file_ttf.c b/src/file_ttf.c
index 97265af..bb15717 100644
--- a/src/file_ttf.c
+++ b/src/file_ttf.c
@@ -91,7 +91,7 @@ static int header_check_ttf(const unsigned char *buffer, const unsigned int buff
* entrySelector Log2(maximum power of 2 <= numTables).
* rangeShift NumTables x 16-searchRange.
* */
- if(td_ilog2(numTables) != be16(ttf->entrySelector))
+ if(td_ilog2(numTables) != (uint16_t)be16(ttf->entrySelector))
return 0;
if((16<<be16(ttf->entrySelector)) != be16(ttf->searchRange))
return 0;
diff --git a/src/file_woff.c b/src/file_woff.c
index b267eb6..f40e04b 100644
--- a/src/file_woff.c
+++ b/src/file_woff.c
@@ -63,20 +63,21 @@ struct WOFFHeader
static int header_check_woff(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)
{
const struct WOFFHeader *woff=(const struct WOFFHeader *)buffer;
- if(be32(woff->length) < sizeof(struct WOFFHeader))
+ const uint64_t length=(uint64_t)be32(woff->length);
+ if((uint32_t)be32(woff->length) < sizeof(struct WOFFHeader))
return 0;
- if(be32(woff->metaOffset) > 0 && be32(woff->metaOffset) < sizeof(struct WOFFHeader))
+ if((uint32_t)be32(woff->metaOffset) > 0 && (uint32_t)be32(woff->metaOffset) < sizeof(struct WOFFHeader))
return 0;
- if(be32(woff->privOffset) > 0 && be32(woff->privOffset) < sizeof(struct WOFFHeader))
+ if((uint32_t)be32(woff->privOffset) > 0 && (uint32_t)be32(woff->privOffset) < sizeof(struct WOFFHeader))
return 0;
- if(be32(woff->metaOffset) + be32(woff->metaLength)> be32(woff->length) ||
- be32(woff->privOffset) + be32(woff->privLength)> be32(woff->length))
+ if((uint64_t)be32(woff->metaOffset) + (uint64_t)be32(woff->metaLength) > length ||
+ (uint64_t)be32(woff->privOffset) + (uint64_t)be32(woff->privLength) > length)
return 0;
if(woff->reserved!=0)
return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_woff.extension;
- file_recovery_new->calculated_file_size=(uint64_t)be32(woff->length);
+ file_recovery_new->calculated_file_size=length;
file_recovery_new->data_check=&data_check_size;
file_recovery_new->file_check=&file_check_size;
return 1;
diff --git a/src/filegen.h b/src/filegen.h
index 2f243da..c601400 100644
--- a/src/filegen.h
+++ b/src/filegen.h
@@ -95,7 +95,7 @@ struct file_hint_struct
/* needed by tar header */
const uint64_t max_filesize;
const int recover;
- const int enable_by_default;
+ const unsigned int enable_by_default;
void (*register_header_check)(file_stat_t *file_stat);
};
diff --git a/src/geometry.c b/src/geometry.c
index 3a605db..e2becc2 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -38,7 +38,7 @@
#include "geometry.h"
#include "autoset.h"
-#define MAX_HEADS 255u
+#define MAX_HEADS 255
void set_cylinders_from_size_up(disk_t *disk_car)
{
diff --git a/src/ntfs_dir.c b/src/ntfs_dir.c
index 4feec1e..4a623b1 100644
--- a/src/ntfs_dir.c
+++ b/src/ntfs_dir.c
@@ -134,7 +134,7 @@ static int index_get_size(ntfs_inode *inode)
}
#ifdef HAVE_ICONV
-static int ntfs_ucstoutf8(iconv_t cd, const ntfschar *ins, int ins_len, char **outs, int outs_len)
+static int ntfs_ucstoutf8(iconv_t cd, const ntfschar *ins, const int ins_len, char **outs, const int outs_len)
{
const char *inp;
char *outp;
diff --git a/src/texfat.c b/src/texfat.c
index 2f890e0..5b94247 100644
--- a/src/texfat.c
+++ b/src/texfat.c
@@ -79,6 +79,7 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
unsigned char *buffer_backup_bs;
const char *options="";
int rescan=1;
+ const int size_bs=12 * disk->sector_size;
#ifdef HAVE_NCURSES
const struct MenuItem menu_exFAT[]=
{
@@ -91,8 +92,8 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
{ 0, NULL, NULL }
};
#endif
- buffer_bs=(unsigned char*)MALLOC(12 * disk->sector_size);
- buffer_backup_bs=(unsigned char*)MALLOC(12 * disk->sector_size);
+ buffer_bs=(unsigned char*)MALLOC(size_bs);
+ buffer_backup_bs=(unsigned char*)MALLOC(size_bs);
while(1)
{
@@ -118,10 +119,10 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
log_info("\nexFAT_boot_sector\n");
log_partition(disk,partition);
screen_buffer_add("Boot sector\n");
- if(disk->pread(disk, buffer_bs, 12 * disk->sector_size, partition->part_offset) != 12 * disk->sector_size)
+ if(disk->pread(disk, buffer_bs, size_bs, partition->part_offset) != size_bs)
{
screen_buffer_add("Bad: can't read exFAT boot record.\n");
- memset(buffer_bs,0,12 * disk->sector_size);
+ memset(buffer_bs,0,size_bs);
}
else if(test_EXFAT((const struct exfat_super_block*)buffer_bs, partition)==0)
{
@@ -132,10 +133,10 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
else
screen_buffer_add("Bad\n");
screen_buffer_add("\nBackup boot record\n");
- if(disk->pread(disk, buffer_backup_bs, 12 * disk->sector_size, partition->part_offset + 12 * disk->sector_size) != 12 * disk->sector_size)
+ if(disk->pread(disk, buffer_backup_bs, size_bs, partition->part_offset + size_bs) != size_bs)
{
screen_buffer_add("Bad: can't read exFAT backup boot record.\n");
- memset(buffer_backup_bs,0,12 * disk->sector_size);
+ memset(buffer_backup_bs,0,size_bs);
}
else if(test_EXFAT((const struct exfat_super_block*)buffer_backup_bs, partition)==0)
{
@@ -146,7 +147,7 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
else
screen_buffer_add("Bad\n");
screen_buffer_add("\n");
- if(memcmp(buffer_bs,buffer_backup_bs,12 * disk->sector_size)==0)
+ if(memcmp(buffer_bs, buffer_backup_bs, size_bs)==0)
{
screen_buffer_add("Sectors are identical.\n");
opt_over=0;
@@ -210,7 +211,7 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
if(ask_confirmation("Copy original exFAT boot record over backup, confirm ? (Y/N)")!=0)
{
log_info("copy original superblock over backup boot\n");
- if(disk->pwrite(disk, buffer_bs, 12 * disk->sector_size, partition->part_offset + 12 * disk->sector_size) != 12 * disk->sector_size)
+ if(disk->pwrite(disk, buffer_bs, size_bs, partition->part_offset + size_bs) != size_bs)
{
display_message("Write error: Can't overwrite exFAT backup boot record\n");
}
@@ -226,7 +227,7 @@ int exFAT_boot_sector(disk_t *disk, partition_t *partition, const int verbose, c
log_info("copy backup superblock over main superblock\n");
/* Reset information about backup boot record */
partition->sb_offset=0;
- if(disk->pwrite(disk, buffer_backup_bs, 12 * disk->sector_size, partition->part_offset) != 12 * disk->sector_size)
+ if(disk->pwrite(disk, buffer_backup_bs, size_bs, partition->part_offset) != size_bs)
{
display_message("Write error: Can't overwrite exFAT main boot record\n");
}
diff --git a/src/xfs.c b/src/xfs.c
index 59e4f3f..a5c2e87 100644
--- a/src/xfs.c
+++ b/src/xfs.c
@@ -62,9 +62,9 @@ int check_xfs(disk_t *disk_car,partition_t *partition,const int verbose)
static int test_xfs(const disk_t *disk_car, const struct xfs_sb *sb, partition_t *partition, const int verbose)
{
if(sb->sb_magicnum!=be32(XFS_SB_MAGIC) ||
- be16(sb->sb_sectsize) != (1U << sb->sb_sectlog) ||
- be32(sb->sb_blocksize) != (1U << sb->sb_blocklog) ||
- be16(sb->sb_inodesize) != (1U << sb->sb_inodelog))
+ (uint16_t)be16(sb->sb_sectsize) != (1U << sb->sb_sectlog) ||
+ (uint32_t)be32(sb->sb_blocksize) != (1U << sb->sb_blocklog) ||
+ (uint16_t)be16(sb->sb_inodesize) != (1U << sb->sb_inodelog))
return 1;
switch(be16(sb->sb_versionnum) & XFS_SB_VERSION_NUMBITS)
{