mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
Fix compiler warnings (-Wconversion)
This commit is contained in:
@@ -510,8 +510,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
char * buffer;
|
||||
off_t filesize = lseek(fileno(fd), 0, SEEK_END);
|
||||
lseek(fileno(fd), 0, SEEK_SET);
|
||||
buffer =(char *) malloc(filesize+1);
|
||||
fread(buffer, filesize, 1, fd);
|
||||
buffer =(char *) malloc((uint32_t)filesize+1);
|
||||
fread(buffer, (uint32_t)filesize, 1, fd);
|
||||
fclose(fd);
|
||||
buffer[filesize] = 0;
|
||||
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
|
||||
|
@@ -233,11 +233,11 @@ bool CExtUpdate::applySettings()
|
||||
return ErrorReset(0, "error system mtd not found");
|
||||
|
||||
#ifdef BOXMODEL_APOLLO
|
||||
int mtdSize = 65536*1024; // FIXME hack, mtd size more than free RAM
|
||||
uint64_t mtdSize = 65536*1024; // FIXME hack, mtd size more than free RAM
|
||||
#else
|
||||
int mtdSize = mtdInfo->getMTDSize(mtdFilename);
|
||||
uint64_t mtdSize = mtdInfo->getMTDSize(mtdFilename);
|
||||
#endif
|
||||
int mtdEraseSize = mtdInfo->getMTDEraseSize(mtdFilename);
|
||||
uint64_t mtdEraseSize = mtdInfo->getMTDEraseSize(mtdFilename);
|
||||
mtdNumber = mtdInfo->findMTDNumber(mtdFilename);
|
||||
|
||||
// get osrelease
|
||||
@@ -259,8 +259,8 @@ bool CExtUpdate::applySettings()
|
||||
if ( !file_exists(mtdramDriver.c_str()) )
|
||||
return ErrorReset(0, "no mtdram driver available");
|
||||
// load mtdram driver
|
||||
snprintf(buf1, sizeof(buf1), "total_size=%d", mtdSize/1024);
|
||||
snprintf(buf2, sizeof(buf2), "erase_size=%d", mtdEraseSize/1024);
|
||||
snprintf(buf1, sizeof(buf1), "total_size=%llu", mtdSize/1024);
|
||||
snprintf(buf2, sizeof(buf2), "erase_size=%llu", mtdEraseSize/1024);
|
||||
my_system(4, "insmod", mtdramDriver.c_str(), buf1, buf2);
|
||||
// check if mtdram driver is now loaded
|
||||
if (!isMtdramLoad())
|
||||
@@ -272,7 +272,8 @@ bool CExtUpdate::applySettings()
|
||||
|
||||
// find mtdram device
|
||||
std::string mtdRamFilename = "", mtdBlockFileName = "";
|
||||
int mtdRamSize = 0, mtdRamEraseSize = 0, mtdRamNr = 0;
|
||||
uint64_t mtdRamSize = 0, mtdRamEraseSize = 0;
|
||||
int mtdRamNr = 0;
|
||||
f1 = fopen("/proc/mtd", "r");
|
||||
if(!f1)
|
||||
return ErrorReset(RESET_UNLOAD, "cannot read /proc/mtd");
|
||||
@@ -280,7 +281,10 @@ bool CExtUpdate::applySettings()
|
||||
while(!feof(f1)) {
|
||||
if(fgets(buf1, sizeof(buf1), f1)!=NULL) {
|
||||
char dummy[50] = "";
|
||||
sscanf(buf1, "mtd%1d: %8x %8x \"%48s\"\n", &mtdRamNr, &mtdRamSize, &mtdRamEraseSize, dummy);
|
||||
uint32_t tmp1, tmp2;
|
||||
sscanf(buf1, "mtd%1d: %8x %8x \"%48s\"\n", &mtdRamNr, &tmp1, &tmp2, dummy);
|
||||
mtdRamSize = (uint64_t)tmp1;
|
||||
mtdRamEraseSize = (uint64_t)tmp2;
|
||||
if (strstr(buf1, "mtdram test device") != NULL) {
|
||||
sprintf(buf1, "/dev/mtd%d", mtdRamNr);
|
||||
mtdRamFilename = buf1;
|
||||
@@ -297,7 +301,7 @@ bool CExtUpdate::applySettings()
|
||||
else {
|
||||
// check mtdRamSize / mtdRamEraseSize
|
||||
if ((mtdRamSize != mtdSize) || (mtdRamEraseSize != mtdEraseSize)) {
|
||||
snprintf(buf2, sizeof(buf2), "error MTDSize(%08x/%08x) or MTDEraseSize(%08x/%08x)\n", mtdSize, mtdRamSize, mtdEraseSize, mtdRamEraseSize);
|
||||
snprintf(buf2, sizeof(buf2), "error MTDSize(%08llx/%08llx) or MTDEraseSize(%08llx/%08llx)\n", mtdSize, mtdRamSize, mtdEraseSize, mtdRamEraseSize);
|
||||
return ErrorReset(RESET_UNLOAD, buf2);
|
||||
}
|
||||
}
|
||||
@@ -310,7 +314,7 @@ bool CExtUpdate::applySettings()
|
||||
fd1 = open(imgFilename.c_str(), O_RDONLY);
|
||||
if (fd1 < 0)
|
||||
return ErrorReset(RESET_UNLOAD | DELETE_MTDBUF, "cannot read image file: " + imgFilename);
|
||||
long filesize = lseek(fd1, 0, SEEK_END);
|
||||
uint64_t filesize = (uint64_t)lseek(fd1, 0, SEEK_END);
|
||||
lseek(fd1, 0, SEEK_SET);
|
||||
if(filesize == 0)
|
||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "image filesize is 0");
|
||||
@@ -327,11 +331,11 @@ bool CExtUpdate::applySettings()
|
||||
}
|
||||
if (fd2 < 0)
|
||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open mtdBlock");
|
||||
long fsize = filesize;
|
||||
long block;
|
||||
uint64_t fsize = filesize;
|
||||
uint32_t block;
|
||||
while(fsize > 0) {
|
||||
block = fsize;
|
||||
if(block > (long)MTDBufSize)
|
||||
block = (uint32_t)fsize;
|
||||
if(block > (uint32_t)MTDBufSize)
|
||||
block = MTDBufSize;
|
||||
read(fd1, MTDBuf, block);
|
||||
write(fd2, MTDBuf, block);
|
||||
@@ -374,15 +378,15 @@ bool CExtUpdate::applySettings()
|
||||
if (fd2 < 0)
|
||||
return ErrorReset(RESET_UNLOAD | CLOSE_FD1 | DELETE_MTDBUF, "cannot open image file: ", imgFilename);
|
||||
while(fsize > 0) {
|
||||
block = fsize;
|
||||
if(block > (long)MTDBufSize)
|
||||
block = (uint32_t)fsize;
|
||||
if(block > (uint32_t)MTDBufSize)
|
||||
block = MTDBufSize;
|
||||
read(fd1, MTDBuf, block);
|
||||
write(fd2, MTDBuf, block);
|
||||
fsize -= block;
|
||||
}
|
||||
lseek(fd2, 0, SEEK_SET);
|
||||
long fsizeDst = lseek(fd2, 0, SEEK_END);
|
||||
uint64_t fsizeDst = (uint64_t)lseek(fd2, 0, SEEK_END);
|
||||
close(fd1);
|
||||
close(fd2);
|
||||
// check image file size
|
||||
|
@@ -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