lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Aug 2023 12:08:16 +0200
From:   Jiri Slaby <jirislaby@...nel.org>
To:     Dan Carpenter <dan.carpenter@...aro.org>
Cc:     gregkh@...uxfoundation.org, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev
Subject: Re: [PATCH 34/36] tty: gdm724x: convert counts to size_t

On 10. 08. 23, 11:42, Dan Carpenter wrote:
> On Thu, Aug 10, 2023 at 11:15:08AM +0200, Jiri Slaby (SUSE) wrote:
>> Unify the type of tty_operations::write() counters with the 'count'
>> parameter. I.e. use size_t for them.
>>
>> This includes changing constants to UL to keep min() and avoid min_t().
>>
>> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@...nel.org>
>> Cc: linux-staging@...ts.linux.dev
>> ---
>>   drivers/staging/gdm724x/gdm_tty.c | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
>> index b31f2afb0286..cbaaa8fa7474 100644
>> --- a/drivers/staging/gdm724x/gdm_tty.c
>> +++ b/drivers/staging/gdm724x/gdm_tty.c
>> @@ -17,9 +17,9 @@
>>   #define GDM_TTY_MAJOR 0
>>   #define GDM_TTY_MINOR 32
>>   
>> -#define WRITE_SIZE 2048
>> +#define WRITE_SIZE 2048UL
>>   
>> -#define MUX_TX_MAX_SIZE 2048
>> +#define MUX_TX_MAX_SIZE 2048UL
>>   
>>   static inline bool gdm_tty_ready(struct gdm *gdm)
>>   {
>> @@ -152,9 +152,8 @@ static void gdm_tty_send_complete(void *arg)
>>   static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len)
>>   {
>>   	struct gdm *gdm = tty->driver_data;
>> -	int remain = len;
>> -	int sent_len = 0;
>> -	int sending_len = 0;
>> +	size_t remain = len;
> 
> We later check if remain <= 0.  It still works because remain could
> never be negative, but now it's even less necessary to check for
> negatives, I guess.

You're right. The whole loop should be now:

while (remain) {
   ...
}

Even without the preceding 'if'.

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ