mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
system/flashtool.cpp: use buffer on stack
This commit is contained in:
@@ -100,13 +100,7 @@ bool CFlashTool::readFromMTD( const std::string & filename, int globalProgressEn
|
|||||||
|
|
||||||
filesize = CMTDInfo::getInstance()->getMTDSize(mtdDevice);
|
filesize = CMTDInfo::getInstance()->getMTDSize(mtdDevice);
|
||||||
|
|
||||||
unsigned char * buf = new unsigned char[meminfo.writesize];
|
unsigned char buf[meminfo.writesize];
|
||||||
if (buf == NULL) {
|
|
||||||
printf("CFlashTool::program: mem alloc failed\n");
|
|
||||||
close(fd);
|
|
||||||
close(fd1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned mtdoffset = 0;
|
unsigned mtdoffset = 0;
|
||||||
long fsize = filesize;
|
long fsize = filesize;
|
||||||
while(fsize > 0) {
|
while(fsize > 0) {
|
||||||
@@ -149,7 +143,6 @@ bool CFlashTool::readFromMTD( const std::string & filename, int globalProgressEn
|
|||||||
if(statusViewer)
|
if(statusViewer)
|
||||||
statusViewer->showLocalStatus(100);
|
statusViewer->showLocalStatus(100);
|
||||||
|
|
||||||
delete[] buf;
|
|
||||||
close(fd);
|
close(fd);
|
||||||
close(fd1);
|
close(fd1);
|
||||||
return true;
|
return true;
|
||||||
@@ -210,13 +203,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
|||||||
if(statusViewer)
|
if(statusViewer)
|
||||||
globalProgressBegin = statusViewer->getGlobalStatus();
|
globalProgressBegin = statusViewer->getGlobalStatus();
|
||||||
|
|
||||||
unsigned char * buf = new unsigned char[meminfo.writesize];
|
unsigned char buf[meminfo.writesize];
|
||||||
if (buf == NULL) {
|
|
||||||
printf("CFlashTool::program: mem alloc failed\n");
|
|
||||||
close(fd);
|
|
||||||
close(fd1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
unsigned mtdoffset = 0;
|
unsigned mtdoffset = 0;
|
||||||
unsigned fsize = filesize;
|
unsigned fsize = filesize;
|
||||||
printf("CFlashTool::program: file %s write size %d, erase size %d\n", filename.c_str(), meminfo.writesize, meminfo.erasesize);
|
printf("CFlashTool::program: file %s write size %d, erase size %d\n", filename.c_str(), meminfo.writesize, meminfo.erasesize);
|
||||||
@@ -269,7 +256,6 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
|||||||
if(statusViewer)
|
if(statusViewer)
|
||||||
statusViewer->showLocalStatus(100);
|
statusViewer->showLocalStatus(100);
|
||||||
|
|
||||||
delete[] buf;
|
|
||||||
close(fd1);
|
close(fd1);
|
||||||
close(fd);
|
close(fd);
|
||||||
// FIXME error message
|
// FIXME error message
|
||||||
@@ -289,7 +275,7 @@ bool CFlashTool::getInfo()
|
|||||||
meminfo.writesize = 1024;
|
meminfo.writesize = 1024;
|
||||||
|
|
||||||
isnand = (meminfo.type == MTD_NANDFLASH);
|
isnand = (meminfo.type == MTD_NANDFLASH);
|
||||||
printf("CFlashTool::getInfo: NAND: %s\n", isnand ? "yes" : "no");
|
printf("CFlashTool::getInfo: NAND: %s writesize %d\n", isnand ? "yes" : "no", meminfo.writesize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user