diff mbox series

[RFC/PoC,2/3] change size type from int to int64_t on load_image()

Message ID 1541674784-25936-3-git-send-email-lizhijian@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series support initrd size up to 4G | expand

Commit Message

Li Zhijian Nov. 8, 2018, 10:59 a.m. UTC
allow load_image to load >= 2G file

CC: Philip Li <philip.li@intel.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 hw/core/loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Peter Maydell Nov. 8, 2018, 11:04 a.m. UTC | #1
On 8 November 2018 at 10:59, Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
> allow load_image to load >= 2G file
>
> CC: Philip Li <philip.li@intel.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> ---
>  hw/core/loader.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index aa0b3fc..8fbc4bd 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -77,7 +77,8 @@ int64_t get_image_size(const char *filename)
>  /* deprecated, because caller does not specify buffer size! */
>  int load_image(const char *filename, uint8_t *addr)
>  {
> -    int fd, size;
> +    int fd;
> +    int64_t size;
>      fd = open(filename, O_RDONLY | O_BINARY);
>      if (fd < 0)
>          return -1;

This function returns "size", so changing the type of "size"
without also changing its return type looks wrong.

load_image_size() uses ssize_t here, which may be what we want.

thanks
-- PMM
Li Zhijian Nov. 9, 2018, 2:48 a.m. UTC | #2
On 11/08/2018 07:04 PM, Peter Maydell wrote:
> On 8 November 2018 at 10:59, Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
>> allow load_image to load >= 2G file
>>
>> CC: Philip Li <philip.li@intel.com>
>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>> ---
>>   hw/core/loader.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/core/loader.c b/hw/core/loader.c
>> index aa0b3fc..8fbc4bd 100644
>> --- a/hw/core/loader.c
>> +++ b/hw/core/loader.c
>> @@ -77,7 +77,8 @@ int64_t get_image_size(const char *filename)
>>   /* deprecated, because caller does not specify buffer size! */
>>   int load_image(const char *filename, uint8_t *addr)
>>   {
>> -    int fd, size;
>> +    int fd;
>> +    int64_t size;
>>       fd = open(filename, O_RDONLY | O_BINARY);
>>       if (fd < 0)
>>           return -1;
> This function returns "size", so changing the type of "size"
> without also changing its return type looks wrong.
>
> load_image_size() uses ssize_t here, which may be what we want.

will change to ssize_t at next version

Thanks
Zhijian

>
> thanks
> -- PMM
>
>
>
diff mbox series

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index aa0b3fc..8fbc4bd 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -77,7 +77,8 @@  int64_t get_image_size(const char *filename)
 /* deprecated, because caller does not specify buffer size! */
 int load_image(const char *filename, uint8_t *addr)
 {
-    int fd, size;
+    int fd;
+    int64_t size;
     fd = open(filename, O_RDONLY | O_BINARY);
     if (fd < 0)
         return -1;