Re: [PATCH 08/12] Use size_t for blob lengths in utilfdt_read*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Mar 30, 2018 at 04:42:44PM +0800, Simon Glass wrote:
> On 26 March 2018 at 07:25, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> wrote:
> > It's more appropriate that off_t since it is, after all, a size not an
> 
> s/that/than/ ?
> 
> > offset.
> >
> > Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
> > ---
> >  fdtdump.c    | 2 +-
> >  fdtoverlay.c | 2 +-
> >  util.c       | 6 +++---
> >  util.h       | 4 ++--
> >  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx>
> 
> Question below
> 
> >
> > diff --git a/fdtdump.c b/fdtdump.c
> > index d12eb35..98aa076 100644
> > --- a/fdtdump.c
> > +++ b/fdtdump.c
> > @@ -181,7 +181,7 @@ int main(int argc, char *argv[])
> >         char *buf;
> >         bool debug = false;
> >         bool scan = false;
> > -       off_t len;
> > +       size_t len;
> >
> >         fprintf(stderr, "\n"
> >  "**** fdtdump is a low-level debugging tool, not meant for general use.\n"
> > diff --git a/fdtoverlay.c b/fdtoverlay.c
> > index 2a2c89c..6b0154d 100644
> > --- a/fdtoverlay.c
> > +++ b/fdtoverlay.c
> > @@ -60,7 +60,7 @@ static int do_fdtoverlay(const char *input_filename,
> >  {
> >         char *blob = NULL;
> >         char **ovblob = NULL;
> > -       off_t blob_len, ov_len, total_len;
> > +       size_t blob_len, ov_len, total_len;
> >         int i, ret = -1;
> >
> >         blob = utilfdt_read(input_filename, &blob_len);
> > diff --git a/util.c b/util.c
> > index 0edd672..a69b7a1 100644
> > --- a/util.c
> > +++ b/util.c
> > @@ -227,11 +227,11 @@ char get_escape_char(const char *s, int *i)
> >         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 */
> >         char *buf = NULL;
> > -       off_t bufsize = 1024, offset = 0;
> > +       size_t bufsize = 1024, offset = 0;
> 
> Should offset remain off_t?

Hm, debatable, but probably not.  It's not passed to any syscall
interface that expect an off_t, and it's always strictly smaller that
bufsize.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux