[PATCH v2 5/5] staging: dgap: tty.c: removes smatch warning "unsigned '--un->un_open_count' is never less than zero"
Lidza Louina
lidza.louina at gmail.com
Thu Sep 26 22:49:13 UTC 2013
On Thu, Sep 26, 2013 at 6:22 AM, Dan Carpenter <dan.carpenter at oracle.com> wrote:
> On Wed, Sep 25, 2013 at 07:08:54PM -0400, Lidza Louina wrote:
>> This patch removes this smatch warning:
>> unsigned '--un->un_open_count' is never less than zero
>>
>> The code decremented the un_open_count variable
>> and tested to see if it was less than zero. Because
>> un_open_count is unsigned and can't be below zero,
>> this test didn't work.
>>
>> Signed-off-by: Lidza Louina <lidza.louina at gmail.com>
>> ---
>> drivers/staging/dgap/dgap_tty.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
>> index 3e12ddb..c0258db 100644
>> --- a/drivers/staging/dgap/dgap_tty.c
>> +++ b/drivers/staging/dgap/dgap_tty.c
>> @@ -1446,13 +1446,11 @@ static void dgap_tty_close(struct tty_struct *tty, struct file *file)
>> APR(("tty->count is 1, un open count is %d\n", un->un_open_count));
>> un->un_open_count = 1;
>> }
>> -
>> - if (--un->un_open_count < 0) {
>> + if (un->un_open_count == 0) {
>> APR(("bad serial port open count of %d\n", un->un_open_count));
>> - un->un_open_count = 0;
>> + un->un_open_count = 1;
>> }
>> -
>> - ch->ch_open_count--;
>
> Wait? Don't delete this line. We need to decrement both.
>
>> + un->un_open_count--;
>
> regards,
> dan carpenter
>
>
Ahh, I see. I'll resend this patch.
More information about the devel
mailing list