Use size_t for blob lengths in utilfdt_read*

It's more appropriate than off_t since it is, after all, a size not an
offset.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
David Gibson 2018-03-17 14:53:23 +11:00
parent 0112fda03b
commit fb9c6abdda
4 changed files with 7 additions and 7 deletions

View file

@ -181,7 +181,7 @@ int main(int argc, char *argv[])
char *buf; char *buf;
bool debug = false; bool debug = false;
bool scan = false; bool scan = false;
off_t len; size_t len;
fprintf(stderr, "\n" fprintf(stderr, "\n"
"**** fdtdump is a low-level debugging tool, not meant for general use.\n" "**** fdtdump is a low-level debugging tool, not meant for general use.\n"

View file

@ -60,7 +60,7 @@ static int do_fdtoverlay(const char *input_filename,
{ {
char *blob = NULL; char *blob = NULL;
char **ovblob = NULL; char **ovblob = NULL;
off_t blob_len, ov_len, total_len; size_t blob_len, ov_len, total_len;
int i, ret = -1; int i, ret = -1;
blob = utilfdt_read(input_filename, &blob_len); blob = utilfdt_read(input_filename, &blob_len);

6
util.c
View file

@ -227,11 +227,11 @@ char get_escape_char(const char *s, int *i)
return val; return val;
} }
int utilfdt_read_err(const char *filename, char **buffp, off_t *len) int utilfdt_read_err(const char *filename, char **buffp, size_t *len)
{ {
int fd = 0; /* assume stdin */ int fd = 0; /* assume stdin */
char *buf = NULL; char *buf = NULL;
off_t bufsize = 1024, offset = 0; size_t bufsize = 1024, offset = 0;
int ret = 0; int ret = 0;
*buffp = NULL; *buffp = NULL;
@ -269,7 +269,7 @@ int utilfdt_read_err(const char *filename, char **buffp, off_t *len)
return ret; return ret;
} }
char *utilfdt_read(const char *filename, off_t *len) char *utilfdt_read(const char *filename, size_t *len)
{ {
char *buff; char *buff;
int ret = utilfdt_read_err(filename, &buff, len); int ret = utilfdt_read_err(filename, &buff, len);

4
util.h
View file

@ -101,7 +101,7 @@ char get_escape_char(const char *s, int *i);
* @param len If non-NULL, the amount of data we managed to read * @param len If non-NULL, the amount of data we managed to read
* @return Pointer to allocated buffer containing fdt, or NULL on error * @return Pointer to allocated buffer containing fdt, or NULL on error
*/ */
char *utilfdt_read(const char *filename, off_t *len); char *utilfdt_read(const char *filename, size_t *len);
/** /**
* Read a device tree file into a buffer. Does not report errors, but only * Read a device tree file into a buffer. Does not report errors, but only
@ -113,7 +113,7 @@ char *utilfdt_read(const char *filename, off_t *len);
* @param len If non-NULL, the amount of data we managed to read * @param len If non-NULL, the amount of data we managed to read
* @return 0 if ok, else an errno value representing the error * @return 0 if ok, else an errno value representing the error
*/ */
int utilfdt_read_err(const char *filename, char **buffp, off_t *len); int utilfdt_read_err(const char *filename, char **buffp, size_t *len);
/** /**
* Write a device tree buffer to a file. This will report any errors on * Write a device tree buffer to a file. This will report any errors on