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:
Hans de Goede 2015-12-08 13:01:45 +01:00
parent 2d258a30d8
commit 55eec70cea

View File

@ -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;