mirror of
https://github.com/linux-sunxi/sunxi-tools.git
synced 2024-11-23 01:46:44 +08:00
script_extractor: Remove unnecessary size argument
The script_extractor tool before this commit used to take a size argument on the cmdline, but the passed in size was only used in some places not in others. Leading to a segfault if the passed in argument was not exactly the same as SCRIPT_SIZE. This commit drops the argument, so that script_extractor will just work. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
2d258a30d8
commit
55eec70cea
@ -21,26 +21,21 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SCRIPT_START 0x43000000
|
||||
#define SCRIPT_SIZE 0x20000
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(void) {
|
||||
char *addr;
|
||||
int fd;
|
||||
int i;
|
||||
int size;
|
||||
|
||||
fd = open("/dev/mem", O_RDONLY);
|
||||
|
||||
size = SCRIPT_SIZE;
|
||||
if (argc)
|
||||
size = atoi(argv[1]);
|
||||
|
||||
addr = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, SCRIPT_START);
|
||||
addr = (char *)mmap(NULL, SCRIPT_SIZE, PROT_READ, MAP_SHARED, fd, SCRIPT_START);
|
||||
for (i = 0; i < SCRIPT_SIZE; i++)
|
||||
putchar(addr[i]);
|
||||
munmap(NULL, SCRIPT_SIZE);
|
||||
munmap(addr, SCRIPT_SIZE);
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user