mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-03 02:41:21 +02:00
Fix compiler warnings (-Wconversion)
This commit is contained in:
@@ -178,12 +178,13 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
||||
bool skipCopy = false;
|
||||
#ifdef BOXMODEL_APOLLO
|
||||
if (strcmp(dn, "/tmp") != 0) {
|
||||
long btotal = 0, bused = 0, bsize = 0;
|
||||
uint64_t btotal = 0, bused = 0;
|
||||
long bsize = 0;
|
||||
if (get_fs_usage("/tmp", btotal, bused, &bsize)) {
|
||||
int fileSize = file_size(filename.c_str()) / 1024;
|
||||
int backupMaxSize = (int)((btotal - bused) * bsize);
|
||||
int res = 10; // Reserved 10% of available space
|
||||
backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100)) / 1024;
|
||||
uint64_t fileSize = (uint64_t)file_size(filename.c_str()) / 1024ULL;
|
||||
uint64_t backupMaxSize = (int)((btotal - bused) * bsize);
|
||||
uint64_t res = 10; // Reserved 10% of available space
|
||||
backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100ULL)) / 1024ULL;
|
||||
if (backupMaxSize < fileSize)
|
||||
skipCopy = true;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
||||
return false;
|
||||
}
|
||||
|
||||
filesize = lseek( fd1, 0, SEEK_END);
|
||||
filesize = (ssize_t)lseek( fd1, 0, SEEK_END);
|
||||
lseek( fd1, 0, SEEK_SET);
|
||||
|
||||
if(filesize==0) {
|
||||
@@ -424,7 +425,7 @@ bool CFlashTool::check_md5( const std::string & filename, const std::string & sm
|
||||
//printf("[flashtool] check file %s md5 %s\n", filename.c_str(), ptr);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
omd5[i] = FROMHEX(ptr[i*2])*16 + FROMHEX(ptr[i*2+1]);
|
||||
omd5[i] = (unsigned char)(FROMHEX(ptr[i*2])*16 + FROMHEX(ptr[i*2+1]));
|
||||
|
||||
md5_file(filename.c_str(), 1, md5);
|
||||
if(memcmp(md5, omd5, 16))
|
||||
|
@@ -374,7 +374,7 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t mode)
|
||||
return false;
|
||||
}
|
||||
|
||||
long block;
|
||||
uint32_t block;
|
||||
off64_t fsizeSrc64 = lseek64(fd1, 0, SEEK_END);
|
||||
lseek64(fd1, 0, SEEK_SET);
|
||||
if (fsizeSrc64 > 0x7FFFFFF0) { // > 2GB
|
||||
@@ -383,7 +383,7 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t mode)
|
||||
//printf("#####[%s] fsizeSrc64: %lld 0x%010llX - large file\n", __FUNCTION__, fsizeSrc64, fsizeSrc64);
|
||||
while(fsize64 > 0) {
|
||||
if(fsize64 < (off64_t)FileBufSize)
|
||||
block = (long)fsize64;
|
||||
block = (uint32_t)fsize64;
|
||||
read(fd1, FileBuf, block);
|
||||
write(fd2, FileBuf, block);
|
||||
fsize64 -= block;
|
||||
@@ -401,14 +401,14 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t mode)
|
||||
}
|
||||
}
|
||||
else { // < 2GB
|
||||
long fsizeSrc = lseek(fd1, 0, SEEK_END);
|
||||
off_t fsizeSrc = lseek(fd1, 0, SEEK_END);
|
||||
lseek(fd1, 0, SEEK_SET);
|
||||
long fsize = fsizeSrc;
|
||||
off_t fsize = fsizeSrc;
|
||||
block = FileBufSize;
|
||||
//printf("#####[%s] fsizeSrc: %ld 0x%08lX - normal file\n", __FUNCTION__, fsizeSrc, fsizeSrc);
|
||||
while(fsize > 0) {
|
||||
if(fsize < (long)FileBufSize)
|
||||
block = fsize;
|
||||
if(fsize < (off_t)FileBufSize)
|
||||
block = (uint32_t)fsize;
|
||||
read(fd1, FileBuf, block);
|
||||
write(fd2, FileBuf, block);
|
||||
fsize -= block;
|
||||
@@ -417,7 +417,7 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t mode)
|
||||
}
|
||||
if (doCopyFlag) {
|
||||
lseek(fd2, 0, SEEK_SET);
|
||||
long fsizeDst = lseek(fd2, 0, SEEK_END);
|
||||
off_t fsizeDst = lseek(fd2, 0, SEEK_END);
|
||||
if (fsizeSrc != fsizeDst){
|
||||
close(fd1);
|
||||
close(fd2);
|
||||
|
@@ -47,7 +47,7 @@ std::string trim(std::string &str, const std::string &trimChars = " \n\r\t");
|
||||
class CFileHelpers
|
||||
{
|
||||
private:
|
||||
int FileBufSize;
|
||||
unsigned long FileBufSize;
|
||||
char *FileBuf;
|
||||
int fd1, fd2;
|
||||
|
||||
|
Reference in New Issue
Block a user