All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lan Chunhe-B25806 <B25806@freescale.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: bug report: signedness issue in ds3232_update_alarm()
Date: Thu, 28 Oct 2010 11:17:38 +0000	[thread overview]
Message-ID: <op.vk99noiofud0ec@localhost.localdomain> (raw)
In-Reply-To: <20101028083503.GZ6062@bicker>

On Thu, 28 Oct 2010 18:58:40 +0800, Dan Carpenter <error27@gmail.com>  
wrote:

> On Thu, Oct 28, 2010 at 06:15:46PM +0800, Lan Chunhe-B25806 wrote:
>>       Of course, bcd2bin()/Time is never less than zero. But it is fault
>> tolerant.
>>       When time has exceptional data, it set time to the default value.
>>
>
> Sorry, I still don't understand what you're trying to do.  This showed
> up on my bug scanner, and I've studied it but as far as I can see it
> doesn't do anything.  I've created a sample program to demonstrate what
> I mean.

    If you must not display these message on your bug scanner, you can
    modify code from

    buf[0] = bcd2bin(buf[0]) < 0 || (ds3232->rtc->irq_data & RTC_UF) ?
						0x80 : buf[0];
    to

    buf[0] = (ds3232->rtc->irq_data & RTC_UF) ?
						0x80 : buf[0];

> It passes every possible non-zero value to bcd2bin() and counts how many
> of the returns are negative.
>
> regards,
> dan carpenter
>
> #include <stdio.h>
>
> unsigned bcd2bin(unsigned char val)
> {
>         return (val & 0x0f) + (val >> 4) * 10;
> }
>
> int main(int argc, char **argv)
> {
> 	unsigned char x;
> 	int useful = 0;
>
> 	for (x = 1; x; x++) {
> 		if (bcd2bin(x) < 0)
> 			useful++;
> 	}
>
> 	printf("useful = %d\n", useful);
> 	return 0;
> }
>
    Thanks.

    Jack Lan



      parent reply	other threads:[~2010-10-28 11:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28  8:35 bug report: signedness issue in ds3232_update_alarm() Dan Carpenter
2010-10-28  8:55 ` Dan Carpenter
2010-10-28 10:15 ` Lan Chunhe-B25806
2010-10-28 10:58 ` Dan Carpenter
2010-10-28 11:17 ` Lan Chunhe-B25806 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.vk99noiofud0ec@localhost.localdomain \
    --to=b25806@freescale.com \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.