diff mbox series

[2/2] Fix types mistmatch

Message ID CAJcrxChR3GPtT6yXEANyT1RONUSkp+Qy6q_4wQvaSe-O5qjG-Q@mail.gmail.com
State Changes Requested
Headers show
Series [1/2] Fix incorrect print type for size | expand

Commit Message

Roman Kalashnikov Oct. 20, 2017, 8:48 p.m. UTC
From: Roman Kalashnikov <lunix0x@gmail.com>

Signed-off-by: Roman Kalashnikov <lunix0x@gmail.com>
---
 archival/gun.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stefano Babic Oct. 20, 2017, 9:06 p.m. UTC | #1
Hi Roman,

On 20/10/2017 22:48, Roman Kalashnikov wrote:
> From: Roman Kalashnikov <lunix0x@gmail.com <mailto:lunix0x@gmail.com>>
> 
> Signed-off-by: Roman Kalashnikov <lunix0x@gmail.com
> <mailto:lunix0x@gmail.com>>
> ---
>  archival/gun.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/archival/gun.c b/archival/gun.c
> index ade0379..91dd134 100644
> --- a/archival/gun.c
> +++ b/archival/gun.c
> @@ -45,8 +45,8 @@ struct ind {
>      unsigned char *inbuf;
>      unsigned long *offs;
>      unsigned long *checksum;
> - int nbytes;
> - int total;
> + unsigned int nbytes;
> + unsigned int total;
>      int percent;
>      void *dgst;
>  };
> @@ -56,7 +56,7 @@ struct ind {
>     returns end-of-file or error. Return 0 on error. */
>  static unsigned in(void *in_desc, unsigned char **buf)
>  {
> - int ret;
> + unsigned int ret;

This seems wrong. The variable is also used to check the return value of
fill_buffer() some lines later. Forcing to unsign makes the return value
useless and an error in fill_buffer() is not detected anymoe.

Best regards,
Stefano Babic
Roman Kalashnikov Oct. 20, 2017, 9:13 p.m. UTC | #2
Yes, but also ret used for size arithmetic, so this lead to error when i'm 
trying to install file bigger than 2147483648 bytes.

суббота, 21 октября 2017 г., 0:06:48 UTC+3 пользователь Stefano Babic 
написал:
>
> Hi Roman, 
>
> On 20/10/2017 22:48, Roman Kalashnikov wrote: 
> > From: Roman Kalashnikov <lun...@gmail.com <javascript:> <mailto:
> lun...@gmail.com <javascript:>>> 
> > 
> > Signed-off-by: Roman Kalashnikov <lun...@gmail.com <javascript:> 
> > <mailto:lun...@gmail.com <javascript:>>> 
> > --- 
> >  archival/gun.c | 6 +++--- 
> >  1 file changed, 3 insertions(+), 3 deletions(-) 
> > 
> > diff --git a/archival/gun.c b/archival/gun.c 
> > index ade0379..91dd134 100644 
> > --- a/archival/gun.c 
> > +++ b/archival/gun.c 
> > @@ -45,8 +45,8 @@ struct ind { 
> >      unsigned char *inbuf; 
> >      unsigned long *offs; 
> >      unsigned long *checksum; 
> > - int nbytes; 
> > - int total; 
> > + unsigned int nbytes; 
> > + unsigned int total; 
> >      int percent; 
> >      void *dgst; 
> >  }; 
> > @@ -56,7 +56,7 @@ struct ind { 
> >     returns end-of-file or error. Return 0 on error. */ 
> >  static unsigned in(void *in_desc, unsigned char **buf) 
> >  { 
> > - int ret; 
> > + unsigned int ret; 
>
> This seems wrong. The variable is also used to check the return value of 
> fill_buffer() some lines later. Forcing to unsign makes the return value 
> useless and an error in fill_buffer() is not detected anymoe. 
>
> Best regards, 
> Stefano Babic 
>
> -- 
> ===================================================================== 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
> <javascript:> 
> ===================================================================== 
>
Roman Kalashnikov Oct. 20, 2017, 9:15 p.m. UTC | #3
The function fill_buffer should return unsigned int too, because it 
operates with size too.

суббота, 21 октября 2017 г., 0:13:40 UTC+3 пользователь Roman Kalashnikov 
написал:
>
> Yes, but also ret used for size arithmetic, so this lead to error when i'm 
> trying to install file bigger than 2147483648 bytes.
>
> суббота, 21 октября 2017 г., 0:06:48 UTC+3 пользователь Stefano Babic 
> написал:
>>
>> Hi Roman, 
>>
>> On 20/10/2017 22:48, Roman Kalashnikov wrote: 
>> > From: Roman Kalashnikov <lun...@gmail.com <mailto:lun...@gmail.com>> 
>> > 
>> > Signed-off-by: Roman Kalashnikov <lun...@gmail.com 
>> > <mailto:lun...@gmail.com>> 
>> > --- 
>> >  archival/gun.c | 6 +++--- 
>> >  1 file changed, 3 insertions(+), 3 deletions(-) 
>> > 
>> > diff --git a/archival/gun.c b/archival/gun.c 
>> > index ade0379..91dd134 100644 
>> > --- a/archival/gun.c 
>> > +++ b/archival/gun.c 
>> > @@ -45,8 +45,8 @@ struct ind { 
>> >      unsigned char *inbuf; 
>> >      unsigned long *offs; 
>> >      unsigned long *checksum; 
>> > - int nbytes; 
>> > - int total; 
>> > + unsigned int nbytes; 
>> > + unsigned int total; 
>> >      int percent; 
>> >      void *dgst; 
>> >  }; 
>> > @@ -56,7 +56,7 @@ struct ind { 
>> >     returns end-of-file or error. Return 0 on error. */ 
>> >  static unsigned in(void *in_desc, unsigned char **buf) 
>> >  { 
>> > - int ret; 
>> > + unsigned int ret; 
>>
>> This seems wrong. The variable is also used to check the return value of 
>> fill_buffer() some lines later. Forcing to unsign makes the return value 
>> useless and an error in fill_buffer() is not detected anymoe. 
>>
>> Best regards, 
>> Stefano Babic 
>>
>> -- 
>> ===================================================================== 
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
>> ===================================================================== 
>>
>
Stefano Babic Oct. 20, 2017, 9:16 p.m. UTC | #4
Hi Roman,

On 20/10/2017 23:13, Roman Kalashnikov wrote:
> Yes, but also ret used for size arithmetic, so this lead to error when
> i'm trying to install file bigger than 2147483648 bytes.
> 

Ok, but the fix is wrong. You should add another variable for size
arithmetic, and let ret as "return value".

Best regards,
Stefano Babic
Roman Kalashnikov Oct. 20, 2017, 9:20 p.m. UTC | #5
Will be done, boss :)

суббота, 21 октября 2017 г., 0:16:17 UTC+3 пользователь Stefano Babic 
написал:
>
> Hi Roman, 
>
> On 20/10/2017 23:13, Roman Kalashnikov wrote: 
> > Yes, but also ret used for size arithmetic, so this lead to error when 
> > i'm trying to install file bigger than 2147483648 bytes. 
> > 
>
> Ok, but the fix is wrong. You should add another variable for size 
> arithmetic, and let ret as "return value". 
>
> Best regards, 
> Stefano Babic 
>
> -- 
> ===================================================================== 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk 
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany 
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de 
> <javascript:> 
> ===================================================================== 
>
diff mbox series

Patch

diff --git a/archival/gun.c b/archival/gun.c
index ade0379..91dd134 100644
--- a/archival/gun.c
+++ b/archival/gun.c
@@ -45,8 +45,8 @@  struct ind {
     unsigned char *inbuf;
     unsigned long *offs;
     unsigned long *checksum;
- int nbytes;
- int total;
+ unsigned int nbytes;
+ unsigned int total;
     int percent;
     void *dgst;
 };
@@ -56,7 +56,7 @@  struct ind {
    returns end-of-file or error. Return 0 on error. */
 static unsigned in(void *in_desc, unsigned char **buf)
 {
- int ret;
+ unsigned int ret;
     unsigned len;
     unsigned char *next;
     struct ind *me = (struct ind *)in_desc;