mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
utilfdt_read: pass back up the length of data read
For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so pass that back if requested. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
f8cb5dd949
commit
cc2c178727
5 changed files with 12 additions and 8 deletions
8
util.c
8
util.c
|
@ -197,7 +197,7 @@ char get_escape_char(const char *s, int *i)
|
|||
return val;
|
||||
}
|
||||
|
||||
int utilfdt_read_err(const char *filename, char **buffp)
|
||||
int utilfdt_read_err(const char *filename, char **buffp, off_t *len)
|
||||
{
|
||||
int fd = 0; /* assume stdin */
|
||||
char *buf = NULL;
|
||||
|
@ -238,13 +238,15 @@ int utilfdt_read_err(const char *filename, char **buffp)
|
|||
free(buf);
|
||||
else
|
||||
*buffp = buf;
|
||||
if (len)
|
||||
*len = bufsize;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *utilfdt_read(const char *filename)
|
||||
char *utilfdt_read(const char *filename, off_t *len)
|
||||
{
|
||||
char *buff;
|
||||
int ret = utilfdt_read_err(filename, &buff);
|
||||
int ret = utilfdt_read_err(filename, &buff, len);
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue