diff mbox series

[v2,2/5] change load_image() reture type to ssize_t

Message ID 1542765966-20244-3-git-send-email-lizhijian@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/5] unify len and addr type for memory/address APIs | expand

Commit Message

Li Zhijian Nov. 21, 2018, 2:06 a.m. UTC
This patch allow load_iamge to load >=2G file

Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 hw/core/loader.c    | 5 +++--
 include/hw/loader.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Peter Maydell Nov. 30, 2018, 1:47 p.m. UTC | #1
On Wed, 21 Nov 2018 at 02:07, Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
>
> This patch allow load_iamge to load >=2G file
>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> ---
>  hw/core/loader.c    | 5 +++--
>  include/hw/loader.h | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index aa0b3fc..0d53229 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -75,9 +75,10 @@ int64_t get_image_size(const char *filename)
>
>  /* return the size or -1 if error */
>  /* deprecated, because caller does not specify buffer size! */
> -int load_image(const char *filename, uint8_t *addr)
> +ssize_t load_image(const char *filename, uint8_t *addr)
>  {
> -    int fd, size;
> +    int fd;
> +    ssize_t size;
>      fd = open(filename, O_RDONLY | O_BINARY);
>      if (fd < 0)
>          return -1;

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

As the comment says, we should ideally move all the callers
to load_image_size(), though...

thanks
-- PMM
Peter Maydell Nov. 30, 2018, 3:14 p.m. UTC | #2
On Fri, 30 Nov 2018 at 13:47, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Wed, 21 Nov 2018 at 02:07, Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
> >
> > This patch allow load_iamge to load >=2G file
> >
> > Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> > ---
> >  hw/core/loader.c    | 5 +++--
> >  include/hw/loader.h | 2 +-
> >  2 files changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/core/loader.c b/hw/core/loader.c
> > index aa0b3fc..0d53229 100644
> > --- a/hw/core/loader.c
> > +++ b/hw/core/loader.c
> > @@ -75,9 +75,10 @@ int64_t get_image_size(const char *filename)
> >
> >  /* return the size or -1 if error */
> >  /* deprecated, because caller does not specify buffer size! */
> > -int load_image(const char *filename, uint8_t *addr)
> > +ssize_t load_image(const char *filename, uint8_t *addr)
> >  {
> > -    int fd, size;
> > +    int fd;
> > +    ssize_t size;
> >      fd = open(filename, O_RDONLY | O_BINARY);
> >      if (fd < 0)
> >          return -1;
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> As the comment says, we should ideally move all the callers
> to load_image_size(), though...

I'm just about to send out a patchset which removes all the
load_image() callers; that would make patches 2 and 4 in this
set unnecessary.

thanks
-- PMM
Li Zhijian Dec. 3, 2018, 6:16 a.m. UTC | #3
On 11/30/2018 11:14 PM, Peter Maydell wrote:
> I'm just about to send out a patchset which removes all the
> load_image() callers; that would make patches 2 and 4 in this
> set unnecessary.

Got it, i will remove them at next version basing on your patch set.

Thanks
Zhijian
diff mbox series

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index aa0b3fc..0d53229 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -75,9 +75,10 @@  int64_t get_image_size(const char *filename)
 
 /* return the size or -1 if error */
 /* deprecated, because caller does not specify buffer size! */
-int load_image(const char *filename, uint8_t *addr)
+ssize_t load_image(const char *filename, uint8_t *addr)
 {
-    int fd, size;
+    int fd;
+    ssize_t size;
     fd = open(filename, O_RDONLY | O_BINARY);
     if (fd < 0)
         return -1;
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 67a0af8..49bb189 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -11,7 +11,7 @@ 
  * On error, errno is also set as appropriate.
  */
 int64_t get_image_size(const char *filename);
-int load_image(const char *filename, uint8_t *addr); /* deprecated */
+ssize_t load_image(const char *filename, uint8_t *addr); /* deprecated */
 ssize_t load_image_size(const char *filename, void *addr, size_t size);
 
 /**load_image_targphys_as: